From eec40bf750b09ead53433ca62d02857a3ae7cc9d Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Thu, 22 Jul 2010 16:51:05 +0100 Subject: [PATCH] Move variable initialization close to variable use. (cherry picked from commit 2fd8c259d3daa88b0cdf98090bb57f3dbd178432) --- src/guestfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/guestfs.c b/src/guestfs.c index e7a5e66..9027ccf 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -836,9 +836,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; @@ -849,6 +846,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); -- 1.8.3.1