summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank K├╝hndel <frank.kuehndel@embedded-brains.de>2020-10-12 16:41:51 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-10-15 19:12:15 +0200
commit0a761a58c9097a0de04baf970f260594618090e8 (patch)
treed9b9c547b027e7a14f154ae135aaef3a3a52cab3
parent3972085dbab9b05e839b2612abf625c6097a180b (diff)
fsdosfsname01: Fix string truncation warning
This patch fixes a compiler warning: ../../../testsuites/fstests/fsdosfsname01/init.c:430:19: warning: '%s' directive output may be truncated writing up to 6424 bytes into a region of size 257 [-Wformat-truncation=] The buffer 'dirname' is exactly large enough so that no truncation can ever occur. Using the return value of snprintf() is an official supported way to suppress the warning. I considered the comment of Joel Sherrill about not replacing snprintf(): https://lists.rtems.org/pipermail/devel/2020-September/062113.html
-rw-r--r--testsuites/fstests/fsdosfsname01/init.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/testsuites/fstests/fsdosfsname01/init.c b/testsuites/fstests/fsdosfsname01/init.c
index 3689da8eed..a916e392f7 100644
--- a/testsuites/fstests/fsdosfsname01/init.c
+++ b/testsuites/fstests/fsdosfsname01/init.c
@@ -422,14 +422,15 @@ static void test_creating_invalid_directories( void )
unsigned int index;
int rc;
char dirname[MAX_NAME_LENGTH_INVALID + MOUNT_DIR_SIZE + 1];
-
+ int len;
for ( index = 0; index < NUMBER_OF_DIRECTORIES_INVALID; ++index ) {
- snprintf( dirname,
- sizeof( dirname ),
- "%s/%s",
- MOUNT_DIR,
- DIRECTORY_NAMES_INVALID[index] );
+ len = snprintf( dirname,
+ sizeof( dirname ),
+ "%s/%s",
+ MOUNT_DIR,
+ DIRECTORY_NAMES_INVALID[index] );
+ rtems_test_assert( len < sizeof( dirname ) );
rc = mkdir( dirname, S_IRWXU | S_IRWXG | S_IRWXO );
rtems_test_assert( rc == -1 );
}