mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 09:15:34 +00:00
lib, ldpd: fix "argument cannot be negative" coverity warnings
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
76ae8092db
commit
993bab898d
@ -450,10 +450,15 @@ start_child(enum ldpd_process p, char *argv0, int fd_async, int fd_sync)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nullfd = open("/dev/null", O_RDONLY | O_NOCTTY);
|
nullfd = open("/dev/null", O_RDONLY | O_NOCTTY);
|
||||||
|
if (nullfd == -1) {
|
||||||
|
zlog_err("%s: failed to open /dev/null: %s", __func__,
|
||||||
|
safe_strerror(errno));
|
||||||
|
} else {
|
||||||
dup2(nullfd, 0);
|
dup2(nullfd, 0);
|
||||||
dup2(nullfd, 1);
|
dup2(nullfd, 1);
|
||||||
dup2(nullfd, 2);
|
dup2(nullfd, 2);
|
||||||
close(nullfd);
|
close(nullfd);
|
||||||
|
}
|
||||||
|
|
||||||
if (dup2(fd_async, LDPD_FD_ASYNC) == -1)
|
if (dup2(fd_async, LDPD_FD_ASYNC) == -1)
|
||||||
fatal("cannot setup imsg async fd");
|
fatal("cannot setup imsg async fd");
|
||||||
|
14
lib/libfrr.c
14
lib/libfrr.c
@ -768,6 +768,8 @@ void frr_vty_serv(void)
|
|||||||
|
|
||||||
static void frr_terminal_close(int isexit)
|
static void frr_terminal_close(int isexit)
|
||||||
{
|
{
|
||||||
|
int nullfd;
|
||||||
|
|
||||||
if (daemon_ctl_sock != -1) {
|
if (daemon_ctl_sock != -1) {
|
||||||
close(daemon_ctl_sock);
|
close(daemon_ctl_sock);
|
||||||
daemon_ctl_sock = -1;
|
daemon_ctl_sock = -1;
|
||||||
@ -783,11 +785,16 @@ static void frr_terminal_close(int isexit)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nullfd = open("/dev/null", O_RDONLY | O_NOCTTY);
|
nullfd = open("/dev/null", O_RDONLY | O_NOCTTY);
|
||||||
|
if (nullfd == -1) {
|
||||||
|
zlog_err("%s: failed to open /dev/null: %s", __func__,
|
||||||
|
safe_strerror(errno));
|
||||||
|
} else {
|
||||||
dup2(nullfd, 0);
|
dup2(nullfd, 0);
|
||||||
dup2(nullfd, 1);
|
dup2(nullfd, 1);
|
||||||
dup2(nullfd, 2);
|
dup2(nullfd, 2);
|
||||||
close(nullfd);
|
close(nullfd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct thread *daemon_ctl_thread = NULL;
|
static struct thread *daemon_ctl_thread = NULL;
|
||||||
@ -849,10 +856,15 @@ void frr_run(struct thread_master *master)
|
|||||||
}
|
}
|
||||||
} else if (di->daemon_mode) {
|
} else if (di->daemon_mode) {
|
||||||
int nullfd = open("/dev/null", O_RDONLY | O_NOCTTY);
|
int nullfd = open("/dev/null", O_RDONLY | O_NOCTTY);
|
||||||
|
if (nullfd == -1) {
|
||||||
|
zlog_err("%s: failed to open /dev/null: %s", __func__,
|
||||||
|
safe_strerror(errno));
|
||||||
|
} else {
|
||||||
dup2(nullfd, 0);
|
dup2(nullfd, 0);
|
||||||
dup2(nullfd, 1);
|
dup2(nullfd, 1);
|
||||||
dup2(nullfd, 2);
|
dup2(nullfd, 2);
|
||||||
close(nullfd);
|
close(nullfd);
|
||||||
|
}
|
||||||
|
|
||||||
if (daemon_ctl_sock != -1)
|
if (daemon_ctl_sock != -1)
|
||||||
close(daemon_ctl_sock);
|
close(daemon_ctl_sock);
|
||||||
|
Loading…
Reference in New Issue
Block a user