From 26fa681c4c55fe15513c86cde67237f8364058f8 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/20] EPEL 5: Don't use C99-style variable decls in for-loop.
---
daemon/md.c | 6 ++++--
generator/generator_bindtests.ml | 3 ++-
src/inspect_fs_unix.c | 22 ++++++++++++++--------
3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/daemon/md.c b/daemon/md.c
index 0e2f704..7baaab8 100644
--- a/daemon/md.c
+++ b/daemon/md.c
@@ -202,7 +202,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"
@@ -278,7 +279,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/generator_bindtests.ml b/generator/generator_bindtests.ml
index 76e5f38..8cf2fec 100644
--- a/generator/generator_bindtests.ml
+++ b/generator/generator_bindtests.ml
@@ -185,7 +185,8 @@ print_strings (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 06936c2..4dc9f6e 100644
--- a/src/inspect_fs_unix.c
+++ b/src/inspect_fs_unix.c
@@ -918,7 +918,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];
}
@@ -931,7 +932,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;
}
@@ -995,8 +997,9 @@ 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 **detail = guestfs_md_detail(g, *md);
+ char **md, **detail;
+ for (md = mds; *md != NULL; md++) {
+ detail = guestfs_md_detail(g, *md);
if (detail == NULL) goto error;
/* Iterate over keys until we find uuid */
@@ -1116,7 +1119,8 @@ map_md_devices(guestfs_h *g, Hash_table **map)
mdadm_app_free);
if (!*map) g->abort_cb();
- for (char **match = matches; *match != NULL; match++) {
+ char **match;
+ for (match = matches; *match != NULL; match++) {
/* Get device name and uuid for each array */
char *dev_path = safe_asprintf(g, "%s/devicename", *match);
char *dev = guestfs_aug_get(g, dev_path);
@@ -1241,7 +1245,8 @@ resolve_fstab_device (guestfs_h *g, const char *spec, Hash_table *md_map)
/* Calculate the numerical index of the disk */
i = disk[0] - 'a';
- for (char *p = disk + 1; *p != '\0'; p++) {
+ char *p;
+ for (p = disk + 1; *p != '\0'; p++) {
i += 1; i *= 26;
i += *p - 'a';
}
@@ -1335,7 +1340,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);
@@ -1373,7 +1379,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