]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
smatch: fix couple warnings
authorSami Kerola <kerolasa@iki.fi>
Sun, 1 Jan 2017 19:25:24 +0000 (19:25 +0000)
committerSami Kerola <kerolasa@iki.fi>
Fri, 6 Jan 2017 22:05:10 +0000 (22:05 +0000)
ui/mtr.c:616:21: warning: Using plain integer as NULL pointer
packet/cmdparse.c:80:18: warning: Variable length array is used.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
packet/cmdparse.c
packet/cmdparse.h
ui/mtr.c

index 6c1d16a7e60aa96309bee2c96ae451e01eb9159c..e01b03fd61e1d9d3186035ff4114ca6efde4d2ce 100644 (file)
@@ -76,15 +76,14 @@ int parse_command(
     struct command_t *command,
     char *command_string)
 {
-    const int max_tokens = MAX_COMMAND_ARGUMENTS * 2 + 2;
-    char *tokens[max_tokens];
+    char *tokens[MAX_COMMAND_TOKENS];
     int token_count;
     int i;
 
     memset(command, 0, sizeof(struct command_t));
 
     /*  Tokenize the string using whitespace  */
-    token_count = tokenize_command(tokens, max_tokens, command_string);
+    token_count = tokenize_command(tokens, MAX_COMMAND_TOKENS, command_string);
     if (token_count < 2) {
         errno = EINVAL;
         return -1;
index aae1fe306a9529393502f4d4e044be4dfc1d0a6c..9b9c3906e152378ce0472d21959796131314cb50 100644 (file)
 #ifndef CMDPARSE_H
 #define CMDPARSE_H
 
-#define MAX_COMMAND_ARGUMENTS 16
+enum {
+    MAX_COMMAND_ARGUMENTS = 16,
+    MAX_COMMAND_TOKENS = MAX_COMMAND_ARGUMENTS * 2 + 2
+};
 
 /*  Parsed commands, or command replies, ready for semantic interpretation  */
 struct command_t
index c635aec4e2b79b4f0c1fc3f667d87265ee8a1765..da1e32dc084f5b3173a0aaafce3384a64e650143 100644 (file)
--- a/ui/mtr.c
+++ b/ui/mtr.c
@@ -613,7 +613,7 @@ static void init_rand(void)
 {
   struct timeval tv;
 
-  gettimeofday(&tv, 0);
+  gettimeofday(&tv, NULL);
   srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
 }