From: Richard Jones Date: Thu, 22 Jul 2010 15:51:05 +0000 (+0100) Subject: Move variable initialization close to variable use. X-Git-Tag: 1.2.11~3 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=3f29445be95f31fff90f38fa724e70e7d7173772;p=libguestfs.git Move variable initialization close to variable use. (cherry picked from commit 2fd8c259d3daa88b0cdf98090bb57f3dbd178432) --- diff --git a/src/guestfs.c b/src/guestfs.c index e55b9ba..68b5b06 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -830,9 +830,6 @@ int guestfs__add_drive_ro_with_if (guestfs_h *g, const char *filename, const char *drive_if) { - size_t len = strlen (filename) + 64; - char buf[len]; - if (strchr (filename, ',') != NULL) { error (g, _("filename cannot contain ',' (comma) character")); return -1; @@ -843,6 +840,9 @@ guestfs__add_drive_ro_with_if (guestfs_h *g, const char *filename, return -1; } + size_t len = strlen (filename) + 64; + char buf[len]; + snprintf (buf, len, "file=%s,snapshot=on,if=%s", filename, drive_if); return guestfs__config (g, "-drive", buf);