conf, tap: Silence two false positive invalidFunctionArg from cppcheck

The newly introduced die() calls exit(), but cppcheck doesn't see it
and warns about possibly invalid arguments used after the check which
triggers die(). Add return statements to silence the warnings.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Stefano Brivio 2023-02-16 19:19:23 +01:00
parent 89e0fbfaa7
commit 36f0199f6e
2 changed files with 8 additions and 1 deletions

3
conf.c
View file

@ -1036,6 +1036,9 @@ static void conf_ugid(char *runas, uid_t *uid, gid_t *gid)
if ((fd = open("/proc/self/uid_map", O_RDONLY | O_CLOEXEC)) < 0) {
die("Can't determine if we're in init namespace: %s",
strerror(errno));
/* Silence cppcheck's invalidFunctionArg for 'fd' in read() */
return;
}
if (read(fd, buf, BUFSIZ) != sizeof(root_uid_map) ||

6
tap.c
View file

@ -1037,9 +1037,13 @@ static void tap_sock_unix_init(struct ctx *c)
snprintf(path, UNIX_PATH_MAX - 1, UNIX_SOCK_PATH, i);
ex = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0);
if (ex < 0)
if (ex < 0) {
die("UNIX domain socket check: %s", strerror(errno));
/* Silence cppcheck's invalidFunctionArg for 'ex' */
return;
}
ret = connect(ex, (const struct sockaddr *)&addr, sizeof(addr));
if (!ret || (errno != ENOENT && errno != ECONNREFUSED &&
errno != EACCES)) {