summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-09-17 13:15:49 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-09-17 13:37:06 +0100
commite128a627fb8f39f4f4c11b782cef895bd79f0282 (patch)
tree4c75d040a7441f5019d41d3f05790ed009e1ae80
parentc387b69cba8f145438188b2b4567abbc9580ade0 (diff)
downloadlibguestfs-e128a627fb8f39f4f4c11b782cef895bd79f0282.tar.gz
libguestfs-e128a627fb8f39f4f4c11b782cef895bd79f0282.tar.xz
libguestfs-e128a627fb8f39f4f4c11b782cef895bd79f0282.zip
Fix multiple errors where jump skips variable initialization.
<file>: error: jump skips variable initialization [-Werror=jump-misses-init] This has only just appeared, possibly related to previous gnulib update. In any case, this is just code motion / cleanup.
-rw-r--r--daemon/luks.c10
-rw-r--r--fish/fish.c11
-rw-r--r--fish/keys.c9
-rw-r--r--src/filearch.c13
-rw-r--r--src/fuse.c6
-rw-r--r--src/inspect-apps.c10
-rw-r--r--src/inspect-fs-windows.c16
-rw-r--r--src/launch-appliance.c6
-rw-r--r--src/launch-libvirt.c4
-rw-r--r--src/launch-unix.c4
-rw-r--r--src/libvirtdomain.c6
11 files changed, 54 insertions, 41 deletions
diff --git a/daemon/luks.c b/daemon/luks.c
index 3e3b4567..9ce8e2cf 100644
--- a/daemon/luks.c
+++ b/daemon/luks.c
@@ -40,19 +40,23 @@ optgroup_luks_available (void)
static char *
write_key_to_temp (const char *key)
{
- char *tempfile = strdup ("/tmp/luksXXXXXX");
+ char *tempfile;
+ int fd;
+ size_t len;
+
+ tempfile = strdup ("/tmp/luksXXXXXX");
if (!tempfile) {
reply_with_perror ("strdup");
return NULL;
}
- int fd = mkstemp (tempfile);
+ fd = mkstemp (tempfile);
if (fd == -1) {
reply_with_perror ("mkstemp");
goto error;
}
- size_t len = strlen (key);
+ len = strlen (key);
if (xwrite (fd, key, len) == -1) {
reply_with_perror ("write");
close (fd);
diff --git a/fish/fish.c b/fish/fish.c
index d0e2d8a9..c46cd116 100644
--- a/fish/fish.c
+++ b/fish/fish.c
@@ -1684,22 +1684,25 @@ static char *
file_in_heredoc (const char *endmarker)
{
TMP_TEMPLATE_ON_STACK (template);
+ int fd;
+ size_t markerlen;
+ char buffer[BUFSIZ];
+ int write_error = 0;
+
file_in_tmpfile = strdup (template);
if (file_in_tmpfile == NULL) {
perror ("strdup");
return NULL;
}
- int fd = mkstemp (file_in_tmpfile);
+ fd = mkstemp (file_in_tmpfile);
if (fd == -1) {
perror ("mkstemp");
goto error1;
}
- size_t markerlen = strlen (endmarker);
+ markerlen = strlen (endmarker);
- char buffer[BUFSIZ];
- int write_error = 0;
while (fgets (buffer, sizeof buffer, stdin) != NULL) {
/* Look for "END"<EOF> or "END\n" in input. */
size_t blen = strlen (buffer);
diff --git a/fish/keys.c b/fish/keys.c
index 80c05012..8db937ff 100644
--- a/fish/keys.c
+++ b/fish/keys.c
@@ -39,6 +39,10 @@ read_key (const char *param)
FILE *infp, *outfp;
struct termios orig, temp;
char *ret = NULL;
+ int tty;
+ int tcset = 0;
+ size_t n = 0;
+ ssize_t len;
/* Read and write to /dev/tty if available. */
if (keys_from_stdin ||
@@ -48,8 +52,7 @@ read_key (const char *param)
}
/* Print the prompt and set no echo. */
- int tty = isatty (fileno (infp));
- int tcset = 0;
+ tty = isatty (fileno (infp));
if (tty) {
fprintf (outfp, _("Enter key or passphrase (\"%s\"): "), param);
@@ -66,8 +69,6 @@ read_key (const char *param)
}
}
- size_t n = 0;
- ssize_t len;
len = getline (&ret, &n, infp);
if (len == -1) {
perror ("getline");
diff --git a/src/filearch.c b/src/filearch.c
index 1802ec47..0b5d37bb 100644
--- a/src/filearch.c
+++ b/src/filearch.c
@@ -135,10 +135,13 @@ cpio_arch (guestfs_h *g, const char *file, const char *path)
char cmd[cmd_len];
#define bin_len (dir_len + 32)
char bin[bin_len];
-
char *ret = NULL;
-
const char *method;
+ int64_t size;
+ int r;
+ const char *bins[] = INITRD_BINARIES2;
+ size_t i;
+
if (strstr (file, "gzip"))
method = "zcat";
else if (strstr (file, "bzip2"))
@@ -147,7 +150,7 @@ cpio_arch (guestfs_h *g, const char *file, const char *path)
method = "cat";
/* Security: Refuse to download initrd if it is huge. */
- int64_t size = guestfs_filesize (g, path);
+ size = guestfs_filesize (g, path);
if (size == -1 || size > 100000000) {
error (g, _("size of %s unreasonable (%" PRIi64 " bytes)"),
path, size);
@@ -166,14 +169,12 @@ cpio_arch (guestfs_h *g, const char *file, const char *path)
snprintf (cmd, cmd_len,
"cd %s && %s initrd | cpio --quiet -id " INITRD_BINARIES1,
dir, method);
- int r = system (cmd);
+ r = system (cmd);
if (r == -1 || WEXITSTATUS (r) != 0) {
perrorf (g, "cpio command failed");
goto out;
}
- const char *bins[] = INITRD_BINARIES2;
- size_t i;
for (i = 0; i < sizeof bins / sizeof bins[0]; ++i) {
snprintf (bin, bin_len, "%s/%s", dir, bins[i]);
diff --git a/src/fuse.c b/src/fuse.c
index 349a5b96..7342e5c2 100644
--- a/src/fuse.c
+++ b/src/fuse.c
@@ -750,6 +750,8 @@ mount_local_getxattr (const char *path, const char *name, char *value,
const struct guestfs_xattr_list *xattrs;
int free_attrs = 0;
+ ssize_t r;
+ size_t i, sz;
xattrs = xac_lookup (g, path);
if (xattrs == NULL) {
@@ -760,8 +762,6 @@ mount_local_getxattr (const char *path, const char *name, char *value,
}
/* Find the matching attribute (index in 'i'). */
- ssize_t r;
- size_t i;
for (i = 0; i < xattrs->len; ++i) {
if (STREQ (xattrs->val[i].attrname, name))
break;
@@ -779,7 +779,7 @@ mount_local_getxattr (const char *path, const char *name, char *value,
* copy as much as possible and return -ERANGE if there's not enough
* space in the buffer.
*/
- size_t sz = xattrs->val[i].attrval_len;
+ sz = xattrs->val[i].attrval_len;
if (value == NULL) {
r = sz;
goto out;
diff --git a/src/inspect-apps.c b/src/inspect-apps.c
index b021320d..67c7dd57 100644
--- a/src/inspect-apps.c
+++ b/src/inspect-apps.c
@@ -264,6 +264,7 @@ list_applications_rpm (guestfs_h *g, struct inspect_fs *fs)
char *Name = NULL, *Packages = NULL;
struct rpm_names_list list = { .names = NULL, .len = 0 };
struct guestfs_application_list *apps = NULL;
+ struct read_package_data data = { .list = &list, .apps = apps };
Name = guestfs___download_to_tmp (g, fs,
"/var/lib/rpm/Name", "rpm_Name",
@@ -290,7 +291,6 @@ list_applications_rpm (guestfs_h *g, struct inspect_fs *fs)
apps->val = NULL;
/* Read Packages database. */
- struct read_package_data data = { .list = &list, .apps = apps };
if (guestfs___read_db_dump (g, Packages, &data, read_package) == -1)
goto error;
@@ -424,6 +424,10 @@ list_applications_windows (guestfs_h *g, struct inspect_fs *fs)
}
struct guestfs_application_list *ret = NULL;
+ const char *hivepath[] =
+ { "Microsoft", "Windows", "CurrentVersion", "Uninstall" };
+ const char *hivepath2[] =
+ { "WOW6432node", "Microsoft", "Windows", "CurrentVersion", "Uninstall" };
if (guestfs_hivex_open (g, software_path,
GUESTFS_HIVEX_OPEN_VERBOSE, g->verbose, -1) == -1)
@@ -435,16 +439,12 @@ list_applications_windows (guestfs_h *g, struct inspect_fs *fs)
ret->val = NULL;
/* Ordinary native applications. */
- const char *hivepath[] =
- { "Microsoft", "Windows", "CurrentVersion", "Uninstall" };
list_applications_windows_from_path (g, ret, hivepath,
sizeof hivepath / sizeof hivepath[0]);
/* 32-bit emulated Windows apps running on the WOW64 emulator.
* http://support.microsoft.com/kb/896459 (RHBZ#692545).
*/
- const char *hivepath2[] =
- { "WOW6432node", "Microsoft", "Windows", "CurrentVersion", "Uninstall" };
list_applications_windows_from_path (g, ret, hivepath2,
sizeof hivepath2 / sizeof hivepath2[0]);
diff --git a/src/inspect-fs-windows.c b/src/inspect-fs-windows.c
index e972e97b..75c7dd98 100644
--- a/src/inspect-fs-windows.c
+++ b/src/inspect-fs-windows.c
@@ -223,14 +223,17 @@ check_windows_software_registry (guestfs_h *g, struct inspect_fs *fs)
*/
return 0;
+ int64_t node;
+ const char *hivepath[] =
+ { "Microsoft", "Windows NT", "CurrentVersion" };
+ size_t i;
+ struct guestfs_hivex_value_list *values = NULL;
+
if (guestfs_hivex_open (g, software_path,
GUESTFS_HIVEX_OPEN_VERBOSE, g->verbose, -1) == -1)
goto out;
- int64_t node = guestfs_hivex_root (g);
- const char *hivepath[] =
- { "Microsoft", "Windows NT", "CurrentVersion" };
- size_t i;
+ node = guestfs_hivex_root (g);
for (i = 0; node > 0 && i < sizeof hivepath / sizeof hivepath[0]; ++i)
node = guestfs_hivex_node_get_child (g, node, hivepath[i]);
@@ -242,7 +245,6 @@ check_windows_software_registry (guestfs_h *g, struct inspect_fs *fs)
goto out;
}
- struct guestfs_hivex_value_list *values = NULL;
values = guestfs_hivex_node_values (g, node);
for (i = 0; i < values->len; ++i) {
@@ -329,6 +331,8 @@ check_windows_system_registry (guestfs_h *g, struct inspect_fs *fs)
size_t i, count;
char *buf = NULL;
size_t buflen;
+ const char *hivepath[] =
+ { fs->windows_current_control_set, "Services", "Tcpip", "Parameters" };
if (guestfs_hivex_open (g, system_path,
GUESTFS_HIVEX_OPEN_VERBOSE, g->verbose, -1) == -1)
@@ -425,8 +429,6 @@ check_windows_system_registry (guestfs_h *g, struct inspect_fs *fs)
skip_drive_letter_mappings:;
/* Get the hostname. */
- const char *hivepath[] =
- { fs->windows_current_control_set, "Services", "Tcpip", "Parameters" };
for (node = root, i = 0;
node > 0 && i < sizeof hivepath / sizeof hivepath[0];
++i) {
diff --git a/src/launch-appliance.c b/src/launch-appliance.c
index ff3b7308..3cc99675 100644
--- a/src/launch-appliance.c
+++ b/src/launch-appliance.c
@@ -128,6 +128,9 @@ launch_appliance (guestfs_h *g, const char *arg)
int wfd[2], rfd[2];
char guestfsd_sock[256];
struct sockaddr_un addr;
+ char *kernel = NULL, *initrd = NULL, *appliance = NULL;
+ uint32_t size;
+ void *buf = NULL;
/* At present you must add drives before starting the appliance. In
* future when we enable hotplugging you won't need to do this.
@@ -142,7 +145,6 @@ launch_appliance (guestfs_h *g, const char *arg)
TRACE0 (launch_build_appliance_start);
/* Locate and/or build the appliance. */
- char *kernel = NULL, *initrd = NULL, *appliance = NULL;
if (guestfs___build_appliance (g, &kernel, &initrd, &appliance) == -1)
return -1;
@@ -635,8 +637,6 @@ launch_appliance (guestfs_h *g, const char *arg)
goto cleanup1;
}
- uint32_t size;
- void *buf = NULL;
r = guestfs___recv_from_daemon (g, &size, &buf);
free (buf);
diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c
index c4ca817f..619cc0eb 100644
--- a/src/launch-libvirt.c
+++ b/src/launch-libvirt.c
@@ -112,6 +112,8 @@ launch_libvirt (guestfs_h *g, const char *libvirt_uri)
char console_sock[256];
struct sockaddr_un addr;
int console = -1, r;
+ uint32_t size;
+ void *buf = NULL;
/* At present you must add drives before starting the appliance. In
* future when we enable hotplugging you won't need to do this.
@@ -338,8 +340,6 @@ launch_libvirt (guestfs_h *g, const char *libvirt_uri)
goto cleanup;
}
- uint32_t size;
- void *buf = NULL;
r = guestfs___recv_from_daemon (g, &size, &buf);
free (buf);
diff --git a/src/launch-unix.c b/src/launch-unix.c
index ab0e9d07..778082c5 100644
--- a/src/launch-unix.c
+++ b/src/launch-unix.c
@@ -38,6 +38,8 @@ launch_unix (guestfs_h *g, const char *sockpath)
{
int r;
struct sockaddr_un addr;
+ uint32_t size;
+ void *buf = NULL;
if (g->qemu_params) {
error (g, _("cannot set qemu parameters with the 'unix:' attach method"));
@@ -75,8 +77,6 @@ launch_unix (guestfs_h *g, const char *sockpath)
goto cleanup;
}
- uint32_t size;
- void *buf = NULL;
r = guestfs___recv_from_daemon (g, &size, &buf);
free (buf);
diff --git a/src/libvirtdomain.c b/src/libvirtdomain.c
index fe871ed6..5a055141 100644
--- a/src/libvirtdomain.c
+++ b/src/libvirtdomain.c
@@ -177,6 +177,7 @@ guestfs___for_each_disk (guestfs_h *g,
xmlXPathContextPtr xpathCtx = NULL;
xmlXPathObjectPtr xpathObj = NULL;
char *xml = NULL;
+ xmlNodeSetPtr nodes;
/* Domain XML. */
xml = virDomainGetXMLDesc (dom, 0);
@@ -210,7 +211,7 @@ guestfs___for_each_disk (guestfs_h *g,
goto cleanup;
}
- xmlNodeSetPtr nodes = xpathObj->nodesetval;
+ nodes = xpathObj->nodesetval;
for (i = 0; i < nodes->nodeNr; ++i) {
xmlXPathObjectPtr xptype;
@@ -504,6 +505,7 @@ connect_live (guestfs_h *g, virDomainPtr dom)
char *xml = NULL;
char *path = NULL;
char *attach_method = NULL;
+ xmlNodeSetPtr nodes;
/* Domain XML. */
xml = virDomainGetXMLDesc (dom, 0);
@@ -543,7 +545,7 @@ connect_live (guestfs_h *g, virDomainPtr dom)
goto cleanup;
}
- xmlNodeSetPtr nodes = xpathObj->nodesetval;
+ nodes = xpathObj->nodesetval;
for (i = 0; i < nodes->nodeNr; ++i) {
xmlXPathObjectPtr xppath;