]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Initialize num_commands to 0, the actual initial number of commands.
authorJames Jones <jejones3141@gmail.com>
Tue, 30 May 2023 18:48:48 +0000 (13:48 -0500)
committerAlan DeKok <aland@freeradius.org>
Tue, 30 May 2023 19:08:44 +0000 (15:08 -0400)
Doing this should keep coverity from getting confused and requiring
annotations.

src/listen/control/radmin.c

index f952eb659911542796dda91323c6e53495e5ee7f..f5aa08a6b5d642c8cb5e80983f31e851e0cf8b26 100644 (file)
@@ -845,7 +845,7 @@ int main(int argc, char **argv)
        TALLOC_CTX              *autofree;
 
        char *commands[MAX_COMMANDS];
-       int num_commands = -1;
+       int num_commands = 0;
 
        int exit_status = EXIT_SUCCESS;
 
@@ -891,13 +891,12 @@ int main(int argc, char **argv)
                        break;
 
                case 'e':
-                       num_commands++; /* starts at -1 */
                        if (num_commands >= MAX_COMMANDS) {
                                fprintf(stderr, "%s: Too many '-e'\n", progname);
                                fr_exit_now(EXIT_FAILURE);
                        }
 
-                       commands[num_commands] = optarg;
+                       commands[num_commands++] = optarg;
                        break;
 
                case 'E':
@@ -1116,11 +1115,10 @@ int main(int argc, char **argv)
        /*
         *      Run commands from the command-line.
         */
-       /* coverity[check_after_sink] */
-       if (num_commands >= 0) {
+       if (num_commands > 0) {
                int i;
 
-               for (i = 0; i <= num_commands; i++) {
+               for (i = 0; i < num_commands; i++) {
                        result = run_command(sockfd, commands[i], io_buffer, sizeof(io_buffer));
                        if (result < 0) fr_exit_now(EXIT_FAILURE);