public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/2] Create tst_tmpdir.h
@ 2024-06-21 10:59 Petr Vorel
  2024-06-21 10:59 ` [LTP] [PATCH v2 1/2] tst_tmpdir: Remove NULL from static Petr Vorel
  2024-06-21 10:59 ` [LTP] [PATCH v2 2/2] lib: Create tst_tmpdir.h Petr Vorel
  0 siblings, 2 replies; 4+ messages in thread
From: Petr Vorel @ 2024-06-21 10:59 UTC (permalink / raw)
  To: ltp

Changes v1->v2:
* Use proper kerneldoc comment (Cyril)
* Add the header to readthedocs docs

Petr Vorel (2):
  tst_tmpdir: Remove NULL from static
  lib: Create tst_tmpdir.h

 doc/developers/api_c_tests.rst |  4 ++++
 include/tst_device.h           |  6 +-----
 include/tst_tmpdir.h           | 19 +++++++++++++++++++
 lib/tst_tmpdir.c               |  3 ++-
 4 files changed, 26 insertions(+), 6 deletions(-)
 create mode 100644 include/tst_tmpdir.h

-- 
2.45.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH v2 1/2] tst_tmpdir: Remove NULL from static
  2024-06-21 10:59 [LTP] [PATCH v2 0/2] Create tst_tmpdir.h Petr Vorel
@ 2024-06-21 10:59 ` Petr Vorel
  2024-06-21 10:59 ` [LTP] [PATCH v2 2/2] lib: Create tst_tmpdir.h Petr Vorel
  1 sibling, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2024-06-21 10:59 UTC (permalink / raw)
  To: ltp

Not needed, reported by checkpatch.pl.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
The same as in v1.

Trivial change, but better to be acked in case I overlook something.

 lib/tst_tmpdir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/tst_tmpdir.c b/lib/tst_tmpdir.c
index b73b5c66f..bcc788390 100644
--- a/lib/tst_tmpdir.c
+++ b/lib/tst_tmpdir.c
@@ -92,7 +92,7 @@
  * Define global variables.
  */
 extern char *TCID;		/* defined/initialized in main() */
-static char *TESTDIR = NULL;	/* the directory created */
+static char *TESTDIR;	/* the directory created */
 
 static char test_start_work_dir[PATH_MAX];
 
-- 
2.45.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH v2 2/2] lib: Create tst_tmpdir.h
  2024-06-21 10:59 [LTP] [PATCH v2 0/2] Create tst_tmpdir.h Petr Vorel
  2024-06-21 10:59 ` [LTP] [PATCH v2 1/2] tst_tmpdir: Remove NULL from static Petr Vorel
@ 2024-06-21 10:59 ` Petr Vorel
  2024-06-25 15:11   ` Avinesh Kumar
  1 sibling, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2024-06-21 10:59 UTC (permalink / raw)
  To: ltp

This fixes our sparse warning:

tst_tmpdir.c:347:6: warning: Symbol 'tst_purge_dir' has no prototype or
library ('tst_') prefix. Should it be static?

Also add header into our readthedocs docs (C API section).

Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Changes v1->v2:
* Use proper kerneldoc comment (Cyril)
* Add the header to readthedocs docs

 doc/developers/api_c_tests.rst |  4 ++++
 include/tst_device.h           |  6 +-----
 include/tst_tmpdir.h           | 19 +++++++++++++++++++
 lib/tst_tmpdir.c               |  1 +
 4 files changed, 25 insertions(+), 5 deletions(-)
 create mode 100644 include/tst_tmpdir.h

diff --git a/doc/developers/api_c_tests.rst b/doc/developers/api_c_tests.rst
index 164f82504..74185c29e 100644
--- a/doc/developers/api_c_tests.rst
+++ b/doc/developers/api_c_tests.rst
@@ -37,3 +37,7 @@ Capabilities
 libltpswap
 ----------
 .. kernel-doc:: ../../include/libswap.h
+
+Temporary directory
+-------------------
+.. kernel-doc:: ../../include/tst_tmpdir.h
diff --git a/include/tst_device.h b/include/tst_device.h
index 36258f436..391fb4e56 100644
--- a/include/tst_device.h
+++ b/include/tst_device.h
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) 2016-2019 Cyril Hrubis <chrubis@suse.cz>
+ * Copyright (c) Linux Test Project, 2019-2024
  */
 
 #ifndef TST_DEVICE_H__
@@ -101,11 +102,6 @@ int tst_dev_sync(int fd);
  */
 unsigned long tst_dev_bytes_written(const char *dev);
 
-/*
- * Wipe the contents of given directory but keep the directory itself
- */
-void tst_purge_dir(const char *path);
-
 /*
  * Find the file or path belongs to which block dev
  * @path       Path to find the backing dev
diff --git a/include/tst_tmpdir.h b/include/tst_tmpdir.h
new file mode 100644
index 000000000..e6c5d962c
--- /dev/null
+++ b/include/tst_tmpdir.h
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
+ * Copyright (c) 2020 Martin Doucha <mdoucha@suse.cz>
+ */
+
+#ifndef TST_TMPDIR_H__
+#define TST_TMPDIR_H__
+
+/**
+ * tst_purge_dir - Wipe the content of given directory.
+ *
+ * Wipe the content of given directory but keep the directory itself.
+ *
+ * @path: Path of the directory to be wiped.
+ */
+void tst_purge_dir(const char *path);
+
+#endif /* TST_TMPDIR_H__ */
diff --git a/lib/tst_tmpdir.c b/lib/tst_tmpdir.c
index bcc788390..0f1b15ca4 100644
--- a/lib/tst_tmpdir.c
+++ b/lib/tst_tmpdir.c
@@ -72,6 +72,7 @@
 
 #include "test.h"
 #include "safe_macros.h"
+#include "tst_tmpdir.h"
 #include "ltp_priv.h"
 #include "lapi/futex.h"
 
-- 
2.45.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH v2 2/2] lib: Create tst_tmpdir.h
  2024-06-21 10:59 ` [LTP] [PATCH v2 2/2] lib: Create tst_tmpdir.h Petr Vorel
@ 2024-06-25 15:11   ` Avinesh Kumar
  0 siblings, 0 replies; 4+ messages in thread
From: Avinesh Kumar @ 2024-06-25 15:11 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi Petr,

...
> diff --git a/lib/tst_tmpdir.c b/lib/tst_tmpdir.c
> index bcc788390..0f1b15ca4 100644
> --- a/lib/tst_tmpdir.c
> +++ b/lib/tst_tmpdir.c
> @@ -72,6 +72,7 @@
>  
>  #include "test.h"
>  #include "safe_macros.h"
> +#include "tst_tmpdir.h"
>  #include "ltp_priv.h"
>  #include "lapi/futex.h"
>  

I think we also need to include tst_tmpdir.h in tst_test.h, else we are
introducing implicit declaration warning in all tests where we use
tst_purge_dir() function.
e.g. creat08.c

creat08.c: In function ‘run’:
creat08.c:128:9: warning: implicit declaration of function ‘tst_purge_dir’ [-Wimplicit-function-declaration]
  128 |         tst_purge_dir(tmpdir);
      |         ^~~~~~~~~~~~~
CC testcases/kernel/syscalls/creat/creat08

> 


Regards,
Avinesh




-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2024-06-25 15:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-21 10:59 [LTP] [PATCH v2 0/2] Create tst_tmpdir.h Petr Vorel
2024-06-21 10:59 ` [LTP] [PATCH v2 1/2] tst_tmpdir: Remove NULL from static Petr Vorel
2024-06-21 10:59 ` [LTP] [PATCH v2 2/2] lib: Create tst_tmpdir.h Petr Vorel
2024-06-25 15:11   ` Avinesh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox