From 0a761a58c9097a0de04baf970f260594618090e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20K=C3=BChndel?= Date: Mon, 12 Oct 2020 16:41:51 +0200 Subject: 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 --- testsuites/fstests/fsdosfsname01/init.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'testsuites/fstests') 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 ); } -- cgit v1.2.3