Clean-up: utils: make utils_partial_realpath static
[lttng-tools.git] / src / common / utils.c
index bd61fff3d52ad8c6c16d68b0ca9e195009225018..ef22144d4e8637ddf15af3f456c11e0a10585efd 100644 (file)
@@ -65,7 +65,7 @@
  * to specify the size of the resolved_path argument if given, or the size to
  * allocate.
  */
-LTTNG_HIDDEN
+static
 char *utils_partial_realpath(const char *path, char *resolved_path, size_t size)
 {
        char *cut_path = NULL, *try_path = NULL, *try_path_prev = NULL;
@@ -1669,3 +1669,39 @@ end:
        free(buf);
        return ret_val;
 }
+
+LTTNG_HIDDEN
+int utils_parse_unsigned_long_long(const char *str,
+               unsigned long long *value)
+{
+       int ret;
+       char *endptr;
+
+       assert(str);
+       assert(value);
+
+       errno = 0;
+       *value = strtoull(str, &endptr, 10);
+
+       /* Conversion failed. Out of range? */
+       if (errno != 0) {
+               /* Don't print an error; allow the caller to log a better error. */
+               DBG("Failed to parse string as unsigned long long number: string = '%s', errno = %d",
+                               str, errno);
+               ret = -1;
+               goto end;
+       }
+
+       /* Not the end of the string or empty string. */
+       if (*endptr || endptr == str) {
+               DBG("Failed to parse string as unsigned long long number: string = '%s'",
+                               str);
+               ret = -1;
+               goto end;
+       }
+
+       ret = 0;
+
+end:
+       return ret;
+}
This page took 0.023223 seconds and 4 git commands to generate.