diff --git a/daemon/debug.c b/daemon/debug.c index a210db1b4..abc769911 100644 --- a/daemon/debug.c +++ b/daemon/debug.c @@ -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); } diff --git a/daemon/lvm.c b/daemon/lvm.c index 421c1c57e..d98998685 100644 --- a/daemon/lvm.c +++ b/daemon/lvm.c @@ -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); diff --git a/daemon/md.c b/daemon/md.c index cf826c526..8bb4b5473 100644 --- a/daemon/md.c +++ b/daemon/md.c @@ -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); } diff --git a/daemon/xattr.c b/daemon/xattr.c index c05124d92..b59940827 100644 --- a/daemon/xattr.c +++ b/daemon/xattr.c @@ -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; diff --git a/src/drives.c b/src/drives.c index b9cc81328..dc884954e 100644 --- a/src/drives.c +++ b/src/drives.c @@ -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++; }