[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] migration: fix stringop-truncation warning
From: |
Richard Henderson |
Subject: |
Re: [PATCH] migration: fix stringop-truncation warning |
Date: |
Wed, 11 Dec 2019 16:55:37 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 |
On 12/11/19 6:23 AM, Paolo Bonzini wrote:
> @@ -44,8 +44,7 @@ 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));
> + memcpy(global_state.runstate, state, strlen(state) + 1);
We should assign the strlen result to a local variable rather than compute it
twice.
r~