Message ID | 20200903112107.27367-9-alex.bennee@linaro.org |
---|---|
State | New |
Headers | show |
Series | some testing and CI updates (re-greening) | expand |
Il gio 3 set 2020, 13:21 Alex Bennée <alex.bennee@linaro.org> ha scritto: > The gcov build triggered: > > ../../migration/global_state.c:47:5: error: ‘strncpy’ specified > bound 100 equals destination size [-Werror=stringop-truncation] > strncpy((char *)global_state.runstate > > As we shouldn't be using strncpy anyway lets use the suggested > pstrcpy. > This is wrong, we want the all-zeros behavior of strncpy that pstrcpy lacks. Paolo > > Signed-off-by: Alex Bennée <alex.bennee@linaro.org> > --- > migration/global_state.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/migration/global_state.c b/migration/global_state.c > index 25311479a4b..5fbe6d1ff07 100644 > --- a/migration/global_state.c > +++ b/migration/global_state.c > @@ -44,8 +44,8 @@ void global_state_store_running(void) > { > const char *state = RunState_str(RUN_STATE_RUNNING); > assert(strlen(state) < sizeof(global_state.runstate)); > - strncpy((char *)global_state.runstate, > - state, sizeof(global_state.runstate)); > + pstrcpy((char *)global_state.runstate, sizeof(global_state.runstate), > + state); > } > > bool global_state_received(void) > -- > 2.20.1 > > <div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il gio 3 set 2020, 13:21 Alex Bennée <<a href="mailto:alex.bennee@linaro.org">alex.bennee@linaro.org</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The gcov build triggered:<br> <br> ../../migration/global_state.c:47:5: error: ‘strncpy’ specified<br> bound 100 equals destination size [-Werror=stringop-truncation]<br> strncpy((char *)global_state.runstate<br> <br> As we shouldn't be using strncpy anyway lets use the suggested<br> pstrcpy.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">This is wrong, we want the all-zeros behavior of strncpy that pstrcpy lacks.</div><div dir="auto"><br></div><div dir="auto">Paolo</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br><br> Signed-off-by: Alex Bennée <<a href="mailto:alex.bennee@linaro.org" target="_blank" rel="noreferrer">alex.bennee@linaro.org</a>><br> ---<br> migration/global_state.c | 4 ++--<br> 1 file changed, 2 insertions(+), 2 deletions(-)<br> <br> diff --git a/migration/global_state.c b/migration/global_state.c<br> index 25311479a4b..5fbe6d1ff07 100644<br> --- a/migration/global_state.c<br> +++ b/migration/global_state.c<br> @@ -44,8 +44,8 @@ void global_state_store_running(void)<br> {<br> const char *state = RunState_str(RUN_STATE_RUNNING);<br> assert(strlen(state) < sizeof(global_state.runstate));<br> - strncpy((char *)global_state.runstate,<br> - state, sizeof(global_state.runstate));<br> + pstrcpy((char *)global_state.runstate, sizeof(global_state.runstate),<br> + state);<br> }<br> <br> bool global_state_received(void)<br> -- <br> 2.20.1<br> <br> </blockquote></div></div></div>
On 9/3/20 2:13 PM, Paolo Bonzini wrote: > Il gio 3 set 2020, 13:21 Alex Bennée <alex.bennee@linaro.org > <mailto:alex.bennee@linaro.org>> ha scritto: > > The gcov build triggered: > > ../../migration/global_state.c:47:5: error: ‘strncpy’ specified > bound 100 equals destination size [-Werror=stringop-truncation] > strncpy((char *)global_state.runstate > > As we shouldn't be using strncpy anyway lets use the suggested > pstrcpy. > > > This is wrong, we want the all-zeros behavior of strncpy that pstrcpy lacks. FWIW links to previous discussions: https://www.mail-archive.com/qemu-devel@nongnu.org/msg584216.html > > Paolo
Philippe Mathieu-Daudé <philmd@redhat.com> writes: > On 9/3/20 2:13 PM, Paolo Bonzini wrote: >> Il gio 3 set 2020, 13:21 Alex Bennée <alex.bennee@linaro.org >> <mailto:alex.bennee@linaro.org>> ha scritto: >> >> The gcov build triggered: >> >> ../../migration/global_state.c:47:5: error: ‘strncpy’ specified >> bound 100 equals destination size [-Werror=stringop-truncation] >> strncpy((char *)global_state.runstate >> >> As we shouldn't be using strncpy anyway lets use the suggested >> pstrcpy. >> >> >> This is wrong, we want the all-zeros behavior of strncpy that pstrcpy lacks. > > FWIW links to previous discussions: > https://www.mail-archive.com/qemu-devel@nongnu.org/msg584216.html Hmm I wonder why gprof interfered with the assert. Either way I'll drop the patch. > >> >> Paolo -- Alex Bennée
diff --git a/migration/global_state.c b/migration/global_state.c index 25311479a4b..5fbe6d1ff07 100644 --- a/migration/global_state.c +++ b/migration/global_state.c @@ -44,8 +44,8 @@ void global_state_store_running(void) { const char *state = RunState_str(RUN_STATE_RUNNING); assert(strlen(state) < sizeof(global_state.runstate)); - strncpy((char *)global_state.runstate, - state, sizeof(global_state.runstate)); + pstrcpy((char *)global_state.runstate, sizeof(global_state.runstate), + state); } bool global_state_received(void)
The gcov build triggered: ../../migration/global_state.c:47:5: error: ‘strncpy’ specified bound 100 equals destination size [-Werror=stringop-truncation] strncpy((char *)global_state.runstate As we shouldn't be using strncpy anyway lets use the suggested pstrcpy. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> --- migration/global_state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.20.1