Skip to contentSkip to conversation

syscalls/cachestat01: minor improvements

PATCH In review Avinesh Kumar via ltp 3 participants 7 messages Jul 8

lore
Share & tools
lore
#0 lore raw

cover syscalls/cachestat01: minor improvements

A few small cleanups and a fix for an unchecked fsync() in cachestat01.

Avinesh Kumar (4):
syscalls/cachestat01: Remove redundant memset() on cachestat buffer syscalls/cachestat01: Drop stray newline in tst_res() message syscalls/cachestat01: Add spaces around '<<' operator syscalls/cachestat01: Use SAFE_FSYNC() instead of fsync()

 testcases/kernel/syscalls/cachestat/cachestat01.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
Signature · 5 lines
2.54.0


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

PATCH 1/4 syscalls/cachestat01: Remove redundant memset() on cachestat buffer

From: Avinesh Kumar <[email protected]>

---
 testcases/kernel/syscalls/cachestat/cachestat01.c | 2 --
 1 file changed, 2 deletions(-)
testcases/kernel/syscalls/cachestat/cachestat01.c +0 -2
index aa6f21d41d1a..ca2c2864a1d1 100644
@@ -36,8 +36,6 @@ static void test_cached_pages(const unsigned int use_sync, const int num_pages)
 	tst_res(TINFO, "%s file synchronization", use_sync ? "Enable" : "Disable");
 	tst_res(TINFO, "Number of pages: %d", num_pages);
 
-	memset(cs, 0, sizeof(struct cachestat));
-
 	fd = SAFE_OPEN(FILENAME, O_RDWR | O_CREAT, 0600);
 
 	for (int i = 0; i < num_pages; i++)
Signature · 5 lines
2.54.0


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

Re: [LTP] syscalls/cachestat01: Remove redundant memset() on cachestat buffer

Hi Avinesh,

Quoted 1 line · Avinesh Kumar

syscalls/cachestat01: Remove redundant memset() on cachestat buffer

Verdict - Reviewed

---
Note:

The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

PATCH 2/4 syscalls/cachestat01: Drop stray newline in tst_res() message

In reply to Avinesh Kumar via ltp

From: Avinesh Kumar <[email protected]>

tst_res() appends its own newline, so this prints a blank line.

tst_test.c:1303: TINFO: Mounting /dev/loop0 to /var/tmp/LTP_cacmJmF9g/mntpoint fstyp=ext2 flags=0 cachestat01.c:78: TINFO: Limiting num_shift to 3

cachestat01.c:36: TINFO: Disable file synchronization cachestat01.c:37: TINFO: Number of pages: 1

---
 testcases/kernel/syscalls/cachestat/cachestat01.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/cachestat/cachestat01.c +1 -1
index ca2c2864a1d1..7cc72cc1bf21 100644
@@ -73,7 +73,7 @@ static void setup(void)
 
 	for (num_shift = 0; num_shift <= 15; num_shift++) {
 		if ((1lu<<num_shift) * page_size / 1024 >= tst_device->size) {
-			tst_res(TINFO, "Limiting num_shift to %i\n", num_shift);
+			tst_res(TINFO, "Limiting num_shift to %i", num_shift);
 			break;
 		}
 	}
Signature · 5 lines
2.54.0


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

PATCH 3/4 syscalls/cachestat01: Add spaces around '<<' operator

In reply to Avinesh Kumar via ltp

From: Avinesh Kumar <[email protected]>

$ make check-cachestat01
CHECK testcases/kernel/syscalls/cachestat/cachestat01.c
cachestat01.c:75: CHECK: spaces preferred around that '<<' (ctx:VxV)
---
 testcases/kernel/syscalls/cachestat/cachestat01.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/cachestat/cachestat01.c +1 -1
index 7cc72cc1bf21..1db530ffe9e5 100644
@@ -72,7 +72,7 @@ static void setup(void)
 	page_size = (int)sysconf(_SC_PAGESIZE);
 
 	for (num_shift = 0; num_shift <= 15; num_shift++) {
-		if ((1lu<<num_shift) * page_size / 1024 >= tst_device->size) {
+		if ((1lu << num_shift) * page_size / 1024 >= tst_device->size) {
 			tst_res(TINFO, "Limiting num_shift to %i", num_shift);
 			break;
 		}
Signature · 5 lines
2.54.0


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

PATCH 4/4 syscalls/cachestat01: Use SAFE_FSYNC() instead of fsync()

In reply to Avinesh Kumar via ltp

From: Avinesh Kumar <[email protected]>

Success of fsync() is not checked. Use SAFE_FSYNC() instead so that a failed synchronization is reported instead of being silently ignored.

---
 testcases/kernel/syscalls/cachestat/cachestat01.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/cachestat/cachestat01.c +1 -1
index 1db530ffe9e5..1ba0f9888f0f 100644
@@ -42,7 +42,7 @@ static void test_cached_pages(const unsigned int use_sync, const int num_pages)
 		SAFE_WRITE(0, fd, page_data, page_size);
 
 	if (use_sync)
-		fsync(fd);
+		SAFE_FSYNC(fd);
 
 	cs_range->off = 0;
 	cs_range->len = page_size * num_pages;
Signature · 5 lines
2.54.0


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

Re: [LTP] [PATCH 4/4] syscalls/cachestat01: Use SAFE_FSYNC() instead of fsync()

Hi Avinesh,

thanks for the cleanup, merged!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp