diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-07-19 16:24:55 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-08-05 21:33:21 +0100 |
commit | 6431194c1001b7798da8da28724546c652634de0 (patch) | |
tree | c1d43e63961843dc3cf1428d42f58f63b5fe4a9b /src | |
parent | 44ff06671a0662b4611512a26bd302d31c5915e0 (diff) | |
download | libguestfs-6431194c1001b7798da8da28724546c652634de0.tar.gz libguestfs-6431194c1001b7798da8da28724546c652634de0.tar.xz libguestfs-6431194c1001b7798da8da28724546c652634de0.zip |
lib: Use safe_asprintf when constructing attach_method.
Just a small code cleanup / simplification.
(cherry picked from commit eca544d87d9335123077e30b7547270b6bfe0f2b)
Diffstat (limited to 'src')
-rw-r--r-- | src/guestfs.c | 4 | ||||
-rw-r--r-- | src/libvirtdomain.c | 4 |
2 files changed, 2 insertions, 6 deletions
diff --git a/src/guestfs.c b/src/guestfs.c index 64d86949..f670a2e1 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -812,9 +812,7 @@ guestfs__get_attach_method (guestfs_h *g) break; case ATTACH_METHOD_UNIX: - ret = safe_malloc (g, strlen (g->attach_method_arg) + 5 + 1); - strcpy (ret, "unix:"); - strcat (ret, g->attach_method_arg); + ret = safe_asprintf (g, "unix:%s", g->attach_method_arg); break; default: /* keep GCC happy - this is not reached */ diff --git a/src/libvirtdomain.c b/src/libvirtdomain.c index 4ff23765..6be45289 100644 --- a/src/libvirtdomain.c +++ b/src/libvirtdomain.c @@ -584,9 +584,7 @@ connect_live (guestfs_h *g, virDomainPtr dom) } /* Got a path. */ - attach_method = safe_malloc (g, strlen (path) + 5 + 1); - strcpy (attach_method, "unix:"); - strcat (attach_method, path); + attach_method = safe_asprintf (g, "unix:%s", path); r = guestfs_set_attach_method (g, attach_method); cleanup: |