Skip to contentSkip to conversation

Minor fixes for tst_device

PATCH In review Cyril Hrubis 2 participants 6 messages Mar 28, 2023 – Mar 29, 2023 Library code

lore
Share & tools
lore
#0 lore raw

cover Minor fixes for tst_device

Cyril Hrubis (4):
lib: include tst_device.h in tst_device.c
lib: tst_device: Make find_stat_file() static
lib: tst_device: Switch to SPDX
lib: tst_device: Constify array members

 include/tst_device.h |  2 +-
 lib/tst_device.c     | 27 +++++----------------------
 2 files changed, 6 insertions(+), 23 deletions(-)
Signature · 5 lines
2.39.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH 1/4 lib: include tst_device.h in tst_device.c

+ Fix broken function prototype

---
 include/tst_device.h | 2 +-
 lib/tst_device.c     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
include/tst_device.h +1 -1
index 39545fab0..36258f436 100644
@@ -49,7 +49,7 @@ int tst_clear_device(const char *dev);
  * free loopdev). If path is non-NULL, it will be filled with free loopdev path.
  *
  */
-int tst_find_free_loopdev(const char *path, size_t path_len);
+int tst_find_free_loopdev(char *path, size_t path_len);
 
 /*
  * Attaches a file to a loop device.
lib/tst_device.c +1 -0
index 892e0b2e6..0cdd8985e 100644
@@ -38,6 +38,7 @@
 #include "lapi/syscalls.h"
 #include "test.h"
 #include "safe_macros.h"
+#include "tst_device.h"
 
 #ifndef LOOP_CTL_GET_FREE
 # define LOOP_CTL_GET_FREE 0x4C82
Signature · 5 lines
2.39.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

PATCH 2/4 lib: tst_device: Make find_stat_file() static

In reply to Cyril Hrubis

tst_device.c:486:5: warning: LTP-003: Symbol 'find_stat_file' is a public library function, but is missing the 'tst_' prefix

---
 lib/tst_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tst_device.c +1 -1
index 0cdd8985e..1f5a95eb9 100644
@@ -483,7 +483,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;
 
Signature · 5 lines
2.39.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

PATCH 3/4 lib: tst_device: Switch to SPDX

In reply to Cyril Hrubis

Note that the original was GPL-2.0 but that was mistake on my side, I should have added GPL-2.0-or-later from the start.

---
 lib/tst_device.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)
lib/tst_device.c +1 -19
index 1f5a95eb9..a4dfda5ba 100644
@@ -1,24 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (C) 2014 Cyril Hrubis [email protected]
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #include <sys/types.h>
Signature · 5 lines
2.39.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

PATCH 4/4 lib: tst_device: Constify array members

In reply to Cyril Hrubis

tst_device.c:40: WARNING: static const char * array should probably be static const char * const tst_device.c:46: WARNING: static const char * array should probably be static const char * const

---
 lib/tst_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/tst_device.c +2 -2
index a4dfda5ba..d659b54cf 100644
@@ -37,13 +37,13 @@ static char dev_path[PATH_MAX];
 static int device_acquired;
 static unsigned long prev_dev_sec_write;
 
-static const char *dev_loop_variants[] = {
+static const char * const dev_loop_variants[] = {
 	"/dev/loop%i",
 	"/dev/loop/%i",
 	"/dev/block/loop%i"
 };
 
-static const char *dev_variants[] = {
+static const char * const dev_variants[] = {
 	"/dev/%s",
 	"/dev/block/%s"
 };
Signature · 5 lines
2.39.2


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