All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/signalfd01.c: Fix compiler warnings
@ 2018-07-20 11:54 Jinhui huang
  2018-08-16 11:54 ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Jinhui huang @ 2018-07-20 11:54 UTC (permalink / raw)
  To: ltp

Signed-off-by: Jinhui huang <huangjh.jy@cn.fujitsu.com>
---
 testcases/kernel/syscalls/signalfd/signalfd01.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/testcases/kernel/syscalls/signalfd/signalfd01.c b/testcases/kernel/syscalls/signalfd/signalfd01.c
index 9859524..0c33603 100644
--- a/testcases/kernel/syscalls/signalfd/signalfd01.c
+++ b/testcases/kernel/syscalls/signalfd/signalfd01.c
@@ -76,7 +76,7 @@ int TST_TOTAL = 1;
 #endif
 
 #ifdef USE_STUB
-int main(int argc, char **argv)
+int main(void)
 {
 	tst_brkm(TCONF, NULL, "System doesn't support execution of the test");
 }
@@ -94,7 +94,7 @@ int signalfd(int fd, const sigset_t * mask, int flags)
 void cleanup(void);
 void setup(void);
 
-int do_test1(int ntst, int sig)
+int do_test1(int sig)
 {
 	int sfd_for_next;
 	int sfd;
@@ -145,7 +145,7 @@ int do_test1(int ntst, int sig)
 	if ((s > 0) && (s != sizeof(struct signalfd_siginfo))) {
 		tst_resm(TFAIL,
 			 "getting incomplete signalfd_siginfo data: "
-			 "actual-size=%" PRId32 ", expected-size=%" PRId32,
+			 "actual-size=%zd" PRId32 ", expected-size=%ld" PRId32,
 			 s, sizeof(struct signalfd_siginfo));
 		sfd_for_next = -1;
 		close(sfd);
@@ -170,7 +170,7 @@ int do_test1(int ntst, int sig)
 		goto out;
 	}
 
-	if (fdsi.SIGNALFD_PREFIX(signo) == sig) {
+	if ((int)fdsi.SIGNALFD_PREFIX(signo) == sig) {
 		tst_resm(TPASS, "got expected signal");
 		sfd_for_next = sfd;
 		goto out;
@@ -187,7 +187,7 @@ out:
 	return sfd_for_next;
 }
 
-void do_test2(int ntst, int fd, int sig)
+void do_test2(int fd, int sig)
 {
 	int sfd;
 	sigset_t mask;
@@ -235,7 +235,7 @@ void do_test2(int ntst, int fd, int sig)
 	if ((s > 0) && (s != sizeof(struct signalfd_siginfo))) {
 		tst_resm(TFAIL,
 			 "getting incomplete signalfd_siginfo data: "
-			 "actual-size=%" PRId32 ", expected-size= %" PRId32,
+			 "actual-size=%zd" PRId32 ", expected-size= %ld" PRId32,
 			 s, sizeof(struct signalfd_siginfo));
 		goto out;
 	} else if (s < 0) {
@@ -254,7 +254,7 @@ void do_test2(int ntst, int fd, int sig)
 		goto out;
 	}
 
-	if (fdsi.SIGNALFD_PREFIX(signo) == sig) {
+	if ((int)fdsi.SIGNALFD_PREFIX(signo) == sig) {
 		tst_resm(TPASS, "got expected signal");
 		goto out;
 	} else {
@@ -285,11 +285,11 @@ int main(int argc, char **argv)
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		tst_count = 0;
 
-		sfd = do_test1(lc, SIGUSR1);
+		sfd = do_test1(SIGUSR1);
 		if (sfd < 0)
 			continue;
 
-		do_test2(lc, sfd, SIGUSR2);
+		do_test2(sfd, SIGUSR2);
 		close(sfd);
 	}
 
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [LTP] [PATCH] syscalls/signalfd01.c: Fix compiler warnings
  2018-07-20 11:54 [LTP] [PATCH] syscalls/signalfd01.c: Fix compiler warnings Jinhui huang
@ 2018-08-16 11:54 ` Cyril Hrubis
  2018-08-17  2:39   ` [LTP] [PATCH v2] syscall/signalfd01: " Jinhui huang
  0 siblings, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2018-08-16 11:54 UTC (permalink / raw)
  To: ltp

Hi!
>  		tst_resm(TFAIL,
>  			 "getting incomplete signalfd_siginfo data: "
> -			 "actual-size=%" PRId32 ", expected-size=%" PRId32,
> +			 "actual-size=%zd" PRId32 ", expected-size=%ld" PRId32,
>  			 s, sizeof(struct signalfd_siginfo));

This is obviously wrong, you have to, at least, remove the PRId32
formatting strings here. Also sizeof() returns size_t hence it should
be formatted with %zu.

>  		sfd_for_next = -1;
>  		close(sfd);
> @@ -170,7 +170,7 @@ int do_test1(int ntst, int sig)
>  		goto out;
>  	}
>  
> -	if (fdsi.SIGNALFD_PREFIX(signo) == sig) {
> +	if ((int)fdsi.SIGNALFD_PREFIX(signo) == sig) {

Maybe it would be clearner to defined the sig to be uint32_t rathe than
sprinkle the code with int casts

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [LTP] [PATCH v2] syscall/signalfd01: Fix compiler warnings
  2018-08-16 11:54 ` Cyril Hrubis
@ 2018-08-17  2:39   ` Jinhui huang
  2018-08-17 12:55     ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Jinhui huang @ 2018-08-17  2:39 UTC (permalink / raw)
  To: ltp

Signed-off-by: Jinhui huang <huangjh.jy@cn.fujitsu.com>
---
 testcases/kernel/syscalls/signalfd/signalfd01.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/syscalls/signalfd/signalfd01.c b/testcases/kernel/syscalls/signalfd/signalfd01.c
index 9859524..72901ff 100644
--- a/testcases/kernel/syscalls/signalfd/signalfd01.c
+++ b/testcases/kernel/syscalls/signalfd/signalfd01.c
@@ -76,7 +76,7 @@ int TST_TOTAL = 1;
 #endif
 
 #ifdef USE_STUB
-int main(int argc, char **argv)
+int main(void)
 {
 	tst_brkm(TCONF, NULL, "System doesn't support execution of the test");
 }
@@ -94,7 +94,7 @@ int signalfd(int fd, const sigset_t * mask, int flags)
 void cleanup(void);
 void setup(void);
 
-int do_test1(int ntst, int sig)
+int do_test1(uint32_t sig)
 {
 	int sfd_for_next;
 	int sfd;
@@ -145,7 +145,7 @@ int do_test1(int ntst, int sig)
 	if ((s > 0) && (s != sizeof(struct signalfd_siginfo))) {
 		tst_resm(TFAIL,
 			 "getting incomplete signalfd_siginfo data: "
-			 "actual-size=%" PRId32 ", expected-size=%" PRId32,
+			 "actual-size=%zd, expected-size=%zu",
 			 s, sizeof(struct signalfd_siginfo));
 		sfd_for_next = -1;
 		close(sfd);
@@ -187,7 +187,7 @@ out:
 	return sfd_for_next;
 }
 
-void do_test2(int ntst, int fd, int sig)
+void do_test2(int fd, uint32_t sig)
 {
 	int sfd;
 	sigset_t mask;
@@ -235,7 +235,7 @@ void do_test2(int ntst, int fd, int sig)
 	if ((s > 0) && (s != sizeof(struct signalfd_siginfo))) {
 		tst_resm(TFAIL,
 			 "getting incomplete signalfd_siginfo data: "
-			 "actual-size=%" PRId32 ", expected-size= %" PRId32,
+			 "actual-size=%zd, expected-size= %zu",
 			 s, sizeof(struct signalfd_siginfo));
 		goto out;
 	} else if (s < 0) {
@@ -285,11 +285,11 @@ int main(int argc, char **argv)
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		tst_count = 0;
 
-		sfd = do_test1(lc, SIGUSR1);
+		sfd = do_test1(SIGUSR1);
 		if (sfd < 0)
 			continue;
 
-		do_test2(lc, sfd, SIGUSR2);
+		do_test2(sfd, SIGUSR2);
 		close(sfd);
 	}
 
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [LTP] [PATCH v2] syscall/signalfd01: Fix compiler warnings
  2018-08-17  2:39   ` [LTP] [PATCH v2] syscall/signalfd01: " Jinhui huang
@ 2018-08-17 12:55     ` Cyril Hrubis
  0 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2018-08-17 12:55 UTC (permalink / raw)
  To: ltp

Hi!
Applied, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-17 12:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-20 11:54 [LTP] [PATCH] syscalls/signalfd01.c: Fix compiler warnings Jinhui huang
2018-08-16 11:54 ` Cyril Hrubis
2018-08-17  2:39   ` [LTP] [PATCH v2] syscall/signalfd01: " Jinhui huang
2018-08-17 12:55     ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.