From: Dave Jones <davej@redhat.com>
To: Mikko Rapeli <mikko.rapeli@iki.fi>
Cc: trinity@vger.kernel.org
Subject: Re: [PATCH 1/6] trinity.c: fix uninitialized variable
Date: Fri, 5 Jul 2013 10:44:49 -0400 [thread overview]
Message-ID: <20130705144449.GA31027@redhat.com> (raw)
In-Reply-To: <1372967744-29353-2-git-send-email-mikko.rapeli@iki.fi>
On Thu, Jul 04, 2013 at 10:55:39PM +0300, Mikko Rapeli wrote:
> Coverity says:
>
> CID 1042350 (#1 of 1): Uninitialized scalar variable (UNINIT)
> 23. uninit_use_in_call: Using uninitialized value "ling": field "ling"."l_linger" is uninitialized when calling "setsockopt(int, int, int, void const *, socklen_t)".
>
> Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
> ---
> trinity.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/trinity.c b/trinity.c
> index 93e7819..3f80020 100644
> --- a/trinity.c
> +++ b/trinity.c
> @@ -250,6 +250,7 @@ cleanup_fds:
>
> for (i = 0; i < nr_sockets; i++) {
> struct linger ling;
> + memset(&ling, 0, sizeof(ling));
>
> ling.l_onoff = FALSE; /* linger active */
> setsockopt(shm->socket_fds[i], SOL_SOCKET, SO_LINGER, &ling, sizeof(struct linger));
Let's just do this as
struct linger ling = { .l_onoff = FALSE, };
That should have the same effect.
This should be a harmless bug anyway, because l_linger only matters when we're turning
linger on afaik.
Dave
next prev parent reply other threads:[~2013-07-05 14:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-04 19:55 [PATCH 0/6] Some simple Coverity fixes Mikko Rapeli
2013-07-04 19:55 ` [PATCH 1/6] trinity.c: fix uninitialized variable Mikko Rapeli
2013-07-05 14:44 ` Dave Jones [this message]
2013-07-05 16:15 ` [PATCHv2 1/2] " Mikko Rapeli
2013-07-05 16:15 ` [PATCHv2 2/2] trinity.c: log errors if socket calls fail Mikko Rapeli
2013-07-04 19:55 ` [PATCH 2/6] " Mikko Rapeli
2013-07-05 14:46 ` Dave Jones
2013-07-04 19:55 ` [PATCH 3/6] perf_event_open: initialize chars Mikko Rapeli
2013-07-04 19:55 ` [PATCH 4/6] perf_event_open.c: close dir's on exit paths Mikko Rapeli
2013-07-04 19:55 ` [PATCH 5/6] sockets.c: don't leak cachefile on return paths Mikko Rapeli
2013-07-04 19:55 ` [PATCH 6/6] maps.c: only close() if fd is valid Mikko Rapeli
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=20130705144449.GA31027@redhat.com \
--to=davej@redhat.com \
--cc=mikko.rapeli@iki.fi \
--cc=trinity@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.