tmpdir: rename tst_tmpdir_mkpath to tst_tmpdir_genpath
PATCH 1/1 tmpdir: rename tst_tmpdir_mkpath to tst_tmpdir_genpath
When I reviewed the rename15 patch I felt confused a while on function like tst_tmpdir_mkpath (reminds me of: mkdir).
Because the name could be misleading since it suggests that a file or directory is being created, when in fact it is simply constructing a path inside a temporary directory without actually creating any files.
To make the function's purpose clearer, the name should reflect that it is only constructing or generating a path, not creating any files or directories.
So I think either 'tst_tmpdir_genpath' or 'tst_tmpdir_buildpath' would be concise and clear options.
--- include/tst_tmpdir.h | 4 ++-- lib/newlib_tests/tst_device.c | 2 +- lib/tst_tmpdir.c | 2 +- testcases/kernel/syscalls/faccessat/faccessat01.c | 2 +- testcases/kernel/syscalls/faccessat2/faccessat201.c | 2 +- testcases/kernel/syscalls/fchmodat/fchmodat01.c | 2 +- testcases/kernel/syscalls/ioctl/ioctl_loop01.c | 2 +- testcases/kernel/syscalls/ioctl/ioctl_loop02.c | 4 ++-- testcases/kernel/syscalls/ioctl/ioctl_loop05.c | 2 +- testcases/kernel/syscalls/mount/mount06.c | 8 ++++---- testcases/kernel/syscalls/mount/mount07.c | 6 +++--- testcases/kernel/syscalls/pathconf/pathconf02.c | 2 +- testcases/kernel/syscalls/readlinkat/readlinkat01.c | 2 +- testcases/kernel/syscalls/stat/stat04.c | 4 ++-- 14 files changed, 22 insertions(+), 22 deletions(-)
include/tst_tmpdir.h +2 -2
@@ -29,7 +29,7 @@ void tst_purge_dir(const char *path);char *tst_tmpdir_path (void );/** -* tst_tmpdir_mkpath - Construct an absolute path pointing to a file inside tmpdir. +* tst_tmpdir_genpath - Construct an absolute path pointing to a file inside tmpdir. * * Constructs a path inside tmpdir i.e. adds a prefix pointing to the current * test tmpdir to the string build by the printf-like format.
@@ -41,7 +41,7 @@ char *tst_tmpdir_path(void);* of the test. If allocation fails the function calls tst_brk() and exits the * test. */ -char *tst_tmpdir_mkpath (const char *fmt, ...) +char *tst_tmpdir_genpath (const char *fmt, ...) __attribute__((format (printf,1 ,2 )));/*
lib/newlib_tests/tst_device.c +1 -1
@@ -29,7 +29,7 @@ static void setup(void) {int fd; - mntpoint =tst_tmpdir_mkpath ("mnt" ); + mntpoint =tst_tmpdir_genpath ("mnt" ); fd =SAFE_OPEN (tst_device->dev,O_RDONLY );
lib/tst_tmpdir.c +1 -1
@@ -372,7 +372,7 @@ char *tst_tmpdir_path(void)return tmpdir; } -char *tst_tmpdir_mkpath (const char *fmt, ...) +char *tst_tmpdir_genpath (const char *fmt, ...) {size_t testdir_len, path_len;va_list va, vac;
testcases/kernel/syscalls/faccessat/faccessat01.c +1 -1
@@ -55,7 +55,7 @@ static void verify_faccessat(unsigned int i)static void setup (void ) { - abs_path =tst_tmpdir_mkpath (FILEPATH ); + abs_path =tst_tmpdir_genpath (FILEPATH );SAFE_MKDIR (TESTDIR ,0700 ); dir_fd =SAFE_OPEN (TESTDIR ,O_DIRECTORY );
testcases/kernel/syscalls/faccessat2/faccessat201.c +1 -1
@@ -56,7 +56,7 @@ static void verify_faccessat2(unsigned int i)static void setup (void ) { - abs_path =tst_tmpdir_mkpath (RELPATH ); + abs_path =tst_tmpdir_genpath (RELPATH );SAFE_MKDIR (TESTDIR ,0777 ); dir_fd =SAFE_OPEN (TESTDIR ,O_DIRECTORY );
testcases/kernel/syscalls/fchmodat/fchmodat01.c +1 -1
@@ -60,7 +60,7 @@ static void verify_fchmodat(unsigned int i)static void setup (void ) { - abs_path =tst_tmpdir_mkpath (FILEPATH ); + abs_path =tst_tmpdir_genpath (FILEPATH );SAFE_MKDIR (TESTDIR ,0700 ); dir_fd =SAFE_OPEN (TESTDIR ,O_DIRECTORY );
testcases/kernel/syscalls/ioctl/ioctl_loop01.c +1 -1
@@ -126,7 +126,7 @@ static void setup(void)sprintf (autoclear_path,"/sys/block/loop%d/loop/autoclear" , dev_num);sprintf (backing_path,"/sys/block/loop%d/loop/backing_file" , dev_num);sprintf (sys_loop_partpath,"/sys/block/loop%d/loop%dp1" , dev_num, dev_num); - backing_file_path =tst_tmpdir_mkpath ("test.img" ); + backing_file_path =tst_tmpdir_genpath ("test.img" );sprintf (loop_partpath,"%sp1" , dev_path); dev_fd =SAFE_OPEN (dev_path,O_RDWR ); }
testcases/kernel/syscalls/ioctl/ioctl_loop02.c +2 -2
@@ -121,8 +121,8 @@ static void setup(void)tst_fill_file ("test2.img" ,0 ,2048 ,20 );sprintf (backing_path,"/sys/block/loop%d/loop/backing_file" , dev_num); - backing_file_path =tst_tmpdir_mkpath ("test.img" ); - backing_file_change_path =tst_tmpdir_mkpath ("test1.img" ); + backing_file_path =tst_tmpdir_genpath ("test.img" ); + backing_file_change_path =tst_tmpdir_genpath ("test1.img" );sprintf (loop_ro_path,"/sys/block/loop%d/ro" , dev_num); file_change_fd =SAFE_OPEN ("test1.img" ,O_RDWR );
testcases/kernel/syscalls/ioctl/ioctl_loop05.c +1 -1
@@ -125,7 +125,7 @@ static void setup(void)* size of loop is bigger than the backing device's and the loop * needn't transform transfer. */ - backing_file_path =tst_tmpdir_mkpath ("test.img" ); + backing_file_path =tst_tmpdir_genpath ("test.img" );tst_find_backing_dev (backing_file_path, bd_path,sizeof (bd_path)); block_devfd =SAFE_OPEN (bd_path,O_RDWR );SAFE_IOCTL (block_devfd,BLKSSZGET , &logical_block_size);
testcases/kernel/syscalls/mount/mount06.c +4 -4
@@ -43,10 +43,10 @@ static void setup(void)SAFE_MOUNT (tmppath, tmppath,"none" ,MS_BIND ,NULL );SAFE_MOUNT ("none" , tmppath,"none" ,MS_PRIVATE ,NULL ); - mntpoint_src =tst_tmpdir_mkpath (MNTPOINT_SRC ); - mntpoint_dst =tst_tmpdir_mkpath (MNTPOINT_DST ); - tstfiles_src =tst_tmpdir_mkpath ("%s/testfile" ,MNTPOINT_SRC ); - tstfiles_dst =tst_tmpdir_mkpath ("%s/testfile" ,MNTPOINT_DST ); + mntpoint_src =tst_tmpdir_genpath (MNTPOINT_SRC ); + mntpoint_dst =tst_tmpdir_genpath (MNTPOINT_DST ); + tstfiles_src =tst_tmpdir_genpath ("%s/testfile" ,MNTPOINT_SRC ); + tstfiles_dst =tst_tmpdir_genpath ("%s/testfile" ,MNTPOINT_DST );SAFE_MKDIR (mntpoint_dst,0750 ); }
testcases/kernel/syscalls/mount/mount07.c +3 -3
@@ -114,9 +114,9 @@ static void test_statfs(bool nosymfollow)static void setup (void ) { - test_file =tst_tmpdir_mkpath ("%s/test_file" ,MNTPOINT ); - link_file =tst_tmpdir_mkpath ("%s/link_file" ,MNTPOINT ); - temp_link_file =tst_tmpdir_mkpath ("%s/temp_link_file" ,MNTPOINT ); + test_file =tst_tmpdir_genpath ("%s/test_file" ,MNTPOINT ); + link_file =tst_tmpdir_genpath ("%s/link_file" ,MNTPOINT ); + temp_link_file =tst_tmpdir_genpath ("%s/temp_link_file" ,MNTPOINT ); }static void cleanup (void )
testcases/kernel/syscalls/pathconf/pathconf02.c +1 -1
@@ -70,7 +70,7 @@ static void setup(void)SAFE_TOUCH ("testfile" ,0777 ,NULL ); - abs_path =tst_tmpdir_mkpath (FILEPATH ); + abs_path =tst_tmpdir_genpath (FILEPATH );SAFE_CHMOD (tst_tmpdir_path (),0 );
testcases/kernel/syscalls/readlinkat/readlinkat01.c +1 -1
@@ -66,7 +66,7 @@ static void verify_readlinkat(unsigned int i)static void setup (void ) { - abspath =tst_tmpdir_mkpath (TEST_SYMLINK ); + abspath =tst_tmpdir_genpath (TEST_SYMLINK ); file_fd =SAFE_OPEN (TEST_FILE ,O_CREAT ,0600 );SAFE_SYMLINK (TEST_FILE ,TEST_SYMLINK );
testcases/kernel/syscalls/stat/stat04.c +2 -2
@@ -49,8 +49,8 @@ static void setup(void)int pagesize;int fd; - file_path =tst_tmpdir_mkpath (FILENAME ); - symb_path =tst_tmpdir_mkpath (SYMBNAME ); + file_path =tst_tmpdir_genpath (FILENAME ); + symb_path =tst_tmpdir_genpath (SYMBNAME );/* change st_blksize / st_dev */ SAFE_STAT ("." , &sb);
Signature · 5 lines
2.46.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 7 lines
When I reviewed the rename15 patch I felt confused a while on function like
tst_tmpdir_mkpath(reminds me of: mkdir).Because the name could be misleading since it suggests that a file or directory is being created, when in fact it is simply constructing a path inside a temporary directory without actually creating any files.
Good catch, this is indeed confusing.
Quoted 6 lines
To make the function's purpose clearer, the name should reflect that it is only constructing or generating a path, not creating any files or directories.
So I think either '
tst_tmpdir_genpath' or 'tst_tmpdir_buildpath' would be concise and clear options.
Maybe tst_tmpdir_getpath()?
But I agree that any of these three is better than the original. Naming API functions is hard...
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 11 lines · Cyril Hrubis
Hi!
Quoted 7 lines
When I reviewed the rename15 patch I felt confused a while on function like
tst_tmpdir_mkpath(reminds me of: mkdir).Because the name could be misleading since it suggests that a file or directory is being created, when in fact it is simply constructing a path inside a temporary directory without actually creating any files.
Good catch, this is indeed confusing.
Quoted 9 lines
Quoted 6 lines
To make the function's purpose clearer, the name should reflect that it is only constructing or generating a path, not creating any files or directories.
So I think either '
tst_tmpdir_genpath' or 'tst_tmpdir_buildpath' would be concise and clear options.Maybe
tst_tmpdir_getpath()?
Hmm, I feel 'gen' is better than 'get', because get looks like there already exist and we just get the path in a pointer. 'gen' is more like generating a string but not creating it.
Maybe others have different opinions.
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 23 lines · Li Wang
Quoted 19 lines · Cyril Hrubis
Hi!
Quoted 7 lines
When I reviewed the rename15 patch I felt confused a while on function like
tst_tmpdir_mkpath(reminds me of: mkdir).Because the name could be misleading since it suggests that a file or directory is being created, when in fact it is simply constructing a path inside a temporary directory without actually creating any files.
Good catch, this is indeed confusing.
Quoted 6 lines
To make the function's purpose clearer, the name should reflect that it is only constructing or generating a path, not creating any files or directories.
So I think either '
tst_tmpdir_genpath' or 'tst_tmpdir_buildpath' would be concise and clear options.
Quoted 8 lines
Quoted 1 line
Maybe
tst_tmpdir_getpath()?Hmm, I feel 'gen' is better than 'get', because get looks like there already exist and we just get the path in a pointer. 'gen' is more like generating a string but not creating it.
Maybe others have different opinions.
tst_tmpdir_pathfmttst_tmpdir_mkpathname - seems too long
given the choices above, genpath seems OK to me as well
Quoted 5 lines
--
Regards,
Li Wang
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Cyril Hrubis
Acked-byHi!
Quoted 3 lines
Hmm, I feel 'gen' is better than 'get', because get looks like there already exist and we just get the path in a pointer. 'gen' is more like generating a string but not creating it.
Feel free to go with 'gen' it's way better than the original.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 11 lines · Cyril Hrubis
Hi!
Quoted 1 line
Hmm, I feel 'gen' is better than 'get', because get looks like there
already
Quoted 1 line
exist and we just get the path in a pointer. 'gen' is more like
generating
Quoted 1 line
a string but not creating it.
Feel free to go with 'gen' it's way better than the original.
Acked-by Cyril Hrubis <[email protected]>
Pushed, thank you all.
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp