From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: Michael Ellerman <mpe@ellerman.id.au>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
npiggin@gmail.com, benh@kernel.crashing.org, paulus@samba.org
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc/powernv/idle: Fix build error
Date: Mon, 13 Aug 2018 16:26:50 +1000 [thread overview]
Message-ID: <48a5eb4c-66db-ba47-dd71-4bb898a958ee@ozlabs.ru> (raw)
In-Reply-To: <87k1oy8znu.fsf@concordia.ellerman.id.au>
On 10/08/2018 17:10, Michael Ellerman wrote:
> "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> writes:
>
>> Fix the below build error using strlcpy instead of strncpy
>>
>> In function 'pnv_parse_cpuidle_dt',
>> inlined from 'pnv_init_idle_states' at arch/powerpc/platforms/powernv/idle.c:840:7,
>> inlined from '__machine_initcall_powernv_pnv_init_idle_states' at arch/powerpc/platforms/powernv/idle.c:870:1:
>> arch/powerpc/platforms/powernv/idle.c:820:3: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation]
>> strncpy(pnv_idle_states[i].name, temp_string[i],
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> PNV_IDLE_NAME_LEN);
>
> I'm curious why I haven't seen this? What compiler are you using?
gcc 8 does this.
>
> cheers
>
>> diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c
>> index ecb002c5db83..35f699ebb662 100644
>> --- a/arch/powerpc/platforms/powernv/idle.c
>> +++ b/arch/powerpc/platforms/powernv/idle.c
>> @@ -817,7 +817,7 @@ static int pnv_parse_cpuidle_dt(void)
>> goto out;
>> }
>> for (i = 0; i < nr_idle_states; i++)
>> - strncpy(pnv_idle_states[i].name, temp_string[i],
>> + strlcpy(pnv_idle_states[i].name, temp_string[i],
>> PNV_IDLE_NAME_LEN);
>> nr_pnv_idle_states = nr_idle_states;
>> rc = 0;
>> --
>> 2.17.1
--
Alexey
next prev parent reply other threads:[~2018-08-13 6:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-09 13:37 [PATCH] powerpc/powernv/idle: Fix build error Aneesh Kumar K.V
2018-08-10 7:10 ` Michael Ellerman
2018-08-13 6:26 ` Alexey Kardashevskiy [this message]
2018-08-14 4:09 ` Michael Ellerman
2018-08-13 11:23 ` Michael Ellerman
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=48a5eb4c-66db-ba47-dd71-4bb898a958ee@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=aneesh.kumar@linux.ibm.com \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=paulus@samba.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 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).