mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
Avoid gcc warnings about infinite loop.
This seemingly redundant change avoids a gcc warning/error: error: cannot optimize possibly infinite loops See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=34114#c3 and following for an explanation. Of course gcc is completely wrong and stupid here, because there's no possibility on current or future hardware that an array of size SSIZE_MAX could be allocated since it would by definition occupy at least all addressible memory (if it was an array of bytes, which this isn't), leaving no room for the code that is being compiled.
This commit is contained in:
@@ -547,7 +547,7 @@ debug_progress (const char *subcmd, size_t argc, char *const *const argv)
|
||||
uint64_t tsecs = secs * 10; /* 1/10ths of seconds */
|
||||
uint64_t i;
|
||||
|
||||
for (i = 1; i <= tsecs; ++i) {
|
||||
for (i = 1; i < tsecs+1; ++i) {
|
||||
usleep (100000);
|
||||
notify_progress (i, tsecs);
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ do_vgcreate (const char *volgroup, char *const *physvols)
|
||||
argv[0] = str_lvm;
|
||||
argv[1] = "vgcreate";
|
||||
argv[2] = volgroup;
|
||||
for (i = 3; i <= argc; ++i)
|
||||
for (i = 3; i < argc+1; ++i)
|
||||
argv[i] = physvols[i-3];
|
||||
|
||||
r = commandv (NULL, &err, (const char * const*) argv);
|
||||
@@ -522,7 +522,7 @@ do_vg_activate (int activate, char *const *volgroups)
|
||||
argv[1] = "vgchange";
|
||||
argv[2] = "-a";
|
||||
argv[3] = activate ? "y" : "n";
|
||||
for (i = 4; i <= argc; ++i)
|
||||
for (i = 4; i < argc+1; ++i)
|
||||
argv[i] = volgroups[i-4];
|
||||
|
||||
r = commandv (NULL, &err, (const char * const*) argv);
|
||||
|
||||
@@ -467,7 +467,7 @@ parse_md_stat_line (char *line)
|
||||
return ret;
|
||||
|
||||
error:
|
||||
for (i = 0; i <= spaces; ++i) {
|
||||
for (i = 0; i < spaces+1; ++i) {
|
||||
free (ret->guestfs_int_mdstat_list_val[i].mdstat_device);
|
||||
free (ret->guestfs_int_mdstat_list_val[i].mdstat_flags);
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ do_internal_lxattrlist (const char *path, char *const *names)
|
||||
* entry[1..nr_attrs] are the attributes.
|
||||
*/
|
||||
entry = &ret->guestfs_int_xattr_list_val[ret->guestfs_int_xattr_list_len-nr_attrs-1];
|
||||
for (m = 1; m <= nr_attrs; ++m) {
|
||||
for (m = 1; m < nr_attrs+1; ++m) {
|
||||
entry[m].attrname = NULL;
|
||||
entry[m].attrval.attrval_len = 0;
|
||||
entry[m].attrval.attrval_val = NULL;
|
||||
|
||||
@@ -524,7 +524,7 @@ add_drive_to_handle_at (guestfs_h *g, struct drive *d, size_t drv_index)
|
||||
if (drv_index >= g->nr_drives) {
|
||||
g->drives = safe_realloc (g, g->drives,
|
||||
sizeof (struct drive *) * (drv_index + 1));
|
||||
while (g->nr_drives <= drv_index) {
|
||||
while (g->nr_drives < drv_index+1) {
|
||||
g->drives[g->nr_drives] = NULL;
|
||||
g->nr_drives++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user