summaryrefslogtreecommitdiffstats
path: root/src
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 /src
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.
Diffstat (limited to 'src')
-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
8 files changed, 35 insertions, 30 deletions
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;