]> git.proxmox.com Git - mirror_frr.git/commitdiff
watchfrr: fix SA warning
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Tue, 26 Jan 2021 16:58:34 +0000 (13:58 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Tue, 26 Jan 2021 17:13:07 +0000 (14:13 -0300)
`valid_command` now causes static analyzer complaints since it no
longer assumes `optarg` is non-NULL. If this was the case then
`valid_command` would return `false` (or 0) because it would mean the
string is empty and doesn't contain the '%s' it expects.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
watchfrr/watchfrr.c

index 12682fa35e48db3d0a7f3a89c431f153c64fd218..441320b1931abc90af1a8e93257c6debda02615b 100644 (file)
@@ -1080,6 +1080,9 @@ static int valid_command(const char *cmd)
 {
        char *p;
 
+       if (cmd == NULL)
+               return 0;
+
        return ((p = strchr(cmd, '%')) != NULL) && (*(p + 1) == 's')
               && !strchr(p + 1, '%');
 }