Il gio 3 set 2020, 13:21 Alex Bennée <alex.ben...@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.ben...@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
>
>

Reply via email to