summaryrefslogtreecommitdiffstats
path: root/daemon/blkid.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-01-24 15:13:32 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-01-24 17:00:23 +0000
commit43a6974cb35759d4772f610f3c92b0d31f0503ac (patch)
treeafaa7f4fc6679ae25d5186a5a84017685a8cc33a /daemon/blkid.c
parentf86c3a45ae19f5bb558ab9ead255ecaf004b24b0 (diff)
downloadlibguestfs-43a6974cb35759d4772f610f3c92b0d31f0503ac.tar.gz
libguestfs-43a6974cb35759d4772f610f3c92b0d31f0503ac.tar.xz
libguestfs-43a6974cb35759d4772f610f3c92b0d31f0503ac.zip
daemon: blkid: Whitespace changes, and use size_t for i instead of pointer.
This is just a code clean-up with no functional change.
Diffstat (limited to 'daemon/blkid.c')
-rw-r--r--daemon/blkid.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/daemon/blkid.c b/daemon/blkid.c
index 3126f85e..ada2d7b0 100644
--- a/daemon/blkid.c
+++ b/daemon/blkid.c
@@ -129,23 +129,24 @@ test_blkid_p_i_opt (void)
static char **
blkid_with_p_i_opt (const char *device)
{
+ size_t i;
int r;
char *out = NULL, *err = NULL;
char **lines = NULL;
char **ret = NULL;
int size = 0, alloc = 0;
- r = command(&out, &err, "blkid", "-c", "/dev/null",
+ r = command (&out, &err, "blkid", "-c", "/dev/null",
"-p", "-i", "-o", "export", device, NULL);
if (r == -1) {
- reply_with_error("%s", err);
+ reply_with_error ("%s", err);
goto error;
}
/* Split the command output into lines */
- lines = split_lines(out);
+ lines = split_lines (out);
if (lines == NULL) {
- reply_with_perror("malloc");
+ reply_with_perror ("malloc");
goto error;
}
@@ -164,38 +165,40 @@ blkid_with_p_i_opt (const char *device)
* PART_ENTRY_SIZE=104857600
* PART_ENTRY_DISK=8:0
*/
- for (char **i = lines; *i != NULL; i++) {
- char *line = *i;
+ for (i = 0; lines[i] != NULL; ++i) {
+ char *line = lines[i];
/* Skip blank lines (shouldn't happen) */
if (line[0] == '\0') continue;
/* Split the line in 2 at the equals sign */
- char *eq = strchr(line, '=');
+ char *eq = strchr (line, '=');
if (eq) {
*eq = '\0'; eq++;
/* Add the key/value pair to the output */
- if (add_string(&ret, &size, &alloc, line) == -1 ||
- add_string(&ret, &size, &alloc, eq) == -1) goto error;
+ if (add_string (&ret, &size, &alloc, line) == -1 ||
+ add_string (&ret, &size, &alloc, eq) == -1) goto error;
} else {
- fprintf(stderr, "blkid: unexpected blkid output ignored: %s", line);
+ fprintf (stderr, "blkid: unexpected blkid output ignored: %s", line);
}
}
- if (add_string(&ret, &size, &alloc, NULL) == -1) goto error;
+ if (add_string (&ret, &size, &alloc, NULL) == -1) goto error;
- free(out);
- free(err);
- free(lines);
+ free (out);
+ free (err);
+ free (lines);
return ret;
error:
- free(out);
- free(err);
- if (lines) free(lines);
- if (ret) free_strings(ret);
+ free (out);
+ free (err);
+ if (lines)
+ free (lines);
+ if (ret)
+ free_strings (ret);
return NULL;
}