psss / rpms / libguestfs

Forked from rpms/libguestfs 5 years ago
Clone
Blob Blame History Raw
From c8f8e45763bc22912b41a4180ba5033e568b380f Mon Sep 17 00:00:00 2001
From: Richard W.M. Jones <rjones@redhat.com>
Date: Sat, 16 Jun 2012 13:55:44 +0100
Subject: [PATCH 04/36] EPEL 5: Don't use C99-style variable decls in for-loop.

---
 daemon/btrfs.c         |    3 ++-
 daemon/md.c            |    6 ++++--
 generator/bindtests.ml |    3 ++-
 src/inspect-fs-unix.c  |   17 +++++++++++------
 4 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 81ce5f5..7053642 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -388,7 +388,8 @@ do_btrfs_subvolume_list (const char *fs)
     goto error;
   }
 
-  for (size_t i = 0; i < nr_subvolumes; ++i) {
+  size_t i;
+  for (i = 0; i < nr_subvolumes; ++i) {
     /* To avoid allocations, reuse the 'line' buffer to store the
      * path.  Thus we don't need to free 'line', since it will be
      * freed by the calling (XDR) code.
diff --git a/daemon/md.c b/daemon/md.c
index b302a8c..d106783 100644
--- a/daemon/md.c
+++ b/daemon/md.c
@@ -201,7 +201,8 @@ do_list_md_devices (void)
     goto error;
   }
 
-  for (size_t i = 0; i < mds.gl_pathc; i++) {
+  size_t i;
+  for (i = 0; i < mds.gl_pathc; i++) {
     size_t len = strlen (mds.gl_pathv[i]) - strlen (PREFIX) - strlen (SUFFIX);
 
 #define DEV "/dev/md"
@@ -277,7 +278,8 @@ do_md_detail(const char *md)
        * case */
       if (STRPREFIX (line, "MD_")) {
         line += 3;
-        for (char *j = line; *j != '\0'; j++) {
+        char *j;
+        for (j = line; *j != '\0'; j++) {
           *j = c_tolower (*j);
         }
       }
diff --git a/generator/bindtests.ml b/generator/bindtests.ml
index 55c39cb..6650547 100644
--- a/generator/bindtests.ml
+++ b/generator/bindtests.ml
@@ -250,7 +250,8 @@ print_strings (guestfs_h *g, char *const *argv)
              pr "  r = safe_calloc (g, sizeof *r, 1);\n";
              pr "  r->len = len;\n";
              pr "  r->val = safe_calloc (g, r->len, sizeof *r->val);\n";
-             pr "  for (size_t i = 0; i < r->len; i++) {\n";
+             pr "  size_t i;\n";
+             pr "  for (i = 0; i < r->len; i++) {\n";
              pr "    r->val[i].pv_size = i;\n";
              pr "  }\n";
              pr "  return r;\n"
diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c
index d3dae37..67e83b7 100644
--- a/src/inspect-fs-unix.c
+++ b/src/inspect-fs-unix.c
@@ -999,7 +999,8 @@ uuid_hash(const void *x, size_t table_size)
   const md_uuid *a = x;
 
   size_t h = a->uuid[0];
-  for (size_t i = 1; i < 4; i++) {
+  size_t i;
+  for (i = 1; i < 4; i++) {
     h ^= a->uuid[i];
   }
 
@@ -1012,7 +1013,8 @@ uuid_cmp(const void *x, const void *y)
   const md_uuid *a = x;
   const md_uuid *b = y;
 
-  for (size_t i = 0; i < 1; i++) {
+  size_t i;
+  for (i = 0; i < 1; i++) {
     if (a->uuid[i] != b->uuid[i]) return 0;
   }
 
@@ -1076,7 +1078,8 @@ map_app_md_devices (guestfs_h *g, Hash_table **map)
   mds = guestfs_list_md_devices(g);
   if (mds == NULL) goto error;
 
-  for (char **md = mds; *md != NULL; md++) {
+  char **md;
+  for (md = mds; *md != NULL; md++) {
     CLEANUP_FREE_STRING_LIST char **detail = guestfs_md_detail (g, *md);
     if (detail == NULL) goto error;
 
@@ -1187,7 +1190,8 @@ map_md_devices(guestfs_h *g, Hash_table **map)
                                    mdadm_app_free);
   if (!*map) g->abort_cb();
 
-  for (char **m = matches; *m != NULL; m++) {
+  char **m;
+  for (m = matches; *m != NULL; m++) {
     /* Get device name and uuid for each array */
     CLEANUP_FREE char *dev_path = safe_asprintf (g, "%s/devicename", *m);
     char *dev = guestfs_aug_get (g, dev_path);
@@ -1480,7 +1484,8 @@ inspect_with_augeas (guestfs_h *g, struct inspect_fs *fs,
                      int (*f) (guestfs_h *, struct inspect_fs *))
 {
   /* Security: Refuse to do this if a config file is too large. */
-  for (const char **i = configfiles; *i != NULL; i++) {
+  const char **i;
+  for (i = configfiles; *i != NULL; i++) {
     if (guestfs_exists(g, *i) == 0) continue;
 
     int64_t size = guestfs_filesize (g, *i);
@@ -1519,7 +1524,7 @@ inspect_with_augeas (guestfs_h *g, struct inspect_fs *fs,
 
 #define EXCL " and . != \""
 #define EXCL_LEN (strlen(EXCL))
-  for (const char **i = &configfiles[1]; *i != NULL; i++) {
+  for (i = &configfiles[1]; *i != NULL; i++) {
     size_t orig_buflen = buflen;
     conflen = strlen(*i);
     buflen += EXCL_LEN + conflen + 1 /* Closing " */;
-- 
1.7.4.1