summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-21 20:52:18 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-21 21:12:42 +0200
commit7d895205eff0f29e14aad5733e4df62050dae8f1 (patch)
treee8d957ea24ae8b48a796f3db44facf87548d465a
parentce2f43797a1fdb4798f40c1689aa33dd0df448f4 (diff)
downloadsystemd-7d895205eff0f29e14aad5733e4df62050dae8f1.tar.gz
tty-ask-password: fix dead code path
Coverity was complaining that watch==1 always at this point. CID #1405882. Use structured initialization while at it.
-rw-r--r--src/tty-ask-password-agent/tty-ask-password-agent.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c
index 2e57a628b2..068988e203 100644
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
@@ -337,7 +337,7 @@ static int process_and_watch_password_files(bool watch) {
};
_cleanup_close_ int notify = -1, signal_fd = -1, tty_block_fd = -1;
- struct pollfd pollfd[_FD_MAX] = {};
+ struct pollfd pollfd[_FD_MAX];
sigset_t mask;
int r;
@@ -354,8 +354,7 @@ static int process_and_watch_password_files(bool watch) {
if (signal_fd < 0)
return log_error_errno(errno, "Failed to allocate signal file descriptor: %m");
- pollfd[FD_SIGNAL].fd = signal_fd;
- pollfd[FD_SIGNAL].events = POLLIN;
+ pollfd[FD_SIGNAL] = (struct pollfd) { .fd = signal_fd, .events = POLLIN };
notify = inotify_init1(IN_CLOEXEC);
if (notify < 0)
@@ -365,8 +364,7 @@ static int process_and_watch_password_files(bool watch) {
if (r < 0)
return r;
- pollfd[FD_INOTIFY].fd = notify;
- pollfd[FD_INOTIFY].events = POLLIN;
+ pollfd[FD_INOTIFY] = (struct pollfd) { .fd = notify, .events = POLLIN };
}
for (;;) {
@@ -389,7 +387,7 @@ static int process_and_watch_password_files(bool watch) {
if (!watch)
break;
- if (poll(pollfd, watch ? _FD_MAX : _FD_MAX-1, timeout) < 0) {
+ if (poll(pollfd, _FD_MAX, timeout) < 0) {
if (errno == EINTR)
continue;