log: avoid call close with negative value
PATCH 1/1 log: avoid call close with negative value
On error path, the journal socket code would call close with -1 which caused Coverity warning.
Coverity issue: 448872
Fixes 9da0dc6c0331 ("log: support systemd journal")
Signed-off-by Stephen Hemminger <[email protected]>
--- lib/log/log_journal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/log/log_journal.c +2 -2
@@ -116,7 +116,7 @@ log_journal_open(const char *id) .sun_family = AF_UNIX, .sun_path = "/run/systemd/journal/socket", }; -int jfd =-1 ; +int jfd; len =snprintf (syslog_id,sizeof (syslog_id),"SYSLOG_IDENTIFIER=%s\nSYSLOG_PID=%u" , id,getpid ());
@@ -128,7 +128,7 @@ log_journal_open(const char *id) jfd =socket (AF_UNIX ,SOCK_DGRAM ,0 );if (jfd <0 ) {perror ("socket" ); - goto error; +return NULL ; }if (connect (jfd, (struct sockaddr *)&sun,sizeof (sun)) <0 ) {
Signature · 1 line
2.47.2
David Marchand
AppliedQuoted 8 lines · Stephen Hemminger
On error path, the journal socket code would call close with -1 which caused Coverity warning.
Coverity issue: 448872
Fixes 9da0dc6c0331 ("log: support systemd journal")Signed-off-by Stephen Hemminger <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand