Changes in / [d5a89a3:4805495] in mainline
- Location:
- uspace
- Files:
-
- 1 added
- 8 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/df/df.c
rd5a89a3 r4805495 70 70 71 71 /* Parse command-line options */ 72 while ((optres = getopt(argc, argv, " ubh")) != -1) {72 while ((optres = getopt(argc, argv, ":ubh")) != -1) { 73 73 switch (optres) { 74 74 case 'h': … … 78 78 case 'b': 79 79 display_blocks = true; 80 break; 81 82 case ':': 83 fprintf(stderr, "Option -%c requires an operand\n", 84 optopt); 85 errflg++; 80 86 break; 81 87 -
uspace/lib/c/Makefile
rd5a89a3 r4805495 190 190 TEST_SOURCES = \ 191 191 test/adt/circ_buf.c \ 192 test/adt/odict.c \193 192 test/casting.c \ 194 193 test/fibril/timer.c \ … … 198 197 test/io/table.c \ 199 198 test/stdio/scanf.c \ 199 test/odict.c \ 200 200 test/perf.c \ 201 201 test/perm.c \ … … 205 205 test/stdlib.c \ 206 206 test/str.c \ 207 test/string.c \ 208 test/cap.c \ 209 test/gsort.c \ 210 test/ieee_double.c \ 211 test/double_to_str.c \ 212 test/getopt.c \ 213 test/uuid.c \ 214 test/imath.c 207 test/string.c 215 208 216 209 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/c/generic/cap.c
rd5a89a3 r4805495 160 160 161 161 /* Round the number so that we have at most @c scap_max_sdig significant digits */ 162 rc = ilog10_u64(cap->m, &sdig); /* number of significant digits */ 163 sdig += 1; 164 assert(rc == EOK); 162 sdig = 1 + ilog10_u64(cap->m); /* number of significant digits */ 165 163 if (sdig > scap_max_sdig) { 166 164 /* Number of digits to remove */ -
uspace/lib/c/generic/gsort.c
rd5a89a3 r4805495 33 33 /** 34 34 * @file 35 * @brief Gnome Sort.35 * @brief Sorting functions. 36 36 * 37 * This file contains an implementation of gnome sort 37 * This files contains functions implementing several sorting 38 * algorithms (e.g. quick sort and gnome sort). 38 39 * 39 40 */ … … 79 80 if ((i != 0) && 80 81 (cmp(INDEX(data, i, elem_size), 81 INDEX(data, i - 1, elem_size), arg) <= -1)) {82 INDEX(data, i - 1, elem_size), arg) == -1)) { 82 83 memcpy(slot, INDEX(data, i, elem_size), elem_size); 83 84 memcpy(INDEX(data, i, elem_size), INDEX(data, i - 1, elem_size), -
uspace/lib/c/generic/ieee_double.c
rd5a89a3 r4805495 92 92 if (ret.is_denormal) { 93 93 ret.pos_val.significand = raw_significand; 94 if (raw_significand == 0) { 95 ret.pos_val.exponent = -exponent_bias; 96 } else { 97 ret.pos_val.exponent = 1 - exponent_bias; 98 } 99 94 ret.pos_val.exponent = 1 - exponent_bias; 100 95 ret.is_accuracy_step = false; 101 96 } else { -
uspace/lib/c/generic/imath.c
rd5a89a3 r4805495 50 50 errno_t ipow10_u64(unsigned exp, uint64_t *res) 51 51 { 52 u int64_ta;52 unsigned a; 53 53 uint64_t r; 54 54 … … 81 81 * 82 82 * @param v Value to compute logarithm from 83 * @param res Place to store result84 * @return EOK on success85 83 * @return Logarithm value 86 84 */ 87 errno_t ilog10_u64(uint64_t v, unsigned *res)85 unsigned ilog10_u64(uint64_t v) 88 86 { 89 if (v == 0)90 return ERANGE;91 92 87 unsigned b; 93 88 unsigned e; … … 122 117 } 123 118 124 *res = r; 125 return EOK; 119 return r; 126 120 } 127 121 -
uspace/lib/c/generic/string.c
rd5a89a3 r4805495 565 565 } 566 566 567 str ncpy(dup, s, sz);567 strcpy(dup, s); 568 568 return dup; 569 569 } -
uspace/lib/c/generic/uuid.c
rd5a89a3 r4805495 39 39 #include <stddef.h> 40 40 #include <str.h> 41 #include <stdio.h>42 41 43 42 /** Generate UUID. … … 65 64 66 65 /* Version 4 UUID from random or pseudo-random numbers */ 67 uuid->b[ 6] = (uuid->b[6] & 0x4F) | 0x40;68 uuid->b[ 8] = (uuid->b[8] & 0xBF) | 0xB0;69 70 r c =EOK;66 uuid->b[8] = (uuid->b[8] & ~0xc0) | 0x40; 67 uuid->b[6] = (uuid->b[6] & 0xf0) | 0x40; 68 69 return EOK; 71 70 error: 72 71 rndgen_destroy(rndgen); … … 140 139 141 140 rc = str_uint64_t(str + 24, &eptr, 16, false, &node); 142 if (rc != EOK || eptr != str + 36 )141 if (rc != EOK || eptr != str + 36 || *eptr != '\0') 143 142 return EINVAL; 144 143 … … 177 176 * @return EOK on success, ENOMEM if out of memory 178 177 */ 179 errno_t uuid_format(uuid_t *uuid, char **rstr , bool uppercase)178 errno_t uuid_format(uuid_t *uuid, char **rstr) 180 179 { 181 size_t size = 37; 182 char *str = malloc(sizeof(char) * size); 183 if (str == NULL) 184 return ENOMEM; 185 186 const char *format = "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"; 187 if (uppercase) 188 format = "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X"; 189 190 int ret = snprintf(str, size, format, uuid->b[0], uuid->b[1], uuid->b[2], uuid->b[3], uuid->b[4], uuid->b[5], uuid->b[6], uuid->b[7], uuid->b[8], uuid->b[9], uuid->b[10], uuid->b[11], uuid->b[12], uuid->b[13], uuid->b[14], uuid->b[15]); 191 192 if (ret != 36) 193 return EINVAL; 194 195 *rstr = str; 196 return EOK; 180 return ENOTSUP; 197 181 } 198 182 -
uspace/lib/c/include/imath.h
rd5a89a3 r4805495 40 40 41 41 extern errno_t ipow10_u64(unsigned, uint64_t *); 42 extern errno_t ilog10_u64(uint64_t, unsigned *);42 extern unsigned ilog10_u64(uint64_t); 43 43 44 44 #endif -
uspace/lib/c/include/uuid.h
rd5a89a3 r4805495 38 38 #include <stdint.h> 39 39 #include <types/uuid.h> 40 #include <stdbool.h>41 40 42 41 extern errno_t uuid_generate(uuid_t *); … … 44 43 extern void uuid_decode(uint8_t *, uuid_t *); 45 44 extern errno_t uuid_parse(const char *, uuid_t *, const char **); 46 extern errno_t uuid_format(uuid_t *, char ** , bool);45 extern errno_t uuid_format(uuid_t *, char **); 47 46 48 47 #endif -
uspace/lib/c/test/main.c
rd5a89a3 r4805495 48 48 PCUT_IMPORT(string); 49 49 PCUT_IMPORT(table); 50 PCUT_IMPORT(cap);51 PCUT_IMPORT(gsort);52 PCUT_IMPORT(ieee_double);53 PCUT_IMPORT(double_to_str);54 PCUT_IMPORT(getopt);55 PCUT_IMPORT(uuid);56 PCUT_IMPORT(imath);57 50 58 51 PCUT_MAIN();
Note:
See TracChangeset
for help on using the changeset viewer.