Remove the inner argv[] loop. It is not a change functionality. Signed-off-by: Holger Eitzenberger <holger@xxxxxxxxxxxxxxxx> Index: ipset/src/ipset.c =================================================================== --- ipset.orig/src/ipset.c 2011-01-19 21:14:59.000000000 +0100 +++ ipset/src/ipset.c 2011-01-19 21:17:55.000000000 +0100 @@ -425,7 +425,6 @@ { int ret = 0; enum ipset_cmd cmd = IPSET_CMD_NONE; - int i; char *arg0 = NULL, *arg1 = NULL, *c; const struct ipset_envopts *opt; const struct ipset_commands *command; @@ -476,61 +475,58 @@ /* Second: parse command */ for (command = ipset_commands; - command->cmd && cmd == IPSET_CMD_NONE; + argc > 1 && command->cmd && cmd == IPSET_CMD_NONE; command++) { - for (i = 1; i < argc; ) { - if (!ipset_match_cmd(argv[1], command->name)) { - i++; + if (!ipset_match_cmd(argv[1], command->name)) continue; - } - if (restore_line != 0 - && (command->cmd == IPSET_CMD_RESTORE - || command->cmd == IPSET_CMD_VERSION - || command->cmd == IPSET_CMD_HELP)) - return exit_error(PARAMETER_PROBLEM, + + if (restore_line != 0 + && (command->cmd == IPSET_CMD_RESTORE + || command->cmd == IPSET_CMD_VERSION + || command->cmd == IPSET_CMD_HELP)) + return exit_error(PARAMETER_PROBLEM, "Command `%s' is invalid " "in restore mode.", command->name[0]); - if (interactive - && command->cmd == IPSET_CMD_RESTORE) { - printf("Restore command ignored " - "in interactive mode\n"); - return 0; - } + if (interactive + && command->cmd == IPSET_CMD_RESTORE) { + printf("Restore command ignored " + "in interactive mode\n"); + return 0; + } - /* Shift off matched command arg */ - ipset_shift_argv(&argc, argv, i); - cmd = command->cmd; - switch (command->has_arg) { - case IPSET_MANDATORY_ARG: - case IPSET_MANDATORY_ARG2: - if (i + 1 > argc) + /* Shift off matched command arg */ + ipset_shift_argv(&argc, argv, 1); + cmd = command->cmd; + switch (command->has_arg) { + case IPSET_MANDATORY_ARG: + case IPSET_MANDATORY_ARG2: + if (argc < 2) return exit_error(PARAMETER_PROBLEM, - "Missing mandatory argument " - "to command %s", - command->name[0]); + "Missing mandatory argument " + "to command %s", + command->name[0]); /* Fall through */ - case IPSET_OPTIONAL_ARG: - arg0 = argv[i]; - if (i + 1 <= argc) - /* Shift off first arg */ - ipset_shift_argv(&argc, argv, i); - break; - default: - break; - } - if (command->has_arg == IPSET_MANDATORY_ARG2) { - if (i + 1 > argc) - return exit_error(PARAMETER_PROBLEM, - "Missing second mandatory " - "argument to command %s", - command->name[0]); - arg1 = argv[i]; - /* Shift off second arg */ - ipset_shift_argv(&argc, argv, i); - } + case IPSET_OPTIONAL_ARG: + arg0 = argv[1]; + if (argc >= 2) + /* Shift off first arg */ + ipset_shift_argv(&argc, argv, 1); + break; + default: break; } + if (command->has_arg == IPSET_MANDATORY_ARG2) { + if (argc < 2) + return exit_error(PARAMETER_PROBLEM, + "Missing second mandatory " + "argument to command %s", + command->name[0]); + arg1 = argv[1]; + /* Shift off second arg */ + ipset_shift_argv(&argc, argv, 1); + } + break; } /* Third: catch interactive mode, handle help, version */ -- -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html