DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH] log: avoid call close with negative value
Date: Wed,  5 Feb 2025 08:15:18 -0800	[thread overview]
Message-ID: <20250205161518.143865-1-stephen@networkplumber.org> (raw)

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 <stephen@networkplumber.org>
---
 lib/log/log_journal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/log/log_journal.c b/lib/log/log_journal.c
index e9b3aa5640..43099649ed 100644
--- a/lib/log/log_journal.c
+++ b/lib/log/log_journal.c
@@ -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) {
-- 
2.47.2


             reply	other threads:[~2025-02-05 16:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 16:15 Stephen Hemminger [this message]
2025-02-07 14:40 ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250205161518.143865-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).