summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2016-05-06 09:56:24 -0400
committerColin Walters (automation) <walters+githubbot@verbum.org>2016-05-07 06:52:05 +0000
commitbf6e3564a30a0e4ddd738ede44dd12cf9aa2c319 (patch)
treeb34750313ea82cabc8d4cd68a373dfeb2d38633e
parentf525e670b8a50f8775b89d70e152bef92ee44f4e (diff)
downloadbubblewrap-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.c10
-rw-r--r--utils.c8
-rw-r--r--utils.h4
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");
}
diff --git a/utils.c b/utils.c
index fd0b6d2..3c4985a 100644
--- a/utils.c
+++ b/utils.c
@@ -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)
diff --git a/utils.h b/utils.h
index a6f709d..2291093 100644
--- a/utils.h
+++ b/utils.h
@@ -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,