All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [RFC PATCH 0/6] Check exported library symbols and cleanup
@ 2021-05-17 16:30 Richard Palethorpe
  2021-05-17 16:30 ` [LTP] [RFC PATCH 1/6] API: Make some internal symbols static Richard Palethorpe
                   ` (5 more replies)
  0 siblings, 6 replies; 21+ messages in thread
From: Richard Palethorpe @ 2021-05-17 16:30 UTC (permalink / raw)
  To: ltp

Hello,

Forgetting to add static to a global variable is a common mistake. So
far we have relied on manual review to spot it. This is a waste of
time for both the test author and reviewer.

Generally speaking all API functions have tst_ or safe_ prepended. It
is simple to check that exported symbols match this naming. Although I
expect the script I have created will break building on some distros.

The patchset also includes a bunch of fixes for some symbols. I have
tried to fix stuff in the new API and ignored issues only in the old
one.

I created another script to look for unused functions. However this
relies on GNU Global. Also I'm not sure what to do with the
results. FYI the unused commands are listed below:

ltpdev_ioctl_cmds_s	testcases/kernel/fs/scsi/ltpfs/Ltpfs.h	62
ltpdev_ioctl_cmds_t	testcases/kernel/fs/scsi/ltpfs/Ltpfs.h	66
tst_its_set_interval_from_ts	include/tst_timer.h	747
tst_ms_to_timeval	include/tst_timer.h	43
tst_numa_types	include/tst_numa.h	93
tst_timer_tcase	lib/tst_timer_test.c	390
tst_timespec_add_us	include/tst_timer.h	820
tst_timespec_diff_us	include/tst_timer.h	941
tst_timespec_from_ms	include/tst_timer.h	717
tst_timespec_sub_us	include/tst_timer.h	847
tst_timeval_diff_ms	include/tst_timer.h	92
tst_timeval_diff_us	include/tst_timer.h	86
tst_ts_abs_diff_ms	include/tst_timer.h	1001

I have removed some from the list which actually seem to be an issue
with the script or I have already submitted a patch to remove.

Richard Palethorpe (6):
  API: Make some internal symbols static
  API: Add tst_ to create_sig_proc
  API: Add tst_ to file_* functions
  API: add tst_ to mount_overlay
  API: Add tst_ to hugepage opt vars
  API: Check exported symbols

 doc/test-writing-guidelines.txt               |  2 +-
 include/old/old_safe_file_ops.h               | 14 ++--
 include/old/test.h                            |  1 -
 include/safe_file_ops_fn.h                    | 25 ++++----
 include/tst_hugepage.h                        |  4 +-
 include/tst_safe_file_ops.h                   | 24 +++----
 include/tst_sig_proc.h                        |  2 +-
 lib/Makefile                                  | 12 ++++
 lib/newlib_tests/tst_safe_fileops.c           |  4 +-
 lib/safe_file_ops.c                           | 10 +--
 lib/tst_assert.c                              |  4 +-
 lib/tst_clocks.c                              |  2 +-
 lib/tst_device.c                              |  2 +-
 lib/tst_fs_link_count.c                       |  2 +-
 lib/tst_fs_setup.c                            |  4 +-
 lib/tst_hugepage.c                            |  8 +--
 lib/tst_res.c                                 |  2 +-
 lib/tst_sig_proc.c                            |  2 +-
 lib/tst_status.c                              |  6 +-
 lib/tst_sys_conf.c                            |  2 +-
 lib/tst_test.c                                |  2 +-
 lib/tst_timer_test.c                          |  2 +-
 libs/libltpsigwait/sigwait.c                  | 18 +++---
 scripts/check_export_syms.sh                  | 64 +++++++++++++++++++
 testcases/cve/meltdown.c                      |  2 +-
 .../device-drivers/cpufreq/cpufreq_boost.c    |  4 +-
 .../kernel/mem/hugetlb/hugemmap/hugemmap01.c  | 14 ++--
 .../kernel/mem/hugetlb/hugemmap/hugemmap02.c  | 14 ++--
 .../kernel/mem/hugetlb/hugemmap/hugemmap04.c  | 14 ++--
 .../mem/hugetlb/hugeshmat/hugeshmat01.c       |  2 +-
 .../mem/hugetlb/hugeshmat/hugeshmat02.c       |  2 +-
 .../mem/hugetlb/hugeshmat/hugeshmat03.c       |  2 +-
 .../mem/hugetlb/hugeshmctl/hugeshmctl01.c     |  2 +-
 .../mem/hugetlb/hugeshmctl/hugeshmctl02.c     |  2 +-
 .../mem/hugetlb/hugeshmctl/hugeshmctl03.c     |  2 +-
 .../mem/hugetlb/hugeshmdt/hugeshmdt01.c       |  2 +-
 .../mem/hugetlb/hugeshmget/hugeshmget01.c     |  2 +-
 .../mem/hugetlb/hugeshmget/hugeshmget02.c     |  2 +-
 .../mem/hugetlb/hugeshmget/hugeshmget03.c     |  4 +-
 .../mem/hugetlb/hugeshmget/hugeshmget05.c     |  2 +-
 testcases/kernel/mem/ksm/ksm01.c              |  4 +-
 testcases/kernel/mem/ksm/ksm02.c              |  4 +-
 testcases/kernel/mem/ksm/ksm03.c              |  4 +-
 testcases/kernel/mem/ksm/ksm04.c              |  4 +-
 testcases/kernel/mem/ksm/ksm05.c              |  2 +-
 testcases/kernel/mem/ksm/ksm06.c              |  8 +--
 testcases/kernel/mem/swapping/swapping01.c    |  2 +-
 .../clock_nanosleep/clock_nanosleep01.c       |  2 +-
 testcases/kernel/syscalls/fcntl/fcntl33.c     |  2 +-
 testcases/kernel/syscalls/fork/fork13.c       |  2 +-
 .../syscalls/migrate_pages/migrate_pages02.c  |  2 +-
 testcases/kernel/syscalls/ppoll/ppoll01.c     |  4 +-
 testcases/kernel/syscalls/prctl/prctl06.c     |  2 +-
 .../kernel/syscalls/readahead/readahead02.c   |  2 +-
 testcases/kernel/syscalls/utils/mq_timed.h    |  2 +-
 testcases/kernel/tracing/pt_test/pt_test.c    |  4 +-
 .../network/can/filter-tests/can_common.h     |  2 +-
 testcases/network/packet/fanout01.c           |  6 +-
 58 files changed, 211 insertions(+), 137 deletions(-)
 create mode 100755 scripts/check_export_syms.sh

-- 
2.31.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 1/6] API: Make some internal symbols static
  2021-05-17 16:30 [LTP] [RFC PATCH 0/6] Check exported library symbols and cleanup Richard Palethorpe
@ 2021-05-17 16:30 ` Richard Palethorpe
  2021-05-18  7:57   ` Petr Vorel
  2021-05-17 16:30 ` [LTP] [RFC PATCH 2/6] API: Add tst_ to create_sig_proc Richard Palethorpe
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 21+ messages in thread
From: Richard Palethorpe @ 2021-05-17 16:30 UTC (permalink / raw)
  To: ltp

These do not appear to be referenced anywhere outside the library.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 include/old/test.h      | 1 -
 lib/tst_clocks.c        | 2 +-
 lib/tst_device.c        | 2 +-
 lib/tst_fs_link_count.c | 2 +-
 lib/tst_fs_setup.c      | 2 +-
 lib/tst_res.c           | 2 +-
 lib/tst_status.c        | 6 +++---
 lib/tst_test.c          | 2 +-
 lib/tst_timer_test.c    | 2 +-
 9 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/include/old/test.h b/include/old/test.h
index 2ae7dba71..a8994c08e 100644
--- a/include/old/test.h
+++ b/include/old/test.h
@@ -113,7 +113,6 @@ void tst_parse_opts(int argc, char *argv[], const option_t *user_optarg,
                     void (*user_help)(void));
 
 /* lib/tst_res.c */
-const char *strttype(int ttype);
 
 void tst_resm_(const char *file, const int lineno, int ttype,
 	const char *arg_fmt, ...)
diff --git a/lib/tst_clocks.c b/lib/tst_clocks.c
index cdcb9fc4f..9af4d2993 100644
--- a/lib/tst_clocks.c
+++ b/lib/tst_clocks.c
@@ -14,7 +14,7 @@
 
 typedef int (*mysyscall)(clockid_t clk_id, void *ts);
 
-int syscall_supported_by_kernel(long sysnr)
+static int syscall_supported_by_kernel(long sysnr)
 {
 	int ret;
 
diff --git a/lib/tst_device.c b/lib/tst_device.c
index c096b418b..079173b87 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -446,7 +446,7 @@ int tst_is_mounted_at_tmpdir(const char *path)
 	return tst_is_mounted(mpath);
 }
 
-int find_stat_file(const char *dev, char *path, size_t path_len)
+static int find_stat_file(const char *dev, char *path, size_t path_len)
 {
 	const char *devname = strrchr(dev, '/') + 1;
 
diff --git a/lib/tst_fs_link_count.c b/lib/tst_fs_link_count.c
index 860510d75..c4e20bebf 100644
--- a/lib/tst_fs_link_count.c
+++ b/lib/tst_fs_link_count.c
@@ -32,7 +32,7 @@
  * XXX: we cannot filter ext4 out, because ext2/ext3/ext4 have the
  * same magic number
  */
-const long subdir_limit_whitelist[] = {
+static const long subdir_limit_whitelist[] = {
 	TST_EXT2_OLD_MAGIC, TST_EXT234_MAGIC, TST_MINIX_MAGIC,
 	TST_MINIX_MAGIC2,   TST_MINIX2_MAGIC, TST_MINIX2_MAGIC2,
 	TST_MINIX3_MAGIC,   TST_UDF_MAGIC,    TST_SYSV2_MAGIC,
diff --git a/lib/tst_fs_setup.c b/lib/tst_fs_setup.c
index 6b93483de..b20fd06f2 100644
--- a/lib/tst_fs_setup.c
+++ b/lib/tst_fs_setup.c
@@ -11,7 +11,7 @@
 #define TST_FS_SETUP_OVERLAYFS_MSG "overlayfs is not configured in this kernel"
 #define TST_FS_SETUP_OVERLAYFS_CONFIG "lowerdir="OVL_LOWER",upperdir="OVL_UPPER",workdir="OVL_WORK
 
-void create_overlay_dirs(void)
+static void create_overlay_dirs(void)
 {
 	DIR *dir = opendir(OVL_LOWER);
 	if (dir == NULL) {
diff --git a/lib/tst_res.c b/lib/tst_res.c
index 8d86b48a4..c82e78a9a 100644
--- a/lib/tst_res.c
+++ b/lib/tst_res.c
@@ -139,7 +139,7 @@ struct pair {
 	return pair_arr[idx].name;                            \
 } while (0)
 
-const char *strttype(int ttype)
+static const char *strttype(int ttype)
 {
 	static const struct pair ttype_pairs[] = {
 		PAIR(TPASS)
diff --git a/lib/tst_status.c b/lib/tst_status.c
index 9124faaa3..12dee103f 100644
--- a/lib/tst_status.c
+++ b/lib/tst_status.c
@@ -11,14 +11,14 @@
 
 static char buf[32];
 
-const char *exited(int status)
+static const char *exited(int status)
 {
 	snprintf(buf, sizeof(buf), "exited with %i", WEXITSTATUS(status));
 
 	return buf;
 }
 
-const char *signaled(int status)
+static const char *signaled(int status)
 {
 	snprintf(buf, sizeof(buf), "killed by %s",
 		tst_strsig(WTERMSIG(status)));
@@ -26,7 +26,7 @@ const char *signaled(int status)
 	return buf;
 }
 
-const char *invalid(int status)
+static const char *invalid(int status)
 {
 	snprintf(buf, sizeof(buf), "invalid status 0x%x", status);
 
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 36a4809c7..4899ea70b 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -747,7 +747,7 @@ static void do_exit(int ret)
 	exit(ret);
 }
 
-void check_kver(void)
+static void check_kver(void)
 {
 	int v1, v2, v3;
 
diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c
index 3cd52fc9d..e77b911dd 100644
--- a/lib/tst_timer_test.c
+++ b/lib/tst_timer_test.c
@@ -251,7 +251,7 @@ static void write_to_file(void)
  *   - then we compute truncated mean and compare that with the requested sleep
  *     time increased by a threshold
  */
-void do_timer_test(long long usec, unsigned int nsamples)
+static void do_timer_test(long long usec, unsigned int nsamples)
 {
 	long long trunc_mean, median;
 	unsigned int discard = compute_discard(nsamples);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 2/6] API: Add tst_ to create_sig_proc
  2021-05-17 16:30 [LTP] [RFC PATCH 0/6] Check exported library symbols and cleanup Richard Palethorpe
  2021-05-17 16:30 ` [LTP] [RFC PATCH 1/6] API: Make some internal symbols static Richard Palethorpe
@ 2021-05-17 16:30 ` Richard Palethorpe
  2021-05-18  9:16   ` Li Wang
  2021-05-19 15:13   ` Petr Vorel
  2021-05-17 16:30 ` [LTP] [RFC PATCH 3/6] API: Add tst_ to file_* functions Richard Palethorpe
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 21+ messages in thread
From: Richard Palethorpe @ 2021-05-17 16:30 UTC (permalink / raw)
  To: ltp

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 include/tst_sig_proc.h                         |  2 +-
 lib/tst_sig_proc.c                             |  2 +-
 libs/libltpsigwait/sigwait.c                   | 18 +++++++++---------
 .../clock_nanosleep/clock_nanosleep01.c        |  2 +-
 testcases/kernel/syscalls/ppoll/ppoll01.c      |  4 ++--
 testcases/kernel/syscalls/utils/mq_timed.h     |  2 +-
 6 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/include/tst_sig_proc.h b/include/tst_sig_proc.h
index b85981e77..39a201037 100644
--- a/include/tst_sig_proc.h
+++ b/include/tst_sig_proc.h
@@ -7,6 +7,6 @@
 
 #include <sys/types.h>
 
-pid_t create_sig_proc(int sig, int count, unsigned int usec);
+pid_t tst_create_sig_proc(int sig, int count, unsigned int usec);
 
 #endif	/* TST_SIG_PROC_H__ */
diff --git a/lib/tst_sig_proc.c b/lib/tst_sig_proc.c
index 509418af4..4826f9679 100644
--- a/lib/tst_sig_proc.c
+++ b/lib/tst_sig_proc.c
@@ -11,7 +11,7 @@
 #define TST_NO_DEFAULT_MAIN
 #include "tst_test.h"
 
-pid_t create_sig_proc(int sig, int count, unsigned int usec)
+pid_t tst_create_sig_proc(int sig, int count, unsigned int usec)
 {
 	pid_t pid, cpid;
 
diff --git a/libs/libltpsigwait/sigwait.c b/libs/libltpsigwait/sigwait.c
index 2be949929..aa8ef226d 100644
--- a/libs/libltpsigwait/sigwait.c
+++ b/libs/libltpsigwait/sigwait.c
@@ -19,7 +19,7 @@ void test_empty_set(swi_func sigwaitinfo, int signo,
 	SAFE_SIGEMPTYSET(&sigs);
 
 	/* Run a child that will wake us up */
-	child = create_sig_proc(signo, INT_MAX, 100000);
+	child = tst_create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, &si, NULL));
 	if (TST_RET == -1) {
@@ -49,7 +49,7 @@ void test_timeout(swi_func sigwaitinfo, int signo, enum tst_ts_type type)
 	SAFE_SIGEMPTYSET(&sigs);
 
 	/* Run a child that will wake us up */
-	child = create_sig_proc(signo, INT_MAX, 100000);
+	child = tst_create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, &si, tst_ts_get(&ts)));
 	if (TST_RET == -1) {
@@ -79,7 +79,7 @@ void test_unmasked_matching(swi_func sigwaitinfo, int signo,
 	SAFE_SIGADDSET(&sigs, signo);
 
 	/* Run a child that will wake us up */
-	child = create_sig_proc(signo, INT_MAX, 100000);
+	child = tst_create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, &si, NULL));
 	if (TST_RET == signo) {
@@ -106,7 +106,7 @@ void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo,
 	SAFE_SIGADDSET(&sigs, signo);
 
 	/* Run a child that will wake us up */
-	child = create_sig_proc(signo, INT_MAX, 100000);
+	child = tst_create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, NULL, NULL));
 	if (TST_RET == signo)
@@ -139,7 +139,7 @@ void test_masked_matching(swi_func sigwaitinfo, int signo,
 	SAFE_SIGDELSET(&sigs, SIGCHLD);
 
 	/* Run a child that will wake us up */
-	child = create_sig_proc(signo, 1, 0);
+	child = tst_create_sig_proc(signo, 1, 0);
 
 	TEST(sigwaitinfo(&sigs, &si, NULL));
 	if (TST_RET == signo) {
@@ -191,8 +191,8 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo,
 	SAFE_SIGDELSET(&sigs, SIGCHLD);
 
 	/* Run a child that will wake us up */
-	child[0] = create_sig_proc(signo, 1, 0);
-	child[1] = create_sig_proc(signo + 1, 1, 0);
+	child[0] = tst_create_sig_proc(signo, 1, 0);
+	child[1] = tst_create_sig_proc(signo + 1, 1, 0);
 
 	/* Ensure that the signals have been sent */
 	SAFE_WAITPID(child[0], &status, 0);
@@ -252,7 +252,7 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo,
 	SAFE_SIGDELSET(&sigs, SIGCHLD);
 
 	/* Run a child that will wake us up */
-	child = create_sig_proc(signo, 1, 0);
+	child = tst_create_sig_proc(signo, 1, 0);
 
 	TEST(sigwaitinfo(&sigs, NULL, NULL));
 	if (TST_RET == signo)
@@ -294,7 +294,7 @@ void test_bad_address(swi_func sigwaitinfo, int signo,
 	SAFE_SIGDELSET(&sigs, SIGCHLD);
 
 	/* Run a child that will wake us up */
-	child = create_sig_proc(signo, 1, 0);
+	child = tst_create_sig_proc(signo, 1, 0);
 
 	TEST(sigwaitinfo(&sigs, (void *)1, NULL));
 	if (TST_RET == -1) {
diff --git a/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c b/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c
index 382497918..983dfe1ad 100644
--- a/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c
+++ b/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c
@@ -139,7 +139,7 @@ static void do_test(unsigned int i)
 	tst_res(TINFO, "case %s", tc->desc);
 
 	if (tc->ttype == SEND_SIGINT || tc->ttype == BAD_TS_ADDR_REM)
-		pid = create_sig_proc(SIGINT, 40, 500000);
+		pid = tst_create_sig_proc(SIGINT, 40, 500000);
 
 	tst_ts_set_sec(rq, tc->tv_sec);
 	tst_ts_set_nsec(rq, tc->tv_nsec);
diff --git a/testcases/kernel/syscalls/ppoll/ppoll01.c b/testcases/kernel/syscalls/ppoll/ppoll01.c
index 3d2f92f2a..3ea155445 100644
--- a/testcases/kernel/syscalls/ppoll/ppoll01.c
+++ b/testcases/kernel/syscalls/ppoll/ppoll01.c
@@ -251,8 +251,8 @@ static void do_test(unsigned int i)
 			tst_brk(TBROK, "sigprocmask");
 	}
 	if (tc->sigint_count > 0) {
-		pid = create_sig_proc(SIGINT, tc->sigint_count,
-			tc->sigint_delay);
+		pid = tst_create_sig_proc(SIGINT, tc->sigint_count,
+					  tc->sigint_delay);
 	}
 
 	/* test */
diff --git a/testcases/kernel/syscalls/utils/mq_timed.h b/testcases/kernel/syscalls/utils/mq_timed.h
index adf46034b..84831b548 100644
--- a/testcases/kernel/syscalls/utils/mq_timed.h
+++ b/testcases/kernel/syscalls/utils/mq_timed.h
@@ -45,7 +45,7 @@ static pid_t set_sig(struct tst_ts *ts,
 	gettime(CLOCK_REALTIME, tst_ts_get(ts));
 	*ts = tst_ts_add_us(*ts, 3000000);
 
-	return create_sig_proc(SIGINT, 40, 50000);
+	return tst_create_sig_proc(SIGINT, 40, 50000);
 }
 
 static void set_timeout(struct tst_ts *ts,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 3/6] API: Add tst_ to file_* functions
  2021-05-17 16:30 [LTP] [RFC PATCH 0/6] Check exported library symbols and cleanup Richard Palethorpe
  2021-05-17 16:30 ` [LTP] [RFC PATCH 1/6] API: Make some internal symbols static Richard Palethorpe
  2021-05-17 16:30 ` [LTP] [RFC PATCH 2/6] API: Add tst_ to create_sig_proc Richard Palethorpe
@ 2021-05-17 16:30 ` Richard Palethorpe
  2021-05-18  9:23   ` Li Wang
  2021-05-19 15:11   ` Petr Vorel
  2021-05-17 16:30 ` [LTP] [RFC PATCH 4/6] API: add tst_ to mount_overlay Richard Palethorpe
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 21+ messages in thread
From: Richard Palethorpe @ 2021-05-17 16:30 UTC (permalink / raw)
  To: ltp

Usually LTP library functions are prepended with tst_ if not with
safe_.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 doc/test-writing-guidelines.txt               |  2 +-
 include/old/old_safe_file_ops.h               | 14 ++++++------
 include/safe_file_ops_fn.h                    | 22 +++++++++----------
 include/tst_safe_file_ops.h                   | 20 ++++++++---------
 lib/newlib_tests/tst_safe_fileops.c           |  4 ++--
 lib/safe_file_ops.c                           | 10 ++++-----
 lib/tst_assert.c                              |  4 ++--
 lib/tst_sys_conf.c                            |  2 +-
 testcases/cve/meltdown.c                      |  2 +-
 .../device-drivers/cpufreq/cpufreq_boost.c    |  4 ++--
 .../mem/hugetlb/hugeshmget/hugeshmget03.c     |  2 +-
 testcases/kernel/mem/ksm/ksm01.c              |  4 ++--
 testcases/kernel/mem/ksm/ksm02.c              |  4 ++--
 testcases/kernel/mem/ksm/ksm03.c              |  4 ++--
 testcases/kernel/mem/ksm/ksm04.c              |  4 ++--
 testcases/kernel/mem/ksm/ksm05.c              |  2 +-
 testcases/kernel/mem/ksm/ksm06.c              |  8 +++----
 testcases/kernel/mem/swapping/swapping01.c    |  2 +-
 testcases/kernel/syscalls/fcntl/fcntl33.c     |  2 +-
 testcases/kernel/syscalls/fork/fork13.c       |  2 +-
 .../syscalls/migrate_pages/migrate_pages02.c  |  2 +-
 testcases/kernel/syscalls/prctl/prctl06.c     |  2 +-
 .../kernel/syscalls/readahead/readahead02.c   |  2 +-
 testcases/kernel/tracing/pt_test/pt_test.c    |  4 ++--
 .../network/can/filter-tests/can_common.h     |  2 +-
 testcases/network/packet/fanout01.c           |  6 ++---
 26 files changed, 68 insertions(+), 68 deletions(-)

diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index c268b8804..74f168e06 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -1715,7 +1715,7 @@ static const char *save_restore[] = {
 
 static void setup(void)
 {
-	FILE_PRINTF("/proc/sys/kernel/core_pattern", "/mypath");
+	TST_FILE_PRINTF("/proc/sys/kernel/core_pattern", "/mypath");
 }
 
 static struct tst_test test = {
diff --git a/include/old/old_safe_file_ops.h b/include/old/old_safe_file_ops.h
index d6e2d29a9..d36079ab5 100644
--- a/include/old/old_safe_file_ops.h
+++ b/include/old/old_safe_file_ops.h
@@ -30,24 +30,24 @@
 
 #include "safe_file_ops_fn.h"
 
-#define FILE_SCANF(path, fmt, ...) \
-	file_scanf(__FILE__, __LINE__, \
-	           (path), (fmt), ## __VA_ARGS__)
+#define TST_FILE_SCANF(path, fmt, ...) \
+	tst_file_scanf(__FILE__, __LINE__, \
+		       (path), (fmt), ## __VA_ARGS__)
 
 #define SAFE_FILE_SCANF(cleanup_fn, path, fmt, ...) \
 	safe_file_scanf(__FILE__, __LINE__, (cleanup_fn), \
 	                (path), (fmt), ## __VA_ARGS__)
 
 #define FILE_LINES_SCANF(cleanup_fn, path, fmt, ...) \
-	file_lines_scanf(__FILE__, __LINE__, (cleanup_fn), 0, \
+	tst_file_lines_scanf(__FILE__, __LINE__, (cleanup_fn), 0, \
 			(path), (fmt), ## __VA_ARGS__)
 
 #define SAFE_FILE_LINES_SCANF(cleanup_fn, path, fmt, ...) \
-	file_lines_scanf(__FILE__, __LINE__, (cleanup_fn), 1, \
+	tst_file_lines_scanf(__FILE__, __LINE__, (cleanup_fn), 1, \
 			(path), (fmt), ## __VA_ARGS__)
 
-#define FILE_PRINTF(path, fmt, ...) \
-	file_printf(__FILE__, __LINE__, \
+#define TST_FILE_PRINTF(path, fmt, ...) \
+	tst_file_printf(__FILE__, __LINE__, \
 	            (path), (fmt), ## __VA_ARGS__)
 
 #define SAFE_FILE_PRINTF(cleanup_fn, path, fmt, ...) \
diff --git a/include/safe_file_ops_fn.h b/include/safe_file_ops_fn.h
index 6d680967b..620e12e9a 100644
--- a/include/safe_file_ops_fn.h
+++ b/include/safe_file_ops_fn.h
@@ -36,31 +36,31 @@ int tst_count_scanf_conversions(const char *fmt);
 /*
  * All-in-one function to scanf value(s) from a file.
  */
-int file_scanf(const char *file, const int lineno,
-		const char *path, const char *fmt, ...)
-		__attribute__ ((format (scanf, 4, 5)));
+int tst_file_scanf(const char *file, const int lineno,
+		   const char *path, const char *fmt, ...)
+		   __attribute__ ((format (scanf, 4, 5)));
 
 void safe_file_scanf(const char *file, const int lineno,
                      void (*cleanup_fn)(void),
 		     const char *path, const char *fmt, ...)
 		     __attribute__ ((format (scanf, 5, 6)));
 
-int file_lines_scanf(const char *file, const int lineno,
-		     void (*cleanup_fn)(void), int strict,
-		     const char *path, const char *fmt, ...)
-		     __attribute__ ((format (scanf, 6, 7)));
+int tst_file_lines_scanf(const char *file, const int lineno,
+			 void (*cleanup_fn)(void), int strict,
+			 const char *path, const char *fmt, ...)
+			 __attribute__ ((format (scanf, 6, 7)));
 
 /*
  * All-in-one function that lets you printf directly into a file.
  */
-int file_printf(const char *file, const int lineno,
-                      const char *path, const char *fmt, ...)
-                      __attribute__ ((format (printf, 4, 5)));
+int tst_file_printf(const char *file, const int lineno,
+		    const char *path, const char *fmt, ...)
+		    __attribute__ ((format (printf, 4, 5)));
 
 void safe_file_printf(const char *file, const int lineno,
                       void (*cleanup_fn)(void),
                       const char *path, const char *fmt, ...)
-                      __attribute__ ((format (printf, 5, 6)));
+		      __attribute__ ((format (printf, 5, 6)));
 
 /*
  * Safe function to copy files, no more system("cp ...") please.
diff --git a/include/tst_safe_file_ops.h b/include/tst_safe_file_ops.h
index 223eddd1f..7457edd61 100644
--- a/include/tst_safe_file_ops.h
+++ b/include/tst_safe_file_ops.h
@@ -7,20 +7,20 @@
 
 #include "safe_file_ops_fn.h"
 
-#define FILE_SCANF(path, fmt, ...) \
-	file_scanf(__FILE__, __LINE__, (path), (fmt), ## __VA_ARGS__)
+#define TST_FILE_SCANF(path, fmt, ...) \
+	tst_file_scanf(__FILE__, __LINE__, (path), (fmt), ## __VA_ARGS__)
 
 #define SAFE_FILE_SCANF(path, fmt, ...) \
 	safe_file_scanf(__FILE__, __LINE__, NULL, \
 	                (path), (fmt), ## __VA_ARGS__)
 
-#define FILE_LINES_SCANF(path, fmt, ...) \
-	file_lines_scanf(__FILE__, __LINE__, NULL, 0,\
-			(path), (fmt), ## __VA_ARGS__)
+#define TST_FILE_LINES_SCANF(path, fmt, ...) \
+	tst_file_lines_scanf(__FILE__, __LINE__, NULL, 0,\
+			     (path), (fmt), ## __VA_ARGS__)
 
 #define SAFE_FILE_LINES_SCANF(path, fmt, ...) \
-	file_lines_scanf(__FILE__, __LINE__, NULL, 1,\
-			(path), (fmt), ## __VA_ARGS__)
+	tst_file_lines_scanf(__FILE__, __LINE__, NULL, 1,\
+			     (path), (fmt), ## __VA_ARGS__)
 
 #define SAFE_READ_MEMINFO(item) \
        ({long tst_rval; \
@@ -36,9 +36,9 @@
                         &tst_rval_); \
         tst_rval_;})
 
-#define FILE_PRINTF(path, fmt, ...) \
-	file_printf(__FILE__, __LINE__, \
-		    (path), (fmt), ## __VA_ARGS__)
+#define TST_FILE_PRINTF(path, fmt, ...) \
+	tst_file_printf(__FILE__, __LINE__, \
+			(path), (fmt), ## __VA_ARGS__)
 
 #define SAFE_FILE_PRINTF(path, fmt, ...) \
 	safe_file_printf(__FILE__, __LINE__, NULL, \
diff --git a/lib/newlib_tests/tst_safe_fileops.c b/lib/newlib_tests/tst_safe_fileops.c
index e8419bd23..d6a7030f6 100644
--- a/lib/newlib_tests/tst_safe_fileops.c
+++ b/lib/newlib_tests/tst_safe_fileops.c
@@ -13,11 +13,11 @@ static void do_test(void)
 	long dummy;
 
 	SAFE_FILE_LINES_SCANF("/proc/meminfo", "MemFree: %ld", &free);
-	if (FILE_LINES_SCANF("/proc/stat", "processes %ld", &nproc))
+	if (TST_FILE_LINES_SCANF("/proc/stat", "processes %ld", &nproc))
 		tst_brk(TBROK, "Could not parse processes");
 	tst_res(TPASS, "Free: %ld, nproc: %ld", free, nproc);
 
-	if (FILE_LINES_SCANF("/proc/stat", "non-existent %ld", &dummy))
+	if (TST_FILE_LINES_SCANF("/proc/stat", "non-existent %ld", &dummy))
 		tst_res(TPASS, "non-existent not found");
 	SAFE_FILE_LINES_SCANF("/proc/stat", "non-existent %ld", &dummy);
 }
diff --git a/lib/safe_file_ops.c b/lib/safe_file_ops.c
index 249a512a1..132530345 100644
--- a/lib/safe_file_ops.c
+++ b/lib/safe_file_ops.c
@@ -66,7 +66,7 @@ int tst_count_scanf_conversions(const char *fmt)
 	return cnt;
 }
 
-int file_scanf(const char *file, const int lineno,
+int tst_file_scanf(const char *file, const int lineno,
 		     const char *path, const char *fmt, ...)
 {
 	va_list va;
@@ -165,9 +165,9 @@ void safe_file_scanf(const char *file, const int lineno,
  * to scanf format 'fmt'. If all fields could be parsed, stop and
  * return 0, otherwise continue or return 1 if EOF is reached.
  */
-int file_lines_scanf(const char *file, const int lineno,
-		     void (*cleanup_fn)(void), int strict,
-		     const char *path, const char *fmt, ...)
+int tst_file_lines_scanf(const char *file, const int lineno,
+			 void (*cleanup_fn)(void), int strict,
+			 const char *path, const char *fmt, ...)
 {
 	FILE *fp;
 	int ret = 0;
@@ -209,7 +209,7 @@ int file_lines_scanf(const char *file, const int lineno,
 	return !(ret == arg_count);
 }
 
-int file_printf(const char *file, const int lineno,
+int tst_file_printf(const char *file, const int lineno,
 		      const char *path, const char *fmt, ...)
 {
 	va_list va;
diff --git a/lib/tst_assert.c b/lib/tst_assert.c
index 9b8ebc167..8c7beb2fd 100644
--- a/lib/tst_assert.c
+++ b/lib/tst_assert.c
@@ -43,7 +43,7 @@ void tst_assert_file_int(const char *file, const int lineno, const char *path, c
 	char fmt[1024];
 
 	snprintf(fmt, sizeof(fmt), "%s%%d", prefix);
-	file_lines_scanf(file, lineno, NULL, 1, path, fmt, &sys_val);
+	tst_file_lines_scanf(file, lineno, NULL, 1, path, fmt, &sys_val);
 
 	if (val == sys_val) {
 		tst_res_(file, lineno, TPASS, "%s %s = %d", path, prefix, sys_val);
@@ -72,7 +72,7 @@ void tst_assert_file_str(const char *file, const int lineno, const char *path, c
 	char fmt[2048];
 
 	snprintf(fmt, sizeof(fmt), "%s: %%1024s", prefix);
-	file_lines_scanf(file, lineno, NULL, 1, path, fmt, sys_val);
+	tst_file_lines_scanf(file, lineno, NULL, 1, path, fmt, sys_val);
 
 	if (!strcmp(val, sys_val)) {
 		tst_res_(file, lineno, TPASS, "%s %s = '%s'", path, prefix, sys_val);
diff --git a/lib/tst_sys_conf.c b/lib/tst_sys_conf.c
index 4ad9f8b9b..f604966d2 100644
--- a/lib/tst_sys_conf.c
+++ b/lib/tst_sys_conf.c
@@ -99,7 +99,7 @@ void tst_sys_conf_restore(int verbose)
 			tst_res(TINFO, "Restoring conf.: %s -> %s\n",
 				i->path, i->value);
 		}
-		FILE_PRINTF(i->path, "%s", i->value);
+		TST_FILE_PRINTF(i->path, "%s", i->value);
 	}
 }
 
diff --git a/testcases/cve/meltdown.c b/testcases/cve/meltdown.c
index a387b3205..f854b9195 100644
--- a/testcases/cve/meltdown.c
+++ b/testcases/cve/meltdown.c
@@ -261,7 +261,7 @@ find_symbol_in_file(const char *filename, const char *symname)
 
 	sprintf(fmt, "%%lx %%c %s%%c", symname);
 
-	ret = FILE_LINES_SCANF(filename, fmt, &addr, &type, &read);
+	ret = TST_FILE_LINES_SCANF(filename, fmt, &addr, &type, &read);
 	if (ret)
 		return 0;
 
diff --git a/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c b/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
index b9739db37..a5f3ce3f8 100644
--- a/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
+++ b/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
@@ -78,10 +78,10 @@ static void check_set_turbo(char *file, char *off)
 
 static void cleanup(void)
 {
-	FILE_PRINTF(cdrv[id].file, "%d", boost_value);
+	TST_FILE_PRINTF(cdrv[id].file, "%d", boost_value);
 
 	if (governor[0] != '\0')
-		FILE_PRINTF(governor, "%s", governor_name);
+		TST_FILE_PRINTF(governor, "%s", governor_name);
 }
 
 static void setup(void)
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
index 2053d0a98..f18c1a124 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
@@ -84,7 +84,7 @@ static void cleanup(void)
 		rm_shm(shm_id_arr[i]);
 
 	if (orig_shmmni != -1)
-		FILE_PRINTF(PATH_SHMMNI, "%ld", orig_shmmni);
+		TST_FILE_PRINTF(PATH_SHMMNI, "%ld", orig_shmmni);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/mem/ksm/ksm01.c b/testcases/kernel/mem/ksm/ksm01.c
index cd2c5c6ee..2d63da20b 100644
--- a/testcases/kernel/mem/ksm/ksm01.c
+++ b/testcases/kernel/mem/ksm/ksm01.c
@@ -88,8 +88,8 @@ static void setup(void)
 static void cleanup(void)
 {
 	if (access(PATH_KSM "merge_across_nodes", F_OK) == 0)
-		FILE_PRINTF(PATH_KSM "merge_across_nodes",
-				 "%d", merge_across_nodes);
+		TST_FILE_PRINTF(PATH_KSM "merge_across_nodes",
+				"%d", merge_across_nodes);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/mem/ksm/ksm02.c b/testcases/kernel/mem/ksm/ksm02.c
index 80017df66..f4595db0f 100644
--- a/testcases/kernel/mem/ksm/ksm02.c
+++ b/testcases/kernel/mem/ksm/ksm02.c
@@ -88,8 +88,8 @@ static void verify_ksm(void)
 static void cleanup(void)
 {
 	if (access(PATH_KSM "merge_across_nodes", F_OK) == 0)
-		FILE_PRINTF(PATH_KSM "merge_across_nodes",
-				 "%d", merge_across_nodes);
+		TST_FILE_PRINTF(PATH_KSM "merge_across_nodes",
+				"%d", merge_across_nodes);
 
 	tst_cgroup_cleanup();
 }
diff --git a/testcases/kernel/mem/ksm/ksm03.c b/testcases/kernel/mem/ksm/ksm03.c
index 83b821c81..f7b29b9b5 100644
--- a/testcases/kernel/mem/ksm/ksm03.c
+++ b/testcases/kernel/mem/ksm/ksm03.c
@@ -88,8 +88,8 @@ static void setup(void)
 static void cleanup(void)
 {
 	if (access(PATH_KSM "merge_across_nodes", F_OK) == 0)
-		FILE_PRINTF(PATH_KSM "merge_across_nodes",
-				 "%d", merge_across_nodes);
+		TST_FILE_PRINTF(PATH_KSM "merge_across_nodes",
+				"%d", merge_across_nodes);
 	tst_cgroup_cleanup();
 }
 
diff --git a/testcases/kernel/mem/ksm/ksm04.c b/testcases/kernel/mem/ksm/ksm04.c
index 65f7e6510..4de06e13b 100644
--- a/testcases/kernel/mem/ksm/ksm04.c
+++ b/testcases/kernel/mem/ksm/ksm04.c
@@ -87,8 +87,8 @@ static void verify_ksm(void)
 static void cleanup(void)
 {
 	if (access(PATH_KSM "merge_across_nodes", F_OK) == 0)
-		FILE_PRINTF(PATH_KSM "merge_across_nodes",
-				 "%d", merge_across_nodes);
+		TST_FILE_PRINTF(PATH_KSM "merge_across_nodes",
+				"%d", merge_across_nodes);
 
 	tst_cgroup_cleanup();
 }
diff --git a/testcases/kernel/mem/ksm/ksm05.c b/testcases/kernel/mem/ksm/ksm05.c
index 380bb0202..bc4ac9e64 100644
--- a/testcases/kernel/mem/ksm/ksm05.c
+++ b/testcases/kernel/mem/ksm/ksm05.c
@@ -99,7 +99,7 @@ static void cleanup(void)
 {
 	/* restore /sys/kernel/mm/ksm/run value */
 	if (ksm_run_orig > 0)
-		FILE_PRINTF(PATH_KSM "run", "%d", ksm_run_orig);
+		TST_FILE_PRINTF(PATH_KSM "run", "%d", ksm_run_orig);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/mem/ksm/ksm06.c b/testcases/kernel/mem/ksm/ksm06.c
index 1c435586e..b0c374de0 100644
--- a/testcases/kernel/mem/ksm/ksm06.c
+++ b/testcases/kernel/mem/ksm/ksm06.c
@@ -75,15 +75,15 @@ static void setup(void)
 static void cleanup(void)
 {
 	if (merge_across_nodes != -1) {
-		FILE_PRINTF(PATH_KSM "merge_across_nodes",
-			    "%d", merge_across_nodes);
+		TST_FILE_PRINTF(PATH_KSM "merge_across_nodes",
+				"%d", merge_across_nodes);
 	}
 
 	if (sleep_millisecs != -1)
-		FILE_PRINTF(PATH_KSM "sleep_millisecs", "%d", sleep_millisecs);
+		TST_FILE_PRINTF(PATH_KSM "sleep_millisecs", "%d", sleep_millisecs);
 
 	if (run != -1)
-		FILE_PRINTF(PATH_KSM "run", "%d", run);
+		TST_FILE_PRINTF(PATH_KSM "run", "%d", run);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/mem/swapping/swapping01.c b/testcases/kernel/mem/swapping/swapping01.c
index 66fc65cbe..49399af3e 100644
--- a/testcases/kernel/mem/swapping/swapping01.c
+++ b/testcases/kernel/mem/swapping/swapping01.c
@@ -83,7 +83,7 @@ static void test_swapping(void)
 static void init_meminfo(void)
 {
 	swap_free_init = SAFE_READ_MEMINFO("SwapFree:");
-	if (FILE_LINES_SCANF("/proc/meminfo", "MemAvailable: %ld",
+	if (TST_FILE_LINES_SCANF("/proc/meminfo", "MemAvailable: %ld",
 		&mem_available_init)) {
 		mem_available_init = SAFE_READ_MEMINFO("MemFree:")
 			+ SAFE_READ_MEMINFO("Cached:");
diff --git a/testcases/kernel/syscalls/fcntl/fcntl33.c b/testcases/kernel/syscalls/fcntl/fcntl33.c
index 8d0d1a5a1..9a90b6888 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl33.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl33.c
@@ -209,7 +209,7 @@ static void cleanup(void)
 		SAFE_CLOSE(fd);
 
 	/* Restore the lease-break-time. */
-	FILE_PRINTF(PATH_LS_BRK_T, "%d", ls_brk_t);
+	TST_FILE_PRINTF(PATH_LS_BRK_T, "%d", ls_brk_t);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/fork/fork13.c b/testcases/kernel/syscalls/fork/fork13.c
index 583c8bd4d..751166417 100644
--- a/testcases/kernel/syscalls/fork/fork13.c
+++ b/testcases/kernel/syscalls/fork/fork13.c
@@ -143,7 +143,7 @@ static void setup(void)
 static void cleanup(void)
 {
 	/* Restore pid_max value. */
-	FILE_PRINTF(PID_MAX_PATH, "%lu", pid_max);
+	TST_FILE_PRINTF(PID_MAX_PATH, "%lu", pid_max);
 }
 
 /* The distance mod PIDMAX between two pids, where the first pid is
diff --git a/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c b/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c
index 485a1c5aa..66795cf05 100644
--- a/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c
+++ b/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c
@@ -276,7 +276,7 @@ static void setup(void)
 	else if (tst_kvercmp(2, 6, 18) < 0)
 		tst_brk(TCONF, "2.6.18 or greater kernel required");
 
-	FILE_PRINTF("/proc/sys/kernel/numa_balancing", "0");
+	TST_FILE_PRINTF("/proc/sys/kernel/numa_balancing", "0");
 	/*
 	 * find 2 nodes, which can hold NODE_MIN_FREEMEM bytes
 	 * The reason is that:
diff --git a/testcases/kernel/syscalls/prctl/prctl06.c b/testcases/kernel/syscalls/prctl/prctl06.c
index 21d336c07..ad3afc49f 100644
--- a/testcases/kernel/syscalls/prctl/prctl06.c
+++ b/testcases/kernel/syscalls/prctl/prctl06.c
@@ -87,7 +87,7 @@ static void setup(void)
 	SAFE_CHOWN(BIN_PATH, 0, 0);
 	SAFE_CHMOD(BIN_PATH, SUID_MODE);
 
-	if (FILE_LINES_SCANF(PROC_STATUS, "NoNewPrivs:%d", &field)) {
+	if (TST_FILE_LINES_SCANF(PROC_STATUS, "NoNewPrivs:%d", &field)) {
 		tst_res(TCONF, "%s doesn't support NoNewPrivs field", PROC_STATUS);
 		proc_flag = 0;
 		proc_sup = "No";
diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c
index 258c70e21..6e1d99871 100644
--- a/testcases/kernel/syscalls/readahead/readahead02.c
+++ b/testcases/kernel/syscalls/readahead/readahead02.c
@@ -351,7 +351,7 @@ static void setup_readahead_length(void)
 	/* raise bdi limit as much as kernel allows */
 	ra_new_limit = testfile_size / 1024;
 	while (ra_new_limit > pagesize / 1024) {
-		FILE_PRINTF(sys_bdi_ra_path, "%d", ra_new_limit);
+		TST_FILE_PRINTF(sys_bdi_ra_path, "%d", ra_new_limit);
 		SAFE_FILE_SCANF(sys_bdi_ra_path, "%d", &ra_limit);
 
 		if (ra_limit == ra_new_limit) {
diff --git a/testcases/kernel/tracing/pt_test/pt_test.c b/testcases/kernel/tracing/pt_test/pt_test.c
index 33db6d770..4ded80585 100644
--- a/testcases/kernel/tracing/pt_test/pt_test.c
+++ b/testcases/kernel/tracing/pt_test/pt_test.c
@@ -128,11 +128,11 @@ static int is_affected_by_erratum_BDM106(void)
 {
 	int family = -1, model = -1;
 
-	if (FILE_LINES_SCANF("/proc/cpuinfo", "cpu family%*s%d", &family)
+	if (TST_FILE_LINES_SCANF("/proc/cpuinfo", "cpu family%*s%d", &family)
 		|| family != 6)
 		return 0;
 
-	if (!FILE_LINES_SCANF("/proc/cpuinfo", "model%*s%d", &model)) {
+	if (!TST_FILE_LINES_SCANF("/proc/cpuinfo", "model%*s%d", &model)) {
 		tst_res(TINFO, "Intel FAM6 model %d", model);
 
 		switch (model) {
diff --git a/testcases/network/can/filter-tests/can_common.h b/testcases/network/can/filter-tests/can_common.h
index af0cf5f00..63421849e 100644
--- a/testcases/network/can/filter-tests/can_common.h
+++ b/testcases/network/can/filter-tests/can_common.h
@@ -53,7 +53,7 @@ static void can_setup_vcan(void)
 
 check_echo:
 	SAFE_ASPRINTF(&path, "/sys/class/net/%s/flags", can_dev_name);
-	if (FILE_SCANF(path, "%x", &flags) || !(flags & IFF_ECHO)) {
+	if (TST_FILE_SCANF(path, "%x", &flags) || !(flags & IFF_ECHO)) {
 		tst_res(TWARN,
 			"Could not determine if ECHO is set on %s. This may effect code coverage.",
 			can_dev_name);
diff --git a/testcases/network/packet/fanout01.c b/testcases/network/packet/fanout01.c
index 5067d83a8..8e6a38c03 100644
--- a/testcases/network/packet/fanout01.c
+++ b/testcases/network/packet/fanout01.c
@@ -41,9 +41,9 @@ void setup(void)
 	if (TST_RET)
 		tst_brk(TBROK | TTERRNO, "Can't create new net namespace");
 
-	FILE_PRINTF("/proc/self/setgroups", "deny");
-	FILE_PRINTF("/proc/self/uid_map", "0 %d 1\n", real_uid);
-	FILE_PRINTF("/proc/self/gid_map", "0 %d 1\n", real_gid);
+	TST_FILE_PRINTF("/proc/self/setgroups", "deny");
+	TST_FILE_PRINTF("/proc/self/uid_map", "0 %d 1\n", real_uid);
+	TST_FILE_PRINTF("/proc/self/gid_map", "0 %d 1\n", real_gid);
 
 	tst_fzsync_pair_init(&pair);
 }
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 4/6] API: add tst_ to mount_overlay
  2021-05-17 16:30 [LTP] [RFC PATCH 0/6] Check exported library symbols and cleanup Richard Palethorpe
                   ` (2 preceding siblings ...)
  2021-05-17 16:30 ` [LTP] [RFC PATCH 3/6] API: Add tst_ to file_* functions Richard Palethorpe
@ 2021-05-17 16:30 ` Richard Palethorpe
  2021-05-18  8:43   ` Li Wang
  2021-05-19 15:12   ` Petr Vorel
  2021-05-17 16:30 ` [LTP] [RFC PATCH 5/6] API: Add tst_ to hugepage opt vars Richard Palethorpe
  2021-05-17 16:30 ` [LTP] [RFC PATCH 6/6] API: Check exported symbols Richard Palethorpe
  5 siblings, 2 replies; 21+ messages in thread
From: Richard Palethorpe @ 2021-05-17 16:30 UTC (permalink / raw)
  To: ltp

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 include/safe_file_ops_fn.h  | 3 +--
 include/tst_safe_file_ops.h | 4 ++--
 lib/tst_fs_setup.c          | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/include/safe_file_ops_fn.h b/include/safe_file_ops_fn.h
index 620e12e9a..e1ace0ae2 100644
--- a/include/safe_file_ops_fn.h
+++ b/include/safe_file_ops_fn.h
@@ -87,7 +87,6 @@ int safe_touch(const char *file, const int lineno,
 		mode_t mode, const struct timespec times[2]);
 
 /* helper functions to setup overlayfs mountpoint */
-void create_overlay_dirs(void);
-int mount_overlay(const char *file, const int lineno, int skip);
+int tst_mount_overlay(const char *file, const int lineno, int skip);
 
 #endif /* SAFE_FILE_OPS_FN */
diff --git a/include/tst_safe_file_ops.h b/include/tst_safe_file_ops.h
index 7457edd61..6b078b16c 100644
--- a/include/tst_safe_file_ops.h
+++ b/include/tst_safe_file_ops.h
@@ -52,9 +52,9 @@
 			(pathname), (mode), (times))
 
 #define SAFE_MOUNT_OVERLAY() \
-	((void) mount_overlay(__FILE__, __LINE__, 1))
+	((void) tst_mount_overlay(__FILE__, __LINE__, 1))
 
 #define TST_MOUNT_OVERLAY() \
-	(mount_overlay(__FILE__, __LINE__, 0) == 0)
+	(tst_mount_overlay(__FILE__, __LINE__, 0) == 0)
 
 #endif /* TST_SAFE_FILE_OPS */
diff --git a/lib/tst_fs_setup.c b/lib/tst_fs_setup.c
index b20fd06f2..8b0a343b7 100644
--- a/lib/tst_fs_setup.c
+++ b/lib/tst_fs_setup.c
@@ -24,7 +24,7 @@ static void create_overlay_dirs(void)
 	closedir(dir);
 }
 
-int mount_overlay(const char *file, const int lineno, int skip)
+int tst_mount_overlay(const char *file, const int lineno, int skip)
 {
 	int ret;
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 5/6] API: Add tst_ to hugepage opt vars
  2021-05-17 16:30 [LTP] [RFC PATCH 0/6] Check exported library symbols and cleanup Richard Palethorpe
                   ` (3 preceding siblings ...)
  2021-05-17 16:30 ` [LTP] [RFC PATCH 4/6] API: add tst_ to mount_overlay Richard Palethorpe
@ 2021-05-17 16:30 ` Richard Palethorpe
  2021-05-18  8:42   ` Li Wang
  2021-05-17 16:30 ` [LTP] [RFC PATCH 6/6] API: Check exported symbols Richard Palethorpe
  5 siblings, 1 reply; 21+ messages in thread
From: Richard Palethorpe @ 2021-05-17 16:30 UTC (permalink / raw)
  To: ltp

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 include/tst_hugepage.h                             |  4 ++--
 lib/tst_hugepage.c                                 |  8 ++++----
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c | 14 +++++++-------
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c | 14 +++++++-------
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c | 14 +++++++-------
 .../kernel/mem/hugetlb/hugeshmat/hugeshmat01.c     |  2 +-
 .../kernel/mem/hugetlb/hugeshmat/hugeshmat02.c     |  2 +-
 .../kernel/mem/hugetlb/hugeshmat/hugeshmat03.c     |  2 +-
 .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c   |  2 +-
 .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c   |  2 +-
 .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c   |  2 +-
 .../kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c     |  2 +-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget01.c   |  2 +-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget02.c   |  2 +-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget03.c   |  2 +-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget05.c   |  2 +-
 16 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/include/tst_hugepage.h b/include/tst_hugepage.h
index e08a2daa2..67104de14 100644
--- a/include/tst_hugepage.h
+++ b/include/tst_hugepage.h
@@ -9,8 +9,8 @@
 #define PATH_HUGEPAGES	"/sys/kernel/mm/hugepages/"
 #define PATH_NR_HPAGES	"/proc/sys/vm/nr_hugepages"
 
-extern char *nr_opt; /* -s num   Set the number of the been allocated hugepages */
-extern char *Hopt;   /* -H /..   Location of hugetlbfs, i.e.  -H /var/hugetlbfs */
+extern char *tst_hugepage_nr_opt; /* -s num   Set the number of the been allocated hugepages */
+extern char *tst_hugepage_Hopt;   /* -H /..   Location of hugetlbfs, i.e.  -H /var/hugetlbfs */
 
 /*
  * Get the default hugepage size. Returns 0 if hugepages are not supported.
diff --git a/lib/tst_hugepage.c b/lib/tst_hugepage.c
index 1d0e62e5b..1180beb87 100644
--- a/lib/tst_hugepage.c
+++ b/lib/tst_hugepage.c
@@ -9,8 +9,8 @@
 #include "tst_hugepage.h"
 
 unsigned long tst_hugepages;
-char *nr_opt;
-char *Hopt;
+char *tst_hugepage_nr_opt;
+char *tst_hugepage_Hopt;
 
 size_t tst_get_hugepage_size(void)
 {
@@ -29,8 +29,8 @@ unsigned long tst_request_hugepages(unsigned long hpages)
 		goto out;
 	}
 
-	if (nr_opt)
-		tst_hugepages = SAFE_STRTOL(nr_opt, 1, LONG_MAX);
+	if (tst_hugepage_nr_opt)
+		tst_hugepages = SAFE_STRTOL(tst_hugepage_nr_opt, 1, LONG_MAX);
 	else
 		tst_hugepages = hpages;
 
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
index 1783bfb12..564f6aaf3 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
@@ -74,25 +74,25 @@ void setup(void)
 	if (tst_hugepages == 0)
 		tst_brk(TCONF, "Not enough hugepages for testing.");
 
-	if (!Hopt)
-		Hopt = tst_get_tmpdir();
-	SAFE_MOUNT("none", Hopt, "hugetlbfs", 0, NULL);
+	if (!tst_hugepage_Hopt)
+		tst_hugepage_Hopt = tst_get_tmpdir();
+	SAFE_MOUNT("none", tst_hugepage_Hopt, "hugetlbfs", 0, NULL);
 
-	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d", Hopt, getpid());
+	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d", tst_hugepage_Hopt, getpid());
 }
 
 void cleanup(void)
 {
 	unlink(TEMPFILE);
-	umount(Hopt);
+	umount(tst_hugepage_Hopt);
 }
 
 static struct tst_test test = {
 	.needs_root = 1,
 	.needs_tmpdir = 1,
 	.options = (struct tst_option[]) {
-		{"H:", &Hopt,   "-H /..   Location of hugetlbfs, i.e.  -H /var/hugetlbfs"},
-		{"s:", &nr_opt, "-s num   Set the number of the been allocated hugepages"},
+		{"H:", &tst_hugepage_Hopt,   "-H /..   Location of hugetlbfs, i.e.  -H /var/hugetlbfs"},
+		{"s:", &tst_hugepage_nr_opt, "-s num   Set the number of the been allocated hugepages"},
 		{}
 	},
 	.setup = setup,
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
index 0b27154af..df1f27419 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
@@ -121,25 +121,25 @@ static void setup(void)
 	if (tst_hugepages == 0)
 		tst_brk(TCONF, "Not enough hugepages for testing.");
 
-	if (!Hopt)
-		Hopt = tst_get_tmpdir();
-	SAFE_MOUNT("none", Hopt, "hugetlbfs", 0, NULL);
+	if (!tst_hugepage_Hopt)
+		tst_hugepage_Hopt = tst_get_tmpdir();
+	SAFE_MOUNT("none", tst_hugepage_Hopt, "hugetlbfs", 0, NULL);
 
-	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d", Hopt, getpid());
+	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d", tst_hugepage_Hopt, getpid());
 }
 
 static void cleanup(void)
 {
 	unlink(TEMPFILE);
-	umount(Hopt);
+	umount(tst_hugepage_Hopt);
 }
 
 static struct tst_test test = {
 	.needs_root = 1,
 	.needs_tmpdir = 1,
 	.options = (struct tst_option[]) {
-		{"H:", &Hopt,   "-H /..   Location of hugetlbfs, i.e.  -H /var/hugetlbfs"},
-		{"s:", &nr_opt, "-s num   Set the number of the been allocated hugepages"},
+		{"H:", &tst_hugepage_Hopt,   "-H /..   Location of hugetlbfs, i.e.  -H /var/hugetlbfs"},
+		{"s:", &tst_hugepage_nr_opt, "-s num   Set the number of the been allocated hugepages"},
 		{}
 	},
 	.setup = setup,
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c
index f63b41f28..12d7705fd 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c
@@ -92,25 +92,25 @@ void setup(void)
 	if (tst_hugepages == 0)
 		tst_brk(TCONF, "Not enough hugepages for testing!");
 
-	if (!Hopt)
-		Hopt = tst_get_tmpdir();
-	SAFE_MOUNT("none", Hopt, "hugetlbfs", 0, NULL);
+	if (!tst_hugepage_Hopt)
+		tst_hugepage_Hopt = tst_get_tmpdir();
+	SAFE_MOUNT("none", tst_hugepage_Hopt, "hugetlbfs", 0, NULL);
 
-	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d", Hopt, getpid());
+	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d", tst_hugepage_Hopt, getpid());
 }
 
 void cleanup(void)
 {
 	unlink(TEMPFILE);
-	umount(Hopt);
+	umount(tst_hugepage_Hopt);
 }
 
 static struct tst_test test = {
 	.needs_root = 1,
 	.needs_tmpdir = 1,
 	.options = (struct tst_option[]) {
-		{"H:", &Hopt,   "-H /..   Location of hugetlbfs, i.e.  -H /var/hugetlbfs"},
-		{"s:", &nr_opt, "-s num   Set the number of the been allocated hugepages"},
+		{"H:", &tst_hugepage_Hopt,   "-H /..   Location of hugetlbfs, i.e.  -H /var/hugetlbfs"},
+		{"s:", &tst_hugepage_nr_opt, "-s num   Set the number of the been allocated hugepages"},
 		{}
 	},
 	.setup = setup,
diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c
index f206522c0..f6235f8eb 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c
@@ -173,7 +173,7 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.needs_tmpdir = 1,
 	.options = (struct tst_option[]) {
-		{"s:", &nr_opt, "-s num   Set the number of the been allocated hugepages"},
+		{"s:", &tst_hugepage_nr_opt, "-s num   Set the number of the been allocated hugepages"},
 		{}
 	},
 	.tcnt = ARRAY_SIZE(tcases),
diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c
index fcad8f5d9..739b29c43 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c
@@ -100,7 +100,7 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.needs_tmpdir = 1,
 	.options = (struct tst_option[]) {
-		{"s:", &nr_opt, "-s num   Set the number of the been allocated hugepages"},
+		{"s:", &tst_hugepage_nr_opt, "-s num   Set the number of the been allocated hugepages"},
 		{}
 	},
 	.tcnt = ARRAY_SIZE(tcases),
diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat03.c b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat03.c
index 1f1d2613a..4e20434f1 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat03.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat03.c
@@ -95,7 +95,7 @@ static struct tst_test test = {
 	.forks_child = 1,
 	.needs_tmpdir = 1,
 	.options = (struct tst_option[]) {
-		{"s:", &nr_opt, "-s num   Set the number of the been allocated hugepages"},
+		{"s:", &tst_hugepage_nr_opt, "-s num   Set the number of the been allocated hugepages"},
 		{}
 	},
 	.test_all = verify_hugeshmat,
diff --git a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c
index b5b5496fd..45157fc6f 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c
@@ -303,7 +303,7 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.forks_child = 1,
 	.options = (struct tst_option[]) {
-		{"s:", &nr_opt, "-s num   Set the number of the been allocated hugepages"},
+		{"s:", &tst_hugepage_nr_opt, "-s num   Set the number of the been allocated hugepages"},
 		{}
 	},
 	.setup = setup,
diff --git a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c
index e014edd94..ed819e949 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c
@@ -105,7 +105,7 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.needs_tmpdir = 1,
 	.options = (struct tst_option[]) {
-		{"s:", &nr_opt, "-s num   Set the number of the been allocated hugepages"},
+		{"s:", &tst_hugepage_nr_opt, "-s num   Set the number of the been allocated hugepages"},
 		{}
 	},
 	.setup = setup,
diff --git a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c
index 8c485810d..3c35efc4b 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c
@@ -128,7 +128,7 @@ static struct tst_test test = {
 	.forks_child = 1,
 	.needs_tmpdir = 1,
 	.options = (struct tst_option[]) {
-		{"s:", &nr_opt, "-s num   Set the number of the been allocated hugepages"},
+		{"s:", &tst_hugepage_nr_opt, "-s num   Set the number of the been allocated hugepages"},
 		{}
 	},
 	.setup = setup,
diff --git a/testcases/kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c b/testcases/kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c
index 571a4cf10..c6641d041 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c
@@ -146,7 +146,7 @@ void cleanup(void)
 static struct tst_test test = {
 	.needs_root = 1,
 	.options = (struct tst_option[]) {
-		{"s:", &nr_opt, "-s num   Set the number of the been allocated hugepages"},
+		{"s:", &tst_hugepage_nr_opt, "-s num   Set the number of the been allocated hugepages"},
 		{}
 	},
 	.setup = setup,
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
index 470563653..a161a1da0 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
@@ -72,7 +72,7 @@ static void cleanup(void)
 static struct tst_test test = {
 	.needs_root = 1,
 	.options = (struct tst_option[]) {
-		{"s:", &nr_opt, "-s num   Set the number of the been allocated hugepages"},
+		{"s:", &tst_hugepage_nr_opt, "-s num   Set the number of the been allocated hugepages"},
 		{}
 	},
 	.setup = setup,
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c
index 323b5d6d1..d102b8f40 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c
@@ -91,7 +91,7 @@ void cleanup(void)
 static struct tst_test test = {
 	.needs_root = 1,
 	.options = (struct tst_option[]) {
-		{"s:", &nr_opt, "-s num   Set the number of the been allocated hugepages"},
+		{"s:", &tst_hugepage_nr_opt, "-s num   Set the number of the been allocated hugepages"},
 		{}
 	},
 	.setup = setup,
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
index f18c1a124..0b1e2fcd0 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
@@ -90,7 +90,7 @@ static void cleanup(void)
 static struct tst_test test = {
 	.needs_root = 1,
 	.options = (struct tst_option[]) {
-		{"s:", &nr_opt, "-s num   Set the number of the been allocated hugepages"},
+		{"s:", &tst_hugepage_nr_opt, "-s num   Set the number of the been allocated hugepages"},
 		{}
 	},
 	.setup = setup,
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c
index 60c86455c..4452f97e3 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c
@@ -86,7 +86,7 @@ void cleanup(void)
 static struct tst_test test = {
 	.needs_root = 1,
 	.options = (struct tst_option[]) {
-		{"s:", &nr_opt, "-s num   Set the number of the been allocated hugepages"},
+		{"s:", &tst_hugepage_nr_opt, "-s num   Set the number of the been allocated hugepages"},
 		{}
 	},
 	.setup = setup,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 6/6] API: Check exported symbols
  2021-05-17 16:30 [LTP] [RFC PATCH 0/6] Check exported library symbols and cleanup Richard Palethorpe
                   ` (4 preceding siblings ...)
  2021-05-17 16:30 ` [LTP] [RFC PATCH 5/6] API: Add tst_ to hugepage opt vars Richard Palethorpe
@ 2021-05-17 16:30 ` Richard Palethorpe
  2021-05-18  8:18   ` Petr Vorel
  5 siblings, 1 reply; 21+ messages in thread
From: Richard Palethorpe @ 2021-05-17 16:30 UTC (permalink / raw)
  To: ltp

Abort the build process if a new symbol is exported from the library
without tst_ or safe_ prepended.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 lib/Makefile                 | 12 +++++++
 scripts/check_export_syms.sh | 64 ++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)
 create mode 100755 scripts/check_export_syms.sh

diff --git a/lib/Makefile b/lib/Makefile
index f019432e8..76ef49a3e 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -42,5 +42,17 @@ $(pc_file):
 	test -d "$(@D)" || mkdir -p "$(@D)"
 	install -m $(INSTALL_MODE) "$(builddir)/$(@F)" "$@"
 
+CHECK_LIB ?= $(top_srcdir)/scripts/check_export_syms.sh
+.PHONY: check_lib
+check_lib: libltp.a
+ifdef VERBOSE
+	$(CHECK_LIB) $<
+else
+	@echo CHECK_LIB $<
+	@$(CHECK_LIB) $<
+endif
+
+MAKE_TARGETS		+= check_lib
+
 include $(top_srcdir)/include/mk/lib.mk
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/scripts/check_export_syms.sh b/scripts/check_export_syms.sh
new file mode 100755
index 000000000..d573ed946
--- /dev/null
+++ b/scripts/check_export_syms.sh
@@ -0,0 +1,64 @@
+#!/bin/sh -eu
+# Check the exported symbols from an object file or archive
+
+obj_file=$1
+
+non_prefix_syms() {
+    nm $obj_file --defined-only -o -g -l | \
+	awk -F ' ' "\$3 !~ /tst_|safe_|ltp_/ { print }"
+}
+
+ignore_list=$(tr -d '\n' <<EOF
+parse_opts|
+STD_LOOP_COUNT|
+usc_global_setup_hook|
+usc_test_looping|
+parse_ranges|
+random_bit|
+random_range|
+random_rangel|
+random_rangell|
+random_range_seed|
+range_max|
+range_min|
+range_mult|
+lio_check_asyncio|
+lio_help1|
+lio_help2|
+Lio_info1|
+Lio_info2|
+lio_parse_io_arg1|
+lio_parse_io_arg2|
+lio_random_methods|
+lio_read_buffer|
+lio_set_debug|
+Lio_SysCall|
+lio_wait4asyncio|
+lio_write_buffer|
+stride_bounds|
+TEST_ERRNO|
+TEST_RETURN|
+TST_RET_PTR|
+TCID|
+TST_ERR|
+TST_PASS|
+TST_RET
+EOF
+)
+
+ignore_regex="\$3 !~ /$ignore_list/"
+fmt_error_statement=$(cat <<"EOF"
+{
+  ("basename " $4) | getline cfile
+  print "ERROR: lib symbol exported without tst_ or safe_: " cfile"::"$3
+  failed = 1
+}
+END {
+  if (failed == 1) {
+      exit(1)
+  }
+}
+EOF
+)
+
+non_prefix_syms | awk -F ' ' "$ignore_regex $fmt_error_statement"
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 1/6] API: Make some internal symbols static
  2021-05-17 16:30 ` [LTP] [RFC PATCH 1/6] API: Make some internal symbols static Richard Palethorpe
@ 2021-05-18  7:57   ` Petr Vorel
  0 siblings, 0 replies; 21+ messages in thread
From: Petr Vorel @ 2021-05-18  7:57 UTC (permalink / raw)
  To: ltp

Hi Richie,

> These do not appear to be referenced anywhere outside the library.

> diff --git a/include/old/test.h b/include/old/test.h
> index 2ae7dba71..a8994c08e 100644
> --- a/include/old/test.h
> +++ b/include/old/test.h
> @@ -113,7 +113,6 @@ void tst_parse_opts(int argc, char *argv[], const option_t *user_optarg,
>                      void (*user_help)(void));

>  /* lib/tst_res.c */
> -const char *strttype(int ttype);

I would not touch legacy API, but this looks to be safe.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 6/6] API: Check exported symbols
  2021-05-17 16:30 ` [LTP] [RFC PATCH 6/6] API: Check exported symbols Richard Palethorpe
@ 2021-05-18  8:18   ` Petr Vorel
  2021-05-18  9:57     ` Richard Palethorpe
  0 siblings, 1 reply; 21+ messages in thread
From: Petr Vorel @ 2021-05-18  8:18 UTC (permalink / raw)
  To: ltp

Hi Richie,

> Abort the build process if a new symbol is exported from the library
> without tst_ or safe_ prepended.

The PR does not work few on old toolchains [1], it fails on [2]:

awk: line 1: regular expression /parse_opts ... exceeds implementation size limit

It's one of the 2 awk calls in check_export_syms.sh, I suppose the other one.
Maybe put non_prefix_syms into temporary file and then run awk on it?

Kind regards,
Petr

[1] https://travis-ci.org/github/pevik/ltp/builds/771465129
[2] https://travis-ci.org/github/pevik/ltp/jobs/771465135#L3115

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 5/6] API: Add tst_ to hugepage opt vars
  2021-05-17 16:30 ` [LTP] [RFC PATCH 5/6] API: Add tst_ to hugepage opt vars Richard Palethorpe
@ 2021-05-18  8:42   ` Li Wang
  0 siblings, 0 replies; 21+ messages in thread
From: Li Wang @ 2021-05-18  8:42 UTC (permalink / raw)
  To: ltp

On Tue, May 18, 2021 at 12:32 AM Richard Palethorpe via ltp
<ltp@lists.linux.it> wrote:
>
> Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>

Reviewed-by: Li Wang <liwang@redhat.com>

-- 
Regards,
Li Wang


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 4/6] API: add tst_ to mount_overlay
  2021-05-17 16:30 ` [LTP] [RFC PATCH 4/6] API: add tst_ to mount_overlay Richard Palethorpe
@ 2021-05-18  8:43   ` Li Wang
  2021-05-19 15:12   ` Petr Vorel
  1 sibling, 0 replies; 21+ messages in thread
From: Li Wang @ 2021-05-18  8:43 UTC (permalink / raw)
  To: ltp

On Tue, May 18, 2021 at 12:31 AM Richard Palethorpe via ltp
<ltp@lists.linux.it> wrote:
>
> Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>

Reviewed-by: Li Wang <liwang@redhat.com>

-- 
Regards,
Li Wang


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 2/6] API: Add tst_ to create_sig_proc
  2021-05-17 16:30 ` [LTP] [RFC PATCH 2/6] API: Add tst_ to create_sig_proc Richard Palethorpe
@ 2021-05-18  9:16   ` Li Wang
  2021-05-19 15:13   ` Petr Vorel
  1 sibling, 0 replies; 21+ messages in thread
From: Li Wang @ 2021-05-18  9:16 UTC (permalink / raw)
  To: ltp

On Tue, May 18, 2021 at 12:31 AM Richard Palethorpe via ltp
<ltp@lists.linux.it> wrote:
>
> Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
Reviewed-by: Li Wang <liwang@redhat.com>

--
Regards,
Li Wang


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 3/6] API: Add tst_ to file_* functions
  2021-05-17 16:30 ` [LTP] [RFC PATCH 3/6] API: Add tst_ to file_* functions Richard Palethorpe
@ 2021-05-18  9:23   ` Li Wang
  2021-05-19 15:11   ` Petr Vorel
  1 sibling, 0 replies; 21+ messages in thread
From: Li Wang @ 2021-05-18  9:23 UTC (permalink / raw)
  To: ltp

On Tue, May 18, 2021 at 12:31 AM Richard Palethorpe via ltp
<ltp@lists.linux.it> wrote:
>
> Usually LTP library functions are prepended with tst_ if not with
> safe_.

I'm not very sure if FILE_PRINTF should be added with TST_ prefix, but
it seems no harm to do that.

So I just hold a neutral view on this patch:).

-- 
Regards,
Li Wang


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 6/6] API: Check exported symbols
  2021-05-18  8:18   ` Petr Vorel
@ 2021-05-18  9:57     ` Richard Palethorpe
  2021-05-18 14:57       ` Petr Vorel
  0 siblings, 1 reply; 21+ messages in thread
From: Richard Palethorpe @ 2021-05-18  9:57 UTC (permalink / raw)
  To: ltp

Hello Petr,

Petr Vorel <pvorel@suse.cz> writes:

> Hi Richie,
>
>> Abort the build process if a new symbol is exported from the library
>> without tst_ or safe_ prepended.
>
> The PR does not work few on old toolchains [1], it fails on [2]:
>
> awk: line 1: regular expression /parse_opts ... exceeds implementation size limit
>
> It's one of the 2 awk calls in check_export_syms.sh, I suppose the other one.
> Maybe put non_prefix_syms into temporary file and then run awk on it?

I doubt it will help, it seems the ignore regex is too long. I'm not
sure we need the script to run on old toolchains though.

Maybe we need a development mode configure flag?

>
> Kind regards,
> Petr
>
> [1] https://travis-ci.org/github/pevik/ltp/builds/771465129
> [2] https://travis-ci.org/github/pevik/ltp/jobs/771465135#L3115


-- 
Thank you,
Richard.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 6/6] API: Check exported symbols
  2021-05-18  9:57     ` Richard Palethorpe
@ 2021-05-18 14:57       ` Petr Vorel
  2021-05-19  9:11         ` Richard Palethorpe
  0 siblings, 1 reply; 21+ messages in thread
From: Petr Vorel @ 2021-05-18 14:57 UTC (permalink / raw)
  To: ltp

Hi Richie,

> Hello Petr,

> Petr Vorel <pvorel@suse.cz> writes:

> > Hi Richie,

> >> Abort the build process if a new symbol is exported from the library
> >> without tst_ or safe_ prepended.

> > The PR does not work few on old toolchains [1], it fails on [2]:

> > awk: line 1: regular expression /parse_opts ... exceeds implementation size limit

> > It's one of the 2 awk calls in check_export_syms.sh, I suppose the other one.
> > Maybe put non_prefix_syms into temporary file and then run awk on it?

> I doubt it will help, it seems the ignore regex is too long. I'm not
> sure we need the script to run on old toolchains though.

> Maybe we need a development mode configure flag?

I'll have a look into it, as I'd prefer to be fixed
(than repeat people on mailing list that this does not work on older distros).
It's actually only on Debian stable or older.

Kind regards,
Petr

> > Kind regards,
> > Petr

> > [1] https://travis-ci.org/github/pevik/ltp/builds/771465129
> > [2] https://travis-ci.org/github/pevik/ltp/jobs/771465135#L3115

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 6/6] API: Check exported symbols
  2021-05-18 14:57       ` Petr Vorel
@ 2021-05-19  9:11         ` Richard Palethorpe
  2021-05-19 12:02           ` Cyril Hrubis
  0 siblings, 1 reply; 21+ messages in thread
From: Richard Palethorpe @ 2021-05-19  9:11 UTC (permalink / raw)
  To: ltp

Hello,

Petr Vorel <pvorel@suse.cz> writes:

> Hi Richie,
>
>> Hello Petr,
>
>> Petr Vorel <pvorel@suse.cz> writes:
>
>> > Hi Richie,
>
>> >> Abort the build process if a new symbol is exported from the library
>> >> without tst_ or safe_ prepended.
>
>> > The PR does not work few on old toolchains [1], it fails on [2]:
>
>> > awk: line 1: regular expression /parse_opts ... exceeds implementation size limit
>
>> > It's one of the 2 awk calls in check_export_syms.sh, I suppose the other one.
>> > Maybe put non_prefix_syms into temporary file and then run awk on it?
>
>> I doubt it will help, it seems the ignore regex is too long. I'm not
>> sure we need the script to run on old toolchains though.
>
>> Maybe we need a development mode configure flag?
>
> I'll have a look into it, as I'd prefer to be fixed
> (than repeat people on mailing list that this does not work on older distros).
> It's actually only on Debian stable or older.

OK, I guess you can just shorten the regex by substituing "[lL]io_\w+"
for all the lio stuff. Or filter by file instead.

>
> Kind regards,
> Petr
>
>> > Kind regards,
>> > Petr
>
>> > [1] https://travis-ci.org/github/pevik/ltp/builds/771465129
>> > [2] https://travis-ci.org/github/pevik/ltp/jobs/771465135#L3115


-- 
Thank you,
Richard.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 6/6] API: Check exported symbols
  2021-05-19  9:11         ` Richard Palethorpe
@ 2021-05-19 12:02           ` Cyril Hrubis
  2021-05-19 15:10             ` Petr Vorel
  0 siblings, 1 reply; 21+ messages in thread
From: Cyril Hrubis @ 2021-05-19 12:02 UTC (permalink / raw)
  To: ltp

Hi!
> OK, I guess you can just shorten the regex by substituing "[lL]io_\w+"
> for all the lio stuff. Or filter by file instead.

Another option would be moving the tlibio.c and random_range.c to
libs/libltpobsolete/ and adding LTPLIBS flags for the few tests that
actually use that code.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 6/6] API: Check exported symbols
  2021-05-19 12:02           ` Cyril Hrubis
@ 2021-05-19 15:10             ` Petr Vorel
  0 siblings, 0 replies; 21+ messages in thread
From: Petr Vorel @ 2021-05-19 15:10 UTC (permalink / raw)
  To: ltp

Hi Cyril, Richie,

> Hi!
> > OK, I guess you can just shorten the regex by substituing "[lL]io_\w+"
> > for all the lio stuff. Or filter by file instead.

> Another option would be moving the tlibio.c and random_range.c to
> libs/libltpobsolete/ and adding LTPLIBS flags for the few tests that
> actually use that code.

Thank you both for tips, both ways would work for me.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 3/6] API: Add tst_ to file_* functions
  2021-05-17 16:30 ` [LTP] [RFC PATCH 3/6] API: Add tst_ to file_* functions Richard Palethorpe
  2021-05-18  9:23   ` Li Wang
@ 2021-05-19 15:11   ` Petr Vorel
  1 sibling, 0 replies; 21+ messages in thread
From: Petr Vorel @ 2021-05-19 15:11 UTC (permalink / raw)
  To: ltp

Hi Richie,

> Usually LTP library functions are prepended with tst_ if not with
> safe_.

LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 4/6] API: add tst_ to mount_overlay
  2021-05-17 16:30 ` [LTP] [RFC PATCH 4/6] API: add tst_ to mount_overlay Richard Palethorpe
  2021-05-18  8:43   ` Li Wang
@ 2021-05-19 15:12   ` Petr Vorel
  1 sibling, 0 replies; 21+ messages in thread
From: Petr Vorel @ 2021-05-19 15:12 UTC (permalink / raw)
  To: ltp

Hi Richie,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [RFC PATCH 2/6] API: Add tst_ to create_sig_proc
  2021-05-17 16:30 ` [LTP] [RFC PATCH 2/6] API: Add tst_ to create_sig_proc Richard Palethorpe
  2021-05-18  9:16   ` Li Wang
@ 2021-05-19 15:13   ` Petr Vorel
  1 sibling, 0 replies; 21+ messages in thread
From: Petr Vorel @ 2021-05-19 15:13 UTC (permalink / raw)
  To: ltp

Hi Richie,

also this one is obviously ok, thanks!
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-05-19 15:13 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 16:30 [LTP] [RFC PATCH 0/6] Check exported library symbols and cleanup Richard Palethorpe
2021-05-17 16:30 ` [LTP] [RFC PATCH 1/6] API: Make some internal symbols static Richard Palethorpe
2021-05-18  7:57   ` Petr Vorel
2021-05-17 16:30 ` [LTP] [RFC PATCH 2/6] API: Add tst_ to create_sig_proc Richard Palethorpe
2021-05-18  9:16   ` Li Wang
2021-05-19 15:13   ` Petr Vorel
2021-05-17 16:30 ` [LTP] [RFC PATCH 3/6] API: Add tst_ to file_* functions Richard Palethorpe
2021-05-18  9:23   ` Li Wang
2021-05-19 15:11   ` Petr Vorel
2021-05-17 16:30 ` [LTP] [RFC PATCH 4/6] API: add tst_ to mount_overlay Richard Palethorpe
2021-05-18  8:43   ` Li Wang
2021-05-19 15:12   ` Petr Vorel
2021-05-17 16:30 ` [LTP] [RFC PATCH 5/6] API: Add tst_ to hugepage opt vars Richard Palethorpe
2021-05-18  8:42   ` Li Wang
2021-05-17 16:30 ` [LTP] [RFC PATCH 6/6] API: Check exported symbols Richard Palethorpe
2021-05-18  8:18   ` Petr Vorel
2021-05-18  9:57     ` Richard Palethorpe
2021-05-18 14:57       ` Petr Vorel
2021-05-19  9:11         ` Richard Palethorpe
2021-05-19 12:02           ` Cyril Hrubis
2021-05-19 15:10             ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.