From: Zbigniew Jędrzejewski-Szmek Date: Mon, 21 Aug 2023 09:56:04 +0000 (+0200) Subject: mount-tool: reduce scope of iterator variables X-Git-Tag: v255-rc1~646^2~3 X-Git-Url: http://git-history.diyao.me/?a=commitdiff_plain;h=857127f1e303c02b5ab4d5aed53ce0310b67f144;p=systemd%2F.git mount-tool: reduce scope of iterator variables --- diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c index a0f1503f70..780179b3ed 100644 --- a/src/mount/mount-tool.c +++ b/src/mount/mount-tool.c @@ -391,15 +391,12 @@ static int parse_argv(int argc, char *argv[]) { return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "At least one argument required."); - if (arg_transport != BUS_TRANSPORT_LOCAL) { - int i; - - for (i = optind; i < argc; i++) - if (!path_is_absolute(argv[i]) ) + if (arg_transport != BUS_TRANSPORT_LOCAL) + for (int i = optind; i < argc; i++) + if (!path_is_absolute(argv[i])) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Path must be absolute when operating remotely: %s", argv[i]); - } } else { if (optind >= argc) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), @@ -1028,10 +1025,10 @@ static int action_umount( int argc, char **argv) { - int i, r, r2 = 0; + int r, r2 = 0; if (arg_transport != BUS_TRANSPORT_LOCAL) { - for (i = optind; i < argc; i++) { + for (int i = optind; i < argc; i++) { _cleanup_free_ char *p = NULL; p = strdup(argv[i]); @@ -1047,7 +1044,7 @@ static int action_umount( return r2; } - for (i = optind; i < argc; i++) { + for (int i = optind; i < argc; i++) { _cleanup_free_ char *u = NULL, *p = NULL; struct stat st; @@ -1411,7 +1408,6 @@ enum { static int list_devices(void) { _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL; _cleanup_(table_unrefp) Table *table = NULL; - unsigned c; int r; r = sd_device_enumerator_new(&e); @@ -1440,7 +1436,7 @@ static int list_devices(void) { table_set_header(table, arg_legend); FOREACH_DEVICE(e, d) { - for (c = 0; c < _COLUMN_MAX; c++) { + for (unsigned c = 0; c < _COLUMN_MAX; c++) { const char *x = NULL; switch (c) {