diff options
author | Colin Walters <walters@verbum.org> | 2016-05-06 09:56:24 -0400 |
---|---|---|
committer | Colin Walters (automation) <walters+githubbot@verbum.org> | 2016-05-07 06:52:05 +0000 |
commit | bf6e3564a30a0e4ddd738ede44dd12cf9aa2c319 (patch) | |
tree | b34750313ea82cabc8d4cd68a373dfeb2d38633e | |
parent | f525e670b8a50f8775b89d70e152bef92ee44f4e (diff) | |
download | bubblewrap-bf6e3564a30a0e4ddd738ede44dd12cf9aa2c319.tar.gz |
utils: Rename strdup_printf -> xasprintf
I find this clearer since I know about `asprintf`, and the `x` prefix.
Closes: #55
Approved by: alexlarsson
-rw-r--r-- | bubblewrap.c | 10 | ||||
-rw-r--r-- | utils.c | 8 | ||||
-rw-r--r-- | utils.h | 4 |
3 files changed, 11 insertions, 11 deletions
diff --git a/bubblewrap.c b/bubblewrap.c index 07986e0..4b5abb6 100644 --- a/bubblewrap.c +++ b/bubblewrap.c @@ -434,7 +434,7 @@ write_uid_gid_map (uid_t sandbox_uid, cleanup_free char *uid_map = NULL; cleanup_free char *gid_map = NULL; - uid_map = strdup_printf ("%d %d 1\n", sandbox_uid, parent_uid); + uid_map = xasprintf ("%d %d 1\n", sandbox_uid, parent_uid); if (write_file_at (proc_fd, "self/uid_map", uid_map) != 0) die_with_error ("setting up uid map"); @@ -442,7 +442,7 @@ write_uid_gid_map (uid_t sandbox_uid, write_file_at (proc_fd, "self/setgroups", "deny\n") != 0) die_with_error ("error writing to setgroups"); - gid_map = strdup_printf ("%d %d 1\n", sandbox_gid, parent_gid); + gid_map = xasprintf ("%d %d 1\n", sandbox_gid, parent_gid); if (write_file_at (proc_fd, "self/gid_map", gid_map) != 0) die_with_error ("setting up gid map"); } @@ -635,7 +635,7 @@ setup_newroot (bool unshare_pid, static const char *const stdionodes[] = { "stdin", "stdout", "stderr" }; for (i = 0; i < N_ELEMENTS (stdionodes); i++) { - cleanup_free char *target = strdup_printf ("/proc/self/fd/%d", i); + cleanup_free char *target = xasprintf ("/proc/self/fd/%d", i); cleanup_free char *node_dest = strconcat3 (dest, "/", stdionodes[i]); if (symlink (target, node_dest) < 0) die_with_error ("Can't create symlink %s/%s", op->dest, stdionodes[i]); @@ -1281,11 +1281,11 @@ main (int argc, /* We need *some* mountpoint where we can mount the root tmpfs. We first try in /run, and if that fails, try in /tmp. */ - base_path = strdup_printf ("/run/user/%d/.bubblewrap", uid); + base_path = xasprintf ("/run/user/%d/.bubblewrap", uid); if (mkdir (base_path, 0755) && errno != EEXIST) { free (base_path); - base_path = strdup_printf ("/tmp/.bubblewrap-%d", uid); + base_path = xasprintf ("/tmp/.bubblewrap-%d", uid); if (mkdir (base_path, 0755) && errno != EEXIST) die_with_error ("Creating root mountpoint failed"); } @@ -239,8 +239,8 @@ strconcat3 (const char *s1, } char* -strdup_printf (const char *format, - ...) +xasprintf (const char *format, + ...) { char *buffer = NULL; va_list args; @@ -640,9 +640,9 @@ label_mount (const char *opt, const char *mount_label) if (mount_label) { if (opt) - return strdup_printf ("%s,context=\"%s\"", opt, mount_label); + return xasprintf ("%s,context=\"%s\"", opt, mount_label); else - return strdup_printf ("context=\"%s\"", mount_label); + return xasprintf ("context=\"%s\"", mount_label); } #endif if (opt) @@ -70,8 +70,8 @@ char *strconcat (const char *s1, char *strconcat3 (const char *s1, const char *s2, const char *s3); -char* strdup_printf (const char *format, - ...) __attribute__((format(printf, 1, 2))); +char* xasprintf (const char *format, + ...) __attribute__((format(printf, 1, 2))); bool has_prefix (const char *str, const char *prefix); bool has_path_prefix (const char *str, |