From: Peter Maydell <peter.maydell@linaro.org>
To: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH 06/12] mc146818rtc: rtc_set_time(): initialize tm to zeroes
Date: Tue, 26 Sep 2023 11:56:04 +0100 [thread overview]
Message-ID: <CAFEAcA-mFrbAea0KkZjT61xSEhU9P0TN=ujhNr3YPzWBA7Fayg@mail.gmail.com> (raw)
In-Reply-To: <20230925194040.68592-7-vsementsov@yandex-team.ru>
On Mon, 25 Sept 2023 at 20:42, Vladimir Sementsov-Ogievskiy
<vsementsov@yandex-team.ru> wrote:
>
> set_time() function doesn't set all the fields, so it's better to
> initialize tm structure. And Coverity will be happier about it.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
> hw/rtc/mc146818rtc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
> index c27c362db9..b63e1aeaea 100644
> --- a/hw/rtc/mc146818rtc.c
> +++ b/hw/rtc/mc146818rtc.c
> @@ -599,7 +599,7 @@ static void rtc_get_time(MC146818RtcState *s, struct tm *tm)
>
> static void rtc_set_time(MC146818RtcState *s)
> {
> - struct tm tm;
> + struct tm tm = {0};
> g_autofree const char *qom_path = object_get_canonical_path(OBJECT(s));
>
> rtc_get_time(s, &tm);
This is probably a false positive, but initializing the struct is
easier to reason about for humans too.
Our "zero initialize a struct" syntax is "= {}" without the 0, though.
(The version with the 0 is the standards-blessed one, but in practice
some compiler versions have not been happy with it in all situations
and produce spurious warnings.)
thanks
-- PMM
next prev parent reply other threads:[~2023-09-26 10:56 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-25 19:40 [PATCH 00/12] coverity fixes Vladimir Sementsov-Ogievskiy
2023-09-25 19:40 ` [PATCH 01/12] hw/core/loader: load_at(): check size Vladimir Sementsov-Ogievskiy
2023-09-26 10:33 ` Peter Maydell
2023-09-26 10:51 ` Vladimir Sementsov-Ogievskiy
2023-09-26 10:54 ` Peter Maydell
2023-09-26 11:42 ` Vladimir Sementsov-Ogievskiy
2023-09-25 19:40 ` [PATCH 02/12] hw/i386/intel_iommu: vtd_slpte_nonzero_rsvd(): reduce magic numbers Vladimir Sementsov-Ogievskiy
2023-09-26 10:37 ` Peter Maydell
2023-09-26 14:12 ` Vladimir Sementsov-Ogievskiy
2023-09-26 14:16 ` Peter Maydell
2023-09-26 18:36 ` Vladimir Sementsov-Ogievskiy
2023-09-26 18:46 ` Vladimir Sementsov-Ogievskiy
2023-09-26 18:59 ` Peter Maydell
2023-09-26 19:16 ` Vladimir Sementsov-Ogievskiy
2023-09-25 19:40 ` [PATCH 03/12] util/filemonitor-inotify: qemu_file_monitor_watch(): avoid overflow Vladimir Sementsov-Ogievskiy
2023-09-26 10:44 ` Peter Maydell
2023-09-25 19:40 ` [PATCH 04/12] libvhost-user.c: add assertion to vu_message_read_default Vladimir Sementsov-Ogievskiy
2023-09-25 19:40 ` [PATCH 05/12] device_tree: qmp_dumpdtb(): stronger assertion Vladimir Sementsov-Ogievskiy
2023-09-26 1:26 ` Alistair Francis
2023-09-26 10:08 ` Vladimir Sementsov-Ogievskiy
2023-09-26 10:51 ` Peter Maydell
2023-09-26 14:20 ` Vladimir Sementsov-Ogievskiy
2023-09-26 14:33 ` Peter Maydell
2023-09-25 19:40 ` [PATCH 06/12] mc146818rtc: rtc_set_time(): initialize tm to zeroes Vladimir Sementsov-Ogievskiy
2023-09-26 10:56 ` Peter Maydell [this message]
2023-09-25 19:40 ` [PATCH 07/12] pcie_sriov: unregister_vfs(): fix error path Vladimir Sementsov-Ogievskiy
2023-09-25 19:40 ` [PATCH 08/12] block/nvme: nvme_process_completion() fix bound for cid Vladimir Sementsov-Ogievskiy
2023-09-25 20:04 ` Michael Tokarev
2023-09-26 11:00 ` Peter Maydell
2023-09-25 19:40 ` [PATCH 09/12] kvm-all: introduce limits for name_size and num_desc Vladimir Sementsov-Ogievskiy
2023-09-26 11:05 ` Peter Maydell
2023-09-26 14:49 ` Vladimir Sementsov-Ogievskiy
2023-09-25 19:40 ` [PATCH 10/12] hw/core/loader: gunzip(): initialize z_stream Vladimir Sementsov-Ogievskiy
2023-09-26 11:06 ` Peter Maydell
2023-09-25 19:40 ` [PATCH 11/12] hw/core/loader: read_targphys(): add upper bound Vladimir Sementsov-Ogievskiy
2023-09-25 20:12 ` Michael Tokarev
2023-09-26 10:14 ` Vladimir Sementsov-Ogievskiy
2023-09-26 11:11 ` Peter Maydell
2023-09-25 19:40 ` [PATCH 12/12] io/channel-socket: qio_channel_socket_flush(): improve msg validation Vladimir Sementsov-Ogievskiy
2023-09-26 9:04 ` Maksim Davydov
2023-09-26 10:19 ` Vladimir Sementsov-Ogievskiy
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='CAFEAcA-mFrbAea0KkZjT61xSEhU9P0TN=ujhNr3YPzWBA7Fayg@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@yandex-team.ru \
/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).