SoW-2020-0002: Trace Hit Counters: trigger error reporting integration
[lttng-tools.git] / src / common / utils.c
index 2a20e5a8c4ab4cca1557ca917cfa2de02defd905..3497f92dbb00aba9c07186c355f9b881b1a0f619 100644 (file)
@@ -679,8 +679,8 @@ int utils_mkdir(const char *path, mode_t mode, int uid, int gid)
        int ret;
        struct lttng_directory_handle *handle;
        const struct lttng_credentials creds = {
-               .uid = (uid_t) uid,
-               .gid = (gid_t) gid,
+               .uid = LTTNG_OPTIONAL_INIT_VALUE(uid),
+               .gid = LTTNG_OPTIONAL_INIT_VALUE(gid),
        };
 
        handle = lttng_directory_handle_create(NULL);
@@ -708,8 +708,8 @@ int utils_mkdir_recursive(const char *path, mode_t mode, int uid, int gid)
        int ret;
        struct lttng_directory_handle *handle;
        const struct lttng_credentials creds = {
-               .uid = (uid_t) uid,
-               .gid = (gid_t) gid,
+               .uid = LTTNG_OPTIONAL_INIT_VALUE(uid),
+               .gid = LTTNG_OPTIONAL_INIT_VALUE(gid),
        };
 
        handle = lttng_directory_handle_create(NULL);
@@ -1669,3 +1669,40 @@ 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) {
+               ret = -1;
+               goto end;
+       }
+
+       /* Not the end of the string? */
+       if (*endptr) {
+               ret = -1;
+               goto end;
+       }
+
+       /* Empty string? */
+       if (endptr == str) {
+               ret = -1;
+               goto end;
+       }
+
+       ret = 0;
+
+end:
+       return ret;
+}
This page took 0.024579 seconds and 5 git commands to generate.