]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/table-types.c
tableprinter: size units are now static
[libucw.git] / ucw / table-types.c
index 063760b705314fe2dd9b65144563031542805ca4..1894a9a6daddf673b929461bc69ee7b3eeac75a9 100644 (file)
@@ -16,7 +16,7 @@
 
 /** xt_size **/
 
-struct unit_definition xtype_units_size[] = {
+static struct unit_definition xtype_units_size[] = {
   [SIZE_UNIT_BYTE] = { "", 1LLU, 1 },
   [SIZE_UNIT_KILOBYTE] = { "KB", 1024LLU, 1 },
   [SIZE_UNIT_MEGABYTE] = { "MB", 1024LLU * 1024LLU, 1 },
@@ -49,7 +49,7 @@ static const char *xt_size_format(void *src, u32 fmt, struct mempool *pool)
   return mp_printf(pool, "%"PRIu64"%s", curr_val, xtype_units_size[out_units].unit);
 }
 
-static const char * xt_size_fmt_parse(const char *opt_str, u32 *dest, struct mempool *pool)
+static const char *xt_size_fmt_parse(const char *opt_str, u32 *dest, struct mempool *pool)
 {
   if(opt_str == NULL) {
     return "NULL is not supported as a column argument.";
@@ -73,7 +73,7 @@ static const char *xt_size_parse(const char *str, void *dest, struct mempool *po
 {
   errno = 0;
   char *units_start = NULL;
-  u64 parsed = strtol(str, &units_start, 10);
+  u64 parsed = strtoul(str, &units_start, 10);
   if(str == units_start) {
     return mp_printf(pool, "Invalid value of size: '%s'.", str);
   }
@@ -92,7 +92,7 @@ static const char *xt_size_parse(const char *str, void *dest, struct mempool *po
 
   int unit_idx = xtype_unit_parser(units_start, xtype_units_size);
   if(unit_idx == -1) {
-    return mp_printf(pool, "Invalid format of size: '%s'.", str);
+    return mp_printf(pool, "Invalid units: '%s'.", units_start);
   }
 
   *(u64*) dest = parsed * xtype_units_size[unit_idx].num;
@@ -136,7 +136,7 @@ static const char *xt_timestamp_format(void *src, u32 fmt, struct mempool *pool)
   return mp_printf(pool, "%s", formatted_time_buf);
 }
 
-static const char * xt_timestamp_fmt_parse(const char *opt_str, u32 *dest, struct mempool *pool)
+static const char *xt_timestamp_fmt_parse(const char *opt_str, u32 *dest, struct mempool *pool)
 {
   if(opt_str == NULL) {
     return "NULL is not supported as a column argument.";
@@ -157,7 +157,7 @@ static const char *xt_timestamp_parse(const char *str, void *dest, struct mempoo
 {
   errno = 0;
   char *parse_end = NULL;
-  u64 parsed = strtol(str, &parse_end, 10);
+  u64 parsed = strtoul(str, &parse_end, 10);
   if(str == parse_end) {
     return mp_printf(pool, "Invalid value of timestamp: '%s'.", str);
   }