[LTP] [PATCH 1/3] syscalls/fchmod*: Fix compiler warnings

Subsystems: the rest

STALE3150d

8 messages, 2 authors, 2018-03-06 · open the first message on its own page

[LTP] [PATCH 1/3] syscalls/fchmod*: Fix compiler warnings

From: Jinhui Huang <hidden>
Date: 2018-03-02 08:02:22

Signed-off-by: Jinhui Huang <redacted>
---
 testcases/kernel/syscalls/fchmod/fchmod05.c | 4 ++--
 testcases/kernel/syscalls/fchmod/fchmod07.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/syscalls/fchmod/fchmod05.c b/testcases/kernel/syscalls/fchmod/fchmod05.c
index 7a27028..cdd3d07 100644
--- a/testcases/kernel/syscalls/fchmod/fchmod05.c
+++ b/testcases/kernel/syscalls/fchmod/fchmod05.c
@@ -220,8 +220,8 @@ void cleanup(void)
 	/* Close the test directory opened in the setup() */
 	SAFE_CLOSE(NULL, fd);
 
-	setegid(0);
-	seteuid(0);
+	SAFE_SETEGID(NULL, 0);
+	SAFE_SETEUID(NULL, 0);
 
 	tst_rmdir();
 
diff --git a/testcases/kernel/syscalls/fchmod/fchmod07.c b/testcases/kernel/syscalls/fchmod/fchmod07.c
index 66032e4..6973555 100644
--- a/testcases/kernel/syscalls/fchmod/fchmod07.c
+++ b/testcases/kernel/syscalls/fchmod/fchmod07.c
@@ -83,7 +83,7 @@ int fd;				/* file descriptor for testfile */
 char *TCID = "fchmod07";
 int TST_TOTAL = 8;		/* Total number of test conditions */
 
-int Modes[] = { 0, 07, 070, 0700, 0777, 02777, 04777, 06777 };
+mode_t Modes[] = { 0, 07, 070, 0700, 0777, 02777, 04777, 06777 };
 
 void setup();			/* setup function for the test */
 void cleanup();			/* cleanup function for the test */
@@ -93,7 +93,7 @@ int main(int ac, char **av)
 	struct stat stat_buf;	/* stat(2) struct contents */
 	int lc;
 	int ind;		/* counter variable for chmod(2) tests */
-	int mode;		/* file mode permission */
+	mode_t mode;		/* file mode permission */
 
 	TST_TOTAL = sizeof(Modes) / sizeof(int);
 
-- 
1.8.3.1


[LTP] [PATCH 2/3] syscalls/pipe*: Fix compiler warnings

From: Jinhui Huang <hidden>
Date: 2018-03-02 08:02:23

Signed-off-by: Jinhui Huang <redacted>
---
 testcases/kernel/syscalls/pipe/pipe04.c | 2 +-
 testcases/kernel/syscalls/pipe/pipe05.c | 4 ++--
 testcases/kernel/syscalls/pipe/pipe07.c | 2 +-
 testcases/kernel/syscalls/pipe/pipe08.c | 2 ++
 testcases/kernel/syscalls/pipe/pipe11.c | 6 +++---
 5 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/testcases/kernel/syscalls/pipe/pipe04.c b/testcases/kernel/syscalls/pipe/pipe04.c
index b3d255b..a3c56e3 100644
--- a/testcases/kernel/syscalls/pipe/pipe04.c
+++ b/testcases/kernel/syscalls/pipe/pipe04.c
@@ -235,7 +235,7 @@ void c2func(void)
 			tst_resm(TBROK | TERRNO, "[child 2] pipe write failed");
 }
 
-void alarmfunc(int sig)
+void alarmfunc(int sig LTP_ATTRIBUTE_UNUSED)
 {
 	/* for some reason tst_brkm doesn't seem to work in a signal handler */
 	tst_brkm(TFAIL, cleanup, "one or more children did't die in 60 second "
diff --git a/testcases/kernel/syscalls/pipe/pipe05.c b/testcases/kernel/syscalls/pipe/pipe05.c
index fe5ec37..4105988 100644
--- a/testcases/kernel/syscalls/pipe/pipe05.c
+++ b/testcases/kernel/syscalls/pipe/pipe05.c
@@ -59,7 +59,7 @@ void sig11_handler(int sig);
 
 int main(int ac, char **av)
 {
-	int lc;
+	volatile int lc;
 	struct sigaction sa, osa;
 
 	tst_parse_opts(ac, av, NULL, NULL);
@@ -120,7 +120,7 @@ void setup(void)
 /******************************************************************
  * sig11_handler() - our segfault recover hack
  ******************************************************************/
-void sig11_handler(int sig)
+void sig11_handler(int sig LTP_ATTRIBUTE_UNUSED)
 {
 	longjmp(sig11_recover, 1);
 }
diff --git a/testcases/kernel/syscalls/pipe/pipe07.c b/testcases/kernel/syscalls/pipe/pipe07.c
index b09df71..55bb9f4 100644
--- a/testcases/kernel/syscalls/pipe/pipe07.c
+++ b/testcases/kernel/syscalls/pipe/pipe07.c
@@ -129,7 +129,7 @@ static void record_open_fds(void)
 		if (fd == dir_fd)
 			continue;
 
-		if (rec_fds_max >= ARRAY_SIZE(rec_fds)) {
+		if (rec_fds_max >= (int)ARRAY_SIZE(rec_fds)) {
 			tst_brkm(TBROK, cleanup,
 			         "Too much file descriptors open");
 		}
diff --git a/testcases/kernel/syscalls/pipe/pipe08.c b/testcases/kernel/syscalls/pipe/pipe08.c
index cdb2a4d..9f8d9cc 100644
--- a/testcases/kernel/syscalls/pipe/pipe08.c
+++ b/testcases/kernel/syscalls/pipe/pipe08.c
@@ -98,6 +98,8 @@ int main(int ac, char **av)
 		 * sent
 		 */
 		written = write(pipefd[1], wrbuf, length);
+		if (written > 0)
+			tst_brkm(TBROK, cleanup, "write succeeded expectedly");
 	}
 	cleanup();
 	tst_exit();
diff --git a/testcases/kernel/syscalls/pipe/pipe11.c b/testcases/kernel/syscalls/pipe/pipe11.c
index e11c556..e3b2741 100644
--- a/testcases/kernel/syscalls/pipe/pipe11.c
+++ b/testcases/kernel/syscalls/pipe/pipe11.c
@@ -198,7 +198,8 @@ void do_child_uclinux(void)
  */
 void setup(void)
 {
-	int i, j;
+	int i;
+	unsigned int j;
 
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 
@@ -230,9 +231,8 @@ void setup(void)
 	j = 0;
 	for (i = 0; i < szcharbuf;) {
 		wrbuf[i++] = rawchars[j++];
-		if (j >= sizeof(rawchars)) {
+		if (j >= sizeof(rawchars))
 			j = 0;
-		}
 	}
 }
 
-- 
1.8.3.1


[LTP] [PATCH 3/3] syscalls/mknod*: Fix compiler warnings

From: Jinhui Huang <hidden>
Date: 2018-03-02 08:02:24

Signed-off-by: Jinhui Huang <redacted>
---
 testcases/kernel/syscalls/mknod/mknod02.c | 2 +-
 testcases/kernel/syscalls/mknod/mknod03.c | 2 +-
 testcases/kernel/syscalls/mknod/mknod04.c | 2 +-
 testcases/kernel/syscalls/mknod/mknod05.c | 2 +-
 testcases/kernel/syscalls/mknod/mknod08.c | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/testcases/kernel/syscalls/mknod/mknod02.c b/testcases/kernel/syscalls/mknod/mknod02.c
index e5741c3..594473e 100644
--- a/testcases/kernel/syscalls/mknod/mknod02.c
+++ b/testcases/kernel/syscalls/mknod/mknod02.c
@@ -173,7 +173,7 @@ int main(int ac, char **av)
 	}
 
 	/* Change the directory back to temporary directory */
-	chdir("..");
+	SAFE_CHDIR(cleanup, "..");
 
 	/*
 	 * Invoke cleanup() to delete the test directories created
diff --git a/testcases/kernel/syscalls/mknod/mknod03.c b/testcases/kernel/syscalls/mknod/mknod03.c
index fc34686..2af66f7 100644
--- a/testcases/kernel/syscalls/mknod/mknod03.c
+++ b/testcases/kernel/syscalls/mknod/mknod03.c
@@ -172,7 +172,7 @@ int main(int ac, char **av)
 	}
 
 	/* Change the directory back to temporary directory */
-	chdir("..");
+	SAFE_CHDIR(cleanup, "..");
 
 	/*
 	 * Invoke cleanup() to delete the test directories created
diff --git a/testcases/kernel/syscalls/mknod/mknod04.c b/testcases/kernel/syscalls/mknod/mknod04.c
index 6a8e08e..e0123ec 100644
--- a/testcases/kernel/syscalls/mknod/mknod04.c
+++ b/testcases/kernel/syscalls/mknod/mknod04.c
@@ -172,7 +172,7 @@ int main(int ac, char **av)
 	}
 
 	/* Change the directory back to temporary directory */
-	chdir("..");
+	SAFE_CHDIR(cleanup, "..");
 
 	/*
 	 * Invoke cleanup() to delete the test directories created
diff --git a/testcases/kernel/syscalls/mknod/mknod05.c b/testcases/kernel/syscalls/mknod/mknod05.c
index a00a0e4..fbc5575 100644
--- a/testcases/kernel/syscalls/mknod/mknod05.c
+++ b/testcases/kernel/syscalls/mknod/mknod05.c
@@ -171,7 +171,7 @@ int main(int ac, char **av)
 	}
 
 	/* change the directory back to temporary directory */
-	chdir("..");
+	SAFE_CHDIR(cleanup, "..");
 
 	/*
 	 * Invoke cleanup() to delete the test directories created
diff --git a/testcases/kernel/syscalls/mknod/mknod08.c b/testcases/kernel/syscalls/mknod/mknod08.c
index 3cc24ab..8647fde 100644
--- a/testcases/kernel/syscalls/mknod/mknod08.c
+++ b/testcases/kernel/syscalls/mknod/mknod08.c
@@ -170,7 +170,7 @@ int main(int ac, char **av)
 	}
 
 	/* Change the directory back to temporary directory */
-	chdir("..");
+	SAFE_CHDIR(cleanup, "..");
 
 	/*
 	 * Invoke cleanup() to delete the test directories created
-- 
1.8.3.1


[LTP] [PATCH 1/3] syscalls/fchmod*: Fix compiler warnings

From: Petr Vorel <pvorel@suse.cz>
Date: 2018-03-05 07:48:34

Hi Jinhui,
Signed-off-by: Jinhui Huang <redacted>
---
 testcases/kernel/syscalls/fchmod/fchmod05.c | 4 ++--
 testcases/kernel/syscalls/fchmod/fchmod07.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
quoted hunk
diff --git a/testcases/kernel/syscalls/fchmod/fchmod05.c b/testcases/kernel/syscalls/fchmod/fchmod05.c
index 7a27028..cdd3d07 100644
--- a/testcases/kernel/syscalls/fchmod/fchmod05.c
+++ b/testcases/kernel/syscalls/fchmod/fchmod05.c
@@ -220,8 +220,8 @@ void cleanup(void)
 	/* Close the test directory opened in the setup() */
 	SAFE_CLOSE(NULL, fd);
quoted hunk
-	setegid(0);
-	seteuid(0);
+	SAFE_SETEGID(NULL, 0);
+	SAFE_SETEUID(NULL, 0);
 	tst_rmdir();
quoted hunk
diff --git a/testcases/kernel/syscalls/fchmod/fchmod07.c b/testcases/kernel/syscalls/fchmod/fchmod07.c
index 66032e4..6973555 100644
--- a/testcases/kernel/syscalls/fchmod/fchmod07.c
+++ b/testcases/kernel/syscalls/fchmod/fchmod07.c
@@ -83,7 +83,7 @@ int fd;				/* file descriptor for testfile */
 char *TCID = "fchmod07";
 int TST_TOTAL = 8;		/* Total number of test conditions */
-int Modes[] = { 0, 07, 070, 0700, 0777, 02777, 04777, 06777 };
+mode_t Modes[] = { 0, 07, 070, 0700, 0777, 02777, 04777, 06777 };
quoted hunk
 void setup();			/* setup function for the test */
 void cleanup();			/* cleanup function for the test */
@@ -93,7 +93,7 @@ int main(int ac, char **av)
 	struct stat stat_buf;	/* stat(2) struct contents */
 	int lc;
 	int ind;		/* counter variable for chmod(2) tests */
-	int mode;		/* file mode permission */
+	mode_t mode;		/* file mode permission */
 	TST_TOTAL = sizeof(Modes) / sizeof(int);
Pushed, thanks!


Kind regards,
Petr

[LTP] [PATCH 2/3] syscalls/pipe*: Fix compiler warnings

From: Petr Vorel <pvorel@suse.cz>
Date: 2018-03-05 08:03:34

Hi Jinhui,
Signed-off-by: Jinhui Huang <redacted>
---
 testcases/kernel/syscalls/pipe/pipe04.c | 2 +-
 testcases/kernel/syscalls/pipe/pipe05.c | 4 ++--
 testcases/kernel/syscalls/pipe/pipe07.c | 2 +-
 testcases/kernel/syscalls/pipe/pipe08.c | 2 ++
 testcases/kernel/syscalls/pipe/pipe11.c | 6 +++---
 5 files changed, 9 insertions(+), 7 deletions(-)
quoted hunk
diff --git a/testcases/kernel/syscalls/pipe/pipe04.c b/testcases/kernel/syscalls/pipe/pipe04.c
index b3d255b..a3c56e3 100644
--- a/testcases/kernel/syscalls/pipe/pipe04.c
+++ b/testcases/kernel/syscalls/pipe/pipe04.c
@@ -235,7 +235,7 @@ void c2func(void)
 			tst_resm(TBROK | TERRNO, "[child 2] pipe write failed");
 }
quoted hunk
-void alarmfunc(int sig)
+void alarmfunc(int sig LTP_ATTRIBUTE_UNUSED)
 {
 	/* for some reason tst_brkm doesn't seem to work in a signal handler */
 	tst_brkm(TFAIL, cleanup, "one or more children did't die in 60 second "
diff --git a/testcases/kernel/syscalls/pipe/pipe05.c b/testcases/kernel/syscalls/pipe/pipe05.c
index fe5ec37..4105988 100644
--- a/testcases/kernel/syscalls/pipe/pipe05.c
+++ b/testcases/kernel/syscalls/pipe/pipe05.c
@@ -59,7 +59,7 @@ void sig11_handler(int sig);
quoted hunk
 int main(int ac, char **av)
 {
-	int lc;
+	volatile int lc;
Why volatile?
 	struct sigaction sa, osa;
quoted hunk
 	tst_parse_opts(ac, av, NULL, NULL);
@@ -120,7 +120,7 @@ void setup(void)
 /******************************************************************
  * sig11_handler() - our segfault recover hack
  ******************************************************************/
-void sig11_handler(int sig)
+void sig11_handler(int sig LTP_ATTRIBUTE_UNUSED)
 {
 	longjmp(sig11_recover, 1);
 }
diff --git a/testcases/kernel/syscalls/pipe/pipe07.c b/testcases/kernel/syscalls/pipe/pipe07.c
index b09df71..55bb9f4 100644
--- a/testcases/kernel/syscalls/pipe/pipe07.c
+++ b/testcases/kernel/syscalls/pipe/pipe07.c
@@ -129,7 +129,7 @@ static void record_open_fds(void)
 		if (fd == dir_fd)
 			continue;
quoted hunk
-		if (rec_fds_max >= ARRAY_SIZE(rec_fds)) {
+		if (rec_fds_max >= (int)ARRAY_SIZE(rec_fds)) {
 			tst_brkm(TBROK, cleanup,
 			         "Too much file descriptors open");
 		}
diff --git a/testcases/kernel/syscalls/pipe/pipe08.c b/testcases/kernel/syscalls/pipe/pipe08.c
index cdb2a4d..9f8d9cc 100644
--- a/testcases/kernel/syscalls/pipe/pipe08.c
+++ b/testcases/kernel/syscalls/pipe/pipe08.c
@@ -98,6 +98,8 @@ int main(int ac, char **av)
 		 * sent
 		 */
 		written = write(pipefd[1], wrbuf, length);
+		if (written > 0)
+			tst_brkm(TBROK, cleanup, "write succeeded expectedly");
Did you mean "unexpectedly"?
quoted hunk
 	}
 	cleanup();
 	tst_exit();
diff --git a/testcases/kernel/syscalls/pipe/pipe11.c b/testcases/kernel/syscalls/pipe/pipe11.c
index e11c556..e3b2741 100644
--- a/testcases/kernel/syscalls/pipe/pipe11.c
+++ b/testcases/kernel/syscalls/pipe/pipe11.c
@@ -198,7 +198,8 @@ void do_child_uclinux(void)
  */
 void setup(void)
 {
-	int i, j;
+	int i;
+	unsigned int j;
 	tst_sig(FORK, DEF_HANDLER, cleanup);
quoted hunk
@@ -230,9 +231,8 @@ void setup(void)
 	j = 0;
 	for (i = 0; i < szcharbuf;) {
 		wrbuf[i++] = rawchars[j++];
-		if (j >= sizeof(rawchars)) {
+		if (j >= sizeof(rawchars))
 			j = 0;
-		}
 	}
 }
Otherwise LGTM, thanks!


Kind regards,
Petr

[LTP] [PATCH 3/3] syscalls/mknod*: Fix compiler warnings

From: Petr Vorel <pvorel@suse.cz>
Date: 2018-03-05 09:21:44

Hi Jinhui,
Signed-off-by: Jinhui Huang <redacted>
---
 testcases/kernel/syscalls/mknod/mknod02.c | 2 +-
 testcases/kernel/syscalls/mknod/mknod03.c | 2 +-
 testcases/kernel/syscalls/mknod/mknod04.c | 2 +-
 testcases/kernel/syscalls/mknod/mknod05.c | 2 +-
 testcases/kernel/syscalls/mknod/mknod08.c | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
quoted hunk
diff --git a/testcases/kernel/syscalls/mknod/mknod02.c b/testcases/kernel/syscalls/mknod/mknod02.c
index e5741c3..594473e 100644
--- a/testcases/kernel/syscalls/mknod/mknod02.c
+++ b/testcases/kernel/syscalls/mknod/mknod02.c
@@ -173,7 +173,7 @@ int main(int ac, char **av)
 	}
quoted hunk
 	/* Change the directory back to temporary directory */
-	chdir("..");
+	SAFE_CHDIR(cleanup, "..");
quoted hunk
 	/*
 	 * Invoke cleanup() to delete the test directories created
diff --git a/testcases/kernel/syscalls/mknod/mknod03.c b/testcases/kernel/syscalls/mknod/mknod03.c
index fc34686..2af66f7 100644
--- a/testcases/kernel/syscalls/mknod/mknod03.c
+++ b/testcases/kernel/syscalls/mknod/mknod03.c
@@ -172,7 +172,7 @@ int main(int ac, char **av)
 	}
quoted hunk
 	/* Change the directory back to temporary directory */
-	chdir("..");
+	SAFE_CHDIR(cleanup, "..");
quoted hunk
 	/*
 	 * Invoke cleanup() to delete the test directories created
diff --git a/testcases/kernel/syscalls/mknod/mknod04.c b/testcases/kernel/syscalls/mknod/mknod04.c
index 6a8e08e..e0123ec 100644
--- a/testcases/kernel/syscalls/mknod/mknod04.c
+++ b/testcases/kernel/syscalls/mknod/mknod04.c
@@ -172,7 +172,7 @@ int main(int ac, char **av)
 	}
quoted hunk
 	/* Change the directory back to temporary directory */
-	chdir("..");
+	SAFE_CHDIR(cleanup, "..");
quoted hunk
 	/*
 	 * Invoke cleanup() to delete the test directories created
diff --git a/testcases/kernel/syscalls/mknod/mknod05.c b/testcases/kernel/syscalls/mknod/mknod05.c
index a00a0e4..fbc5575 100644
--- a/testcases/kernel/syscalls/mknod/mknod05.c
+++ b/testcases/kernel/syscalls/mknod/mknod05.c
@@ -171,7 +171,7 @@ int main(int ac, char **av)
 	}
quoted hunk
 	/* change the directory back to temporary directory */
-	chdir("..");
+	SAFE_CHDIR(cleanup, "..");
quoted hunk
 	/*
 	 * Invoke cleanup() to delete the test directories created
diff --git a/testcases/kernel/syscalls/mknod/mknod08.c b/testcases/kernel/syscalls/mknod/mknod08.c
index 3cc24ab..8647fde 100644
--- a/testcases/kernel/syscalls/mknod/mknod08.c
+++ b/testcases/kernel/syscalls/mknod/mknod08.c
@@ -170,7 +170,7 @@ int main(int ac, char **av)
 	}
quoted hunk
 	/* Change the directory back to temporary directory */
-	chdir("..");
+	SAFE_CHDIR(cleanup, "..");
 	/*
 	 * Invoke cleanup() to delete the test directories created
Pushed, thanks!

Kind regards,
Petr

[LTP] [PATCH 2/3] syscalls/pipe*: Fix compiler warnings

From: jinhui huang <hidden>
Date: 2018-03-06 01:41:33

于 2018/03/05 16:03, Petr Vorel 写道:
Hi Jinhui,
quoted
Signed-off-by: Jinhui Huang<redacted>
---
  testcases/kernel/syscalls/pipe/pipe04.c | 2 +-
  testcases/kernel/syscalls/pipe/pipe05.c | 4 ++--
  testcases/kernel/syscalls/pipe/pipe07.c | 2 +-
  testcases/kernel/syscalls/pipe/pipe08.c | 2 ++
  testcases/kernel/syscalls/pipe/pipe11.c | 6 +++---
  5 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/testcases/kernel/syscalls/pipe/pipe04.c b/testcases/kernel/syscalls/pipe/pipe04.c
index b3d255b..a3c56e3 100644
--- a/testcases/kernel/syscalls/pipe/pipe04.c
+++ b/testcases/kernel/syscalls/pipe/pipe04.c
@@ -235,7 +235,7 @@ void c2func(void)
  			tst_resm(TBROK | TERRNO, "[child 2] pipe write failed");
  }
-void alarmfunc(int sig)
+void alarmfunc(int sig LTP_ATTRIBUTE_UNUSED)
  {
  	/* for some reason tst_brkm doesn't seem to work in a signal handler */
  	tst_brkm(TFAIL, cleanup, "one or more children did't die in 60 second "
diff --git a/testcases/kernel/syscalls/pipe/pipe05.c b/testcases/kernel/syscalls/pipe/pipe05.c
index fe5ec37..4105988 100644
--- a/testcases/kernel/syscalls/pipe/pipe05.c
+++ b/testcases/kernel/syscalls/pipe/pipe05.c
@@ -59,7 +59,7 @@ void sig11_handler(int sig);
  int main(int ac, char **av)
  {
-	int lc;
+	volatile int lc;
Why volatile?
Hi Petr,

The compiler warning:
pipe05.c: In function ‘main’:
pipe05.c:62:6: warning: variable ‘lc’ might be clobbered by ‘longjmp’ or 
‘vfork’ [-Wclobbered]
int lc;
We may avoid this warning by declaring "lc" as volatile which tells the 
optimizer not to optimize it.
quoted
  	struct sigaction sa, osa;
  	tst_parse_opts(ac, av, NULL, NULL);
@@ -120,7 +120,7 @@ void setup(void)
  /******************************************************************
   * sig11_handler() - our segfault recover hack
   ******************************************************************/
-void sig11_handler(int sig)
+void sig11_handler(int sig LTP_ATTRIBUTE_UNUSED)
  {
  	longjmp(sig11_recover, 1);
  }
diff --git a/testcases/kernel/syscalls/pipe/pipe07.c b/testcases/kernel/syscalls/pipe/pipe07.c
index b09df71..55bb9f4 100644
--- a/testcases/kernel/syscalls/pipe/pipe07.c
+++ b/testcases/kernel/syscalls/pipe/pipe07.c
@@ -129,7 +129,7 @@ static void record_open_fds(void)
  		if (fd == dir_fd)
  			continue;
-		if (rec_fds_max>= ARRAY_SIZE(rec_fds)) {
+		if (rec_fds_max>= (int)ARRAY_SIZE(rec_fds)) {
  			tst_brkm(TBROK, cleanup,
  			         "Too much file descriptors open");
  		}
diff --git a/testcases/kernel/syscalls/pipe/pipe08.c b/testcases/kernel/syscalls/pipe/pipe08.c
index cdb2a4d..9f8d9cc 100644
--- a/testcases/kernel/syscalls/pipe/pipe08.c
+++ b/testcases/kernel/syscalls/pipe/pipe08.c
@@ -98,6 +98,8 @@ int main(int ac, char **av)
  		 * sent
  		 */
  		written = write(pipefd[1], wrbuf, length);
+		if (written>  0)
+			tst_brkm(TBROK, cleanup, "write succeeded expectedly");
Did you mean "unexpectedly"?
Yes.

Best regards,
Jinhui
quoted
  	}
  	cleanup();
  	tst_exit();
diff --git a/testcases/kernel/syscalls/pipe/pipe11.c b/testcases/kernel/syscalls/pipe/pipe11.c
index e11c556..e3b2741 100644
--- a/testcases/kernel/syscalls/pipe/pipe11.c
+++ b/testcases/kernel/syscalls/pipe/pipe11.c
@@ -198,7 +198,8 @@ void do_child_uclinux(void)
   */
  void setup(void)
  {
-	int i, j;
+	int i;
+	unsigned int j;
  	tst_sig(FORK, DEF_HANDLER, cleanup);
@@ -230,9 +231,8 @@ void setup(void)
  	j = 0;
  	for (i = 0; i<  szcharbuf;) {
  		wrbuf[i++] = rawchars[j++];
-		if (j>= sizeof(rawchars)) {
+		if (j>= sizeof(rawchars))
  			j = 0;
-		}
  	}
  }
Otherwise LGTM, thanks!


Kind regards,
Petr


.

[LTP] [PATCH 2/3] syscalls/pipe*: Fix compiler warnings

From: Petr Vorel <pvorel@suse.cz>
Date: 2018-03-06 15:03:02

Hi Jinhui,
quoted
quoted
Signed-off-by: Jinhui Huang<redacted>
---
  testcases/kernel/syscalls/pipe/pipe04.c | 2 +-
  testcases/kernel/syscalls/pipe/pipe05.c | 4 ++--
  testcases/kernel/syscalls/pipe/pipe07.c | 2 +-
  testcases/kernel/syscalls/pipe/pipe08.c | 2 ++
  testcases/kernel/syscalls/pipe/pipe11.c | 6 +++---
  5 files changed, 9 insertions(+), 7 deletions(-)
...
Hi Petr,
The compiler warning:
pipe05.c: In function ‘main’:
pipe05.c:62:6: warning: variable ‘lc’ might be clobbered by ‘longjmp’ or
‘vfork’ [-Wclobbered]
int lc;
We may avoid this warning by declaring "lc" as volatile which tells the
optimizer not to optimize it.
Thanks for info. This was issued by gcc-4.x, that's why I didn't notice that.
I pushed the patch, thanks!
BTW these tests deserve rewriting into new API, that would be a big improvement.


Kind regards,
Petr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help