All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	David Hildenbrand <david@redhat.com>,
	Howard Spoelstra <hsp.cat7@gmail.com>,
	qemu-devel@nongnu.org, qemu-trivial@nongnu.org
Subject: Re: [Qemu-trivial] [PATCH] migration: Replace strncpy() by g_strlcpy()
Date: Mon, 20 Aug 2018 11:57:01 +0200	[thread overview]
Message-ID: <87lg91e4ya.fsf@trasno.org> (raw)
In-Reply-To: <20180818025653.21192-1-f4bug@amsat.org> ("Philippe Mathieu-Daudé"'s message of "Fri, 17 Aug 2018 23:56:53 -0300")

Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> Fedora 29 comes with GCC 8.1 which added the 'stringop-truncation' checks.
>
> Replace the strncpy() calls by g_strlcpy() to avoid the following warning:
>
>   migration/global_state.c: In function 'global_state_store_running':
>   migration/global_state.c:45:5: error: 'strncpy' specified bound 100 equals destination size [-Werror=stringop-truncation]
>        strncpy((char *)global_state.runstate,
>        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>               state, sizeof(global_state.runstate));
>               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Juan Quintela <quintela@redhat.com>

will be in next pull, thanks.

> ---
> See http://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg03723.html
>
>  migration/global_state.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/migration/global_state.c b/migration/global_state.c
> index 8e8ab5c51e..d5df502cd5 100644
> --- a/migration/global_state.c
> +++ b/migration/global_state.c
> @@ -42,7 +42,7 @@ int global_state_store(void)
>  void global_state_store_running(void)
>  {
>      const char *state = RunState_str(RUN_STATE_RUNNING);
> -    strncpy((char *)global_state.runstate,
> +    g_strlcpy((char *)global_state.runstate,
>             state, sizeof(global_state.runstate));
>  }


WARNING: multiple messages have this Message-ID (diff)
From: Juan Quintela <quintela@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	David Hildenbrand <david@redhat.com>,
	Howard Spoelstra <hsp.cat7@gmail.com>,
	qemu-devel@nongnu.org, qemu-trivial@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] migration: Replace strncpy() by g_strlcpy()
Date: Mon, 20 Aug 2018 11:57:01 +0200	[thread overview]
Message-ID: <87lg91e4ya.fsf@trasno.org> (raw)
In-Reply-To: <20180818025653.21192-1-f4bug@amsat.org> ("Philippe Mathieu-Daudé"'s message of "Fri, 17 Aug 2018 23:56:53 -0300")

Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> Fedora 29 comes with GCC 8.1 which added the 'stringop-truncation' checks.
>
> Replace the strncpy() calls by g_strlcpy() to avoid the following warning:
>
>   migration/global_state.c: In function 'global_state_store_running':
>   migration/global_state.c:45:5: error: 'strncpy' specified bound 100 equals destination size [-Werror=stringop-truncation]
>        strncpy((char *)global_state.runstate,
>        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>               state, sizeof(global_state.runstate));
>               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Juan Quintela <quintela@redhat.com>

will be in next pull, thanks.

> ---
> See http://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg03723.html
>
>  migration/global_state.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/migration/global_state.c b/migration/global_state.c
> index 8e8ab5c51e..d5df502cd5 100644
> --- a/migration/global_state.c
> +++ b/migration/global_state.c
> @@ -42,7 +42,7 @@ int global_state_store(void)
>  void global_state_store_running(void)
>  {
>      const char *state = RunState_str(RUN_STATE_RUNNING);
> -    strncpy((char *)global_state.runstate,
> +    g_strlcpy((char *)global_state.runstate,
>             state, sizeof(global_state.runstate));
>  }

  reply	other threads:[~2018-08-20 10:04 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-18  2:56 [Qemu-trivial] [PATCH] migration: Replace strncpy() by g_strlcpy() Philippe Mathieu-Daudé
2018-08-18  2:56 ` [Qemu-devel] " Philippe Mathieu-Daudé
2018-08-20  9:57 ` Juan Quintela [this message]
2018-08-20  9:57   ` Juan Quintela
2018-08-20 12:42 ` [Qemu-trivial] " David Hildenbrand
2018-08-20 12:42   ` [Qemu-devel] " David Hildenbrand
2018-08-20 13:23 ` [Qemu-trivial] " Paolo Bonzini
2018-08-20 13:23   ` Paolo Bonzini
2018-08-20 13:28   ` [Qemu-trivial] " David Hildenbrand
2018-08-20 13:28     ` David Hildenbrand
2018-08-20 17:16     ` [Qemu-trivial] " Thomas Huth
2018-08-20 17:16       ` Thomas Huth
2018-08-20 19:48       ` [Qemu-trivial] " Eric Blake
2018-08-20 19:48         ` Eric Blake
2018-08-20 19:59         ` [Qemu-trivial] " David Hildenbrand
2018-08-20 19:59           ` David Hildenbrand
2018-08-21  6:03           ` [Qemu-trivial] " Thomas Huth
2018-08-21  6:03             ` Thomas Huth
2018-08-21  9:39             ` [Qemu-trivial] " Paolo Bonzini
2018-08-21  9:39               ` Paolo Bonzini
2018-08-21 11:52               ` [Qemu-trivial] " Juan Quintela
2018-08-21 11:52                 ` [Qemu-devel] " Juan Quintela

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=87lg91e4ya.fsf@trasno.org \
    --to=quintela@redhat.com \
    --cc=david@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=hsp.cat7@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.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.