Skip to contentSkip to conversation

syscalls/msync: Assgin value for page_sz

PATCH New Yang Xu 3 participants 3 messages Jan 26, 2021

lore
Share & tools
lore

Yang Xu

author
#0 lore raw

PATCH 1/1 syscalls/msync: Assgin value for page_sz

Since the previous patch, it removes useless getpagesize() check because this function never fail. But it also remove the page_size assignment and it lead case fail as below:

msync02     1  TBROK  :  msync02.c:133: mmap failed: errno=EINVAL(22): Invalid argument
msync02     2  TBROK  :  msync02.c:133: Remaining cases broken
msync02     3  TBROK  :  msync02.c:147: munmap failed: errno=EINVAL(22): Invalid argument

Fix this and also fix compiler warning by using size_t data type instead of int.

Fixes 60f4b01194ca ("syscalls/msync01: Remove useless getpagesize() check")
---
 testcases/kernel/syscalls/msync/msync01.c | 4 +++-
 testcases/kernel/syscalls/msync/msync02.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/msync/msync01.c +3 -1
index 121fd86e8..cb740565d 100644
@@ -153,12 +153,14 @@ int main(int ac, char **av)
  */
 void setup(void)
 {
-	int c_total = 0, nwrite = 0;	/* no. of bytes to be written */
+	size_t c_total = 0, nwrite = 0;	/* no. of bytes to be written */
 
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
 	TEST_PAUSE;
 
+	page_sz = (size_t)getpagesize();
+
 	tst_tmpdir();
 
 	if ((fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666)) < 0)
testcases/kernel/syscalls/msync/msync02.c +3 -1
index c7b7e9e9c..11ed29e3b 100644
@@ -106,13 +106,15 @@ int main(int ac, char **av)
 
 void setup(void)
 {
-	int c_total = 0, nwrite = 0;	/* no. of bytes to be written */
+	size_t c_total = 0, nwrite = 0;	/* no. of bytes to be written */
 	char tst_buf[BUF_SIZE];
 
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
 	TEST_PAUSE;
 
+	page_sz = (size_t)getpagesize();
+
 	tst_tmpdir();
 
 	if ((fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666)) < 0)
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/1 syscalls/msync: Assgin value for page_sz

Quoted 4 lines · Yang Xu

Since the previous patch, it removes useless getpagesize() check because this function never fail. But it also remove the page_size assignment and it lead case fail as below:

Quoted 9 lines

msync02 1 TBROK : msync02.c:133: mmap failed: errno=EINVAL(22):
Invalid argument

msync02     2  TBROK  :  msync02.c:133: Remaining cases broken
msync02     3  TBROK  :  msync02.c:147: munmap failed: errno=EINVAL(22):

Invalid argument

Fix this and also fix compiler warning by using size_t data type instead of int.

Pushed, thanks for the fix.

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210126/a40c17fd/attachment.htm>
#2 lore raw

PATCH 1/1 syscalls/msync: Assgin value for page_sz

Hi Xu, Li,

Quoted 13 lines
Quoted 9 lines · Yang Xu

Since the previous patch, it removes useless getpagesize() check because this function never fail. But it also remove the page_size assignment and it lead case fail as below:

msync02 1 TBROK : msync02.c:133: mmap failed: errno=EINVAL(22):
Invalid argument

msync02     2  TBROK  :  msync02.c:133: Remaining cases broken
msync02     3  TBROK  :  msync02.c:147: munmap failed: errno=EINVAL(22):

Invalid argument

Quoted 5 lines
Quoted 2 lines

Fix this and also fix compiler warning by using size_t data type instead of int.

Pushed, thanks for the fix.

I'm sorry for a regression and thanks for fixing it.

Kind regards,
Petr