fuse_service: Avoid modifying counters in for loop CodeQL annotates that and I personally prefer while loops for such loops as well. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
diff --git a/util/fuservicemount.c b/util/fuservicemount.c index a17ae0b..d270e05 100644 --- a/util/fuservicemount.c +++ b/util/fuservicemount.c
@@ -39,20 +39,22 @@ * This doesn't tell us if the listening socket is actually connected * to anything. */ - for (i = 1; i < argc; i++) { + i = 1; + while (i < argc) { if (!strcmp(argv[i], "--check")) { if (check) { check = false; break; } check = true; + i++; } else if (!strcmp(argv[i], "-t") && i + 1 < argc) { if (fstype) { check = false; break; } fstype = argv[i + 1]; - i++; + i += 2; } else { check = false; break;
diff --git a/util/mount_service.c b/util/mount_service.c index b2a2085..c929f73 100644 --- a/util/mount_service.c +++ b/util/mount_service.c
@@ -493,10 +493,11 @@ if (ret) return ret; - for (i = 1; i < argc; i++) { + i = 1; + while (i < argc) { /* skip the -t(ype) argument */ if (!strcmp(argv[i], "-t") && i + 1 < argc) { - i++; + i += 2; continue; } @@ -504,6 +505,7 @@ &array_pos, &string_pos); if (ret) return ret; + i++; } /* Now write the header */