This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new f3828cc  fstest: Force the minimum filename to 4 to avoid collisions
f3828cc is described below

commit f3828ccbca3e45319d804cd5c3f91a4764de68c8
Author: Alan Carvalho de Assis <[email protected]>
AuthorDate: Thu Mar 25 14:52:37 2021 -0300

    fstest: Force the minimum filename to 4 to avoid collisions
---
 testing/fstest/fstest_main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/testing/fstest/fstest_main.c b/testing/fstest/fstest_main.c
index b171936..413aaa7 100644
--- a/testing/fstest/fstest_main.c
+++ b/testing/fstest/fstest_main.c
@@ -39,6 +39,7 @@
 #include <errno.h>
 #include <crc32.h>
 #include <debug.h>
+#include <assert.h>
 
 /****************************************************************************
  * Pre-processor Definitions
@@ -200,8 +201,11 @@ static inline void fstest_randname(FAR struct 
fstest_filedesc_s *file)
   int i;
 
   dirlen   = strlen(g_mountdir);
-  maxname  = CONFIG_TESTING_FSTEST_MAXNAME - dirlen;
-  namelen  = (rand() % maxname) + 1;
+
+  /* Force the max filename lengh and also the min name len = 4 */
+
+  maxname  = CONFIG_TESTING_FSTEST_MAXNAME - dirlen - 3;
+  namelen  = (rand() % maxname) + 4;
   alloclen = namelen + dirlen;
 
   file->name = (FAR char *)malloc(alloclen + 1);

Reply via email to