Skip to contentSkip to conversation

selftests/powerpc: Fix compiling error on tlbie_test due to newer gcc

PATCH Applied Desnes A. Nunes do Rosario 2 participants 3 messages Oct 3, 2019 – Oct 11, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/powerpc: Fix compiling error on tlbie_test due to newer gcc

Newer versions of GCC demand that the size of the string to be copied must be explicitly smaller than the size of the destination. Thus, the NULL char has to be taken into account on strncpy.

This will avoid the following compiling error:

tlbie_test.c: In function 'main':
tlbie_test.c:639:4: error: 'strncpy' specified bound 100 equals destination size [-Werror=stringop-truncation]

      strncpy(logdir, optarg, LOGDIR_NAME_SIZE);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cc1: all warnings being treated as errors

---
 tools/testing/selftests/powerpc/mm/tlbie_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/powerpc/mm/tlbie_test.c +1 -1
index 9868a5ddd847..0d0aee462f8e 100644
@@ -636,7 +636,7 @@ int main(int argc, char *argv[])
 			nrthreads = strtoul(optarg, NULL, 10);
 			break;
 		case 'l':
-			strncpy(logdir, optarg, LOGDIR_NAME_SIZE);
+			strncpy(logdir, optarg, LOGDIR_NAME_SIZE-1);
 			break;
 		case 't':
 			run_time = strtoul(optarg, NULL, 10);
Signature · 1 line
2.21.0
#1 lore raw
Quoted 6 lines · Desnes A. Nunes do Rosario

Newer versions of GCC demand that the size of the string to be copied must be explicitly smaller than the size of the destination. Thus, the NULL char has to be taken into account on strncpy.

This will avoid the following compiling error:

Quoted 7 lines

tlbie_test.c: In function 'main':
tlbie_test.c:639:4: error: 'strncpy' specified bound 100 equals destination size [-Werror=stringop-truncation]

      strncpy(logdir, optarg, LOGDIR_NAME_SIZE);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cc1: all warnings being treated as errors

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/3439595d5b85f0af565f5a58e495d885537fb227

cheers

#2 lore raw
In reply to Desnes A. Nunes do Rosario
Quoted 6 lines · Desnes A. Nunes do Rosario

Newer versions of GCC demand that the size of the string to be copied must be explicitly smaller than the size of the destination. Thus, the NULL char has to be taken into account on strncpy.

This will avoid the following compiling error:

Quoted 7 lines

tlbie_test.c: In function 'main':
tlbie_test.c:639:4: error: 'strncpy' specified bound 100 equals destination size [-Werror=stringop-truncation]

      strncpy(logdir, optarg, LOGDIR_NAME_SIZE);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cc1: all warnings being treated as errors

Reapplied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/5b216ea1c40cf06eead15054c70e238c9bd4729e

cheers