powerpc/powernv/idle: Fix build error
PATCH 1/1 powerpc/powernv/idle: Fix build error
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);
--- arch/powerpc/platforms/powernv/idle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/powernv/idle.c +1 -1
@@ -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 ;
Signature · 1 line
2.17.1
Michael Ellerman
reviewerQuoted 9 lines · Aneesh Kumar K.V
Fix the below build error using strlcpy instead of strncpy
In function '
pnv_parse_cpuidle_dt',
inlined from 'pnv_init_idle_states' atarch/powerpc/platforms/powernv/idle.c:840:7,
inlined from '__machine_initcall_powernv_pnv_init_idle_states' atarch/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?
cheers
Quoted 15 lines
arch/powerpc/platforms/powernv/idle.c +1
-1@@ -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 ;Signature · 1 line
2.17.1
Quoted 12 lines · Michael Ellerman
Quoted 9 lines · Aneesh Kumar K.V
Fix the below build error using strlcpy instead of strncpy
In function '
pnv_parse_cpuidle_dt',
inlined from 'pnv_init_idle_states' atarch/powerpc/platforms/powernv/idle.c:840:7,
inlined from '__machine_initcall_powernv_pnv_init_idle_states' atarch/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);
Quoted 1 line
I'm curious why I haven't seen this? What compiler are you using?
gcc 8 does this.
Quoted 18 lines
cheers
Quoted 15 lines
arch/powerpc/platforms/powernv/idle.c +1
-1@@ -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 ;Signature · 1 line
2.17.1
Signature · 1 line
Alexey
Michael Ellerman
reviewerQuoted 13 lines · Alexey Kardashevskiy
Quoted 12 lines · Michael Ellerman
Quoted 9 lines · Aneesh Kumar K.V
Fix the below build error using strlcpy instead of strncpy
In function '
pnv_parse_cpuidle_dt',
inlined from 'pnv_init_idle_states' atarch/powerpc/platforms/powernv/idle.c:840:7,
inlined from '__machine_initcall_powernv_pnv_init_idle_states' atarch/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);
Quoted 3 lines
Quoted 1 line
I'm curious why I haven't seen this? What compiler are you using?
gcc 8 does this.
Yeah you're right. It was hidden by another build failure in my build scripts :/
cheers
Michael Ellerman
AppliedQuoted 11 lines · Aneesh Kumar K.V
Fix the below build error using strlcpy instead of strncpy
In function '
pnv_parse_cpuidle_dt',
inlined from 'pnv_init_idle_states' atarch/powerpc/platforms/powernv/idle.c:840:7,
inlined from '__machine_initcall_powernv_pnv_init_idle_states' atarch/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);Signed-off-by Aneesh Kumar K.V <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/ae24ce5e12127eeef6bf946c3ee0e9
cheers