[LTP] [PATCH v4 1/3] syscalls/f{get, set}xattr: Don't pass a pointer to mode argument in open
Tudor Cretu
tudor.cretu@arm.com
Wed Nov 30 16:07:36 CET 2022
Passing NULL to open as the mode parameter is undefined behaviour
as a mode_t is a numerical type, not compatible with a pointer type.
If neither O_CREAT nor O_TMPFILE is specified in flags, then the mode
argument is ignored, so just remove it in these cases.
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Tudor Cretu <tudor.cretu@arm.com>
---
testcases/kernel/syscalls/fgetxattr/fgetxattr01.c | 2 +-
testcases/kernel/syscalls/fgetxattr/fgetxattr02.c | 2 +-
testcases/kernel/syscalls/fgetxattr/fgetxattr03.c | 2 +-
testcases/kernel/syscalls/fsetxattr/fsetxattr01.c | 2 +-
testcases/kernel/syscalls/fsetxattr/fsetxattr02.c | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/testcases/kernel/syscalls/fgetxattr/fgetxattr01.c b/testcases/kernel/syscalls/fgetxattr/fgetxattr01.c
index 35c46a1c3..52e6e44ab 100644
--- a/testcases/kernel/syscalls/fgetxattr/fgetxattr01.c
+++ b/testcases/kernel/syscalls/fgetxattr/fgetxattr01.c
@@ -111,7 +111,7 @@ static void setup(void)
size_t i = 0;
SAFE_TOUCH(FNAME, 0644, NULL);
- fd = SAFE_OPEN(FNAME, O_RDONLY, NULL);
+ fd = SAFE_OPEN(FNAME, O_RDONLY);
for (i = 0; i < ARRAY_SIZE(tc); i++) {
tc[i].value = SAFE_MALLOC(tc[i].size);
diff --git a/testcases/kernel/syscalls/fgetxattr/fgetxattr02.c b/testcases/kernel/syscalls/fgetxattr/fgetxattr02.c
index 82fb676be..c3cff0aab 100644
--- a/testcases/kernel/syscalls/fgetxattr/fgetxattr02.c
+++ b/testcases/kernel/syscalls/fgetxattr/fgetxattr02.c
@@ -244,7 +244,7 @@ static void setup(void)
SAFE_BIND(tc[i].fd, (const struct sockaddr *) &sun,
sizeof(struct sockaddr_un));
} else {
- tc[i].fd = SAFE_OPEN(tc[i].fname, tc[i].fflags, NULL);
+ tc[i].fd = SAFE_OPEN(tc[i].fname, tc[i].fflags);
}
if (tc[i].exp_ret >= 0) {
diff --git a/testcases/kernel/syscalls/fgetxattr/fgetxattr03.c b/testcases/kernel/syscalls/fgetxattr/fgetxattr03.c
index d293ffca9..0581b9670 100644
--- a/testcases/kernel/syscalls/fgetxattr/fgetxattr03.c
+++ b/testcases/kernel/syscalls/fgetxattr/fgetxattr03.c
@@ -48,7 +48,7 @@ static void verify_fgetxattr(void)
static void setup(void)
{
SAFE_TOUCH(FILENAME, 0644, NULL);
- fd = SAFE_OPEN(FILENAME, O_RDONLY, NULL);
+ fd = SAFE_OPEN(FILENAME, O_RDONLY);
SAFE_FSETXATTR(fd, XATTR_TEST_KEY, XATTR_TEST_VALUE,
XATTR_TEST_VALUE_SIZE, XATTR_CREATE);
diff --git a/testcases/kernel/syscalls/fsetxattr/fsetxattr01.c b/testcases/kernel/syscalls/fsetxattr/fsetxattr01.c
index ffec8104f..d799e477f 100644
--- a/testcases/kernel/syscalls/fsetxattr/fsetxattr01.c
+++ b/testcases/kernel/syscalls/fsetxattr/fsetxattr01.c
@@ -205,7 +205,7 @@ static void setup(void)
long_value[XATTR_SIZE_MAX + 1] = '\0';
SAFE_TOUCH(FNAME, 0644, NULL);
- fd = SAFE_OPEN(FNAME, O_RDONLY, NULL);
+ fd = SAFE_OPEN(FNAME, O_RDONLY);
for (i = 0; i < ARRAY_SIZE(tc); i++) {
if (!tc[i].key)
diff --git a/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c b/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
index 3aea4b59e..0336c964a 100644
--- a/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
+++ b/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
@@ -211,7 +211,7 @@ static void setup(void)
for (i = 0; i < ARRAY_SIZE(tc); i++) {
if (!tc[i].issocket) {
- tc[i].fd = SAFE_OPEN(tc[i].fname, tc[i].fflags, NULL);
+ tc[i].fd = SAFE_OPEN(tc[i].fname, tc[i].fflags);
continue;
}
--
2.25.1
More information about the ltp
mailing list