]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
xdp-gun: improve popen return handling to mute Clang analyzer
authorDaniel Salzman <daniel.salzman@nic.cz>
Wed, 27 May 2020 11:49:14 +0000 (13:49 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Sun, 31 May 2020 07:17:13 +0000 (09:17 +0200)
src/utils/xdp-gun/main.c

index e8d239505412837c319d468ab46b293f38340942..0ddaec05ec5b536a29a7afedbe66f8f9f22f7f09 100644 (file)
@@ -343,9 +343,10 @@ static int ip_route_get(const char *ip, const char *what, char **res)
        char cmd[50 + strlen(ip) + strlen(what)];
        (void)snprintf(cmd, sizeof(cmd), "ip route get %s | grep -o ' %s [^ ]* '", ip, what);
 
+       errno = 0;
        FILE *p = popen(cmd, "r");
        if (p == NULL) {
-               return knot_map_errno();
+               return (errno != 0) ? knot_map_errno() : KNOT_ENOMEM;
        }
 
        char check[16] = { 0 }, got[256] = { 0 };