[LTP] [PATCH] syslogtst.c: fix a bug of assert() is used wrong

Peng Haitao
2011-02-24T06:17:51Z

Hi Garrett,

When executing "./syslogtst 1", the error message is follows:
syslogtst: syslogtst.c:93: main: Assertion `ch1 != -1' failed.

Signed-off-by: Peng Haitao <penght@cn.fujitsu.com>
---
testcases/kernel/syscalls/syslog/syslogtst.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/syslog/syslogtst.c b/testcases/kernel/syscalls/syslog/syslogtst.c
index a229688..11a97fd 100644
--- a/testcases/kernel/syscalls/syslog/syslogtst.c
+++ b/testcases/kernel/syscalls/syslog/syslogtst.c
@@ -90,8 +90,6 @@ int main(int argc, char *argv[])
ch1 = atoi(argv[2]);
}

- assert (ch1 != -1);
-
/*
* Send syslog messages according to the case number, which
* we will know from command line.
@@ -101,6 +99,8 @@ int main(int argc, char *argv[])
syslog(LOG_MAIL | LOG_INFO, "syslogtst: mail info test.");
break;
case 2:
+ assert (ch1 != -1);
+
switch (ch1) {
case 0:
syslog(LOG_MAIL | LOG_EMERG,
@@ -254,6 +254,8 @@ int main(int argc, char *argv[])
syslog(LOG_USER | LOG_DEBUG, "syslogtst: debug log");
break;
case 8:
+ assert (ch1 != -1);
+
switch (ch1) {
/*
* Kernel messages cannot be send by user, so skipping the
@@ -343,4 +345,4 @@ void sig_handler(int signal)
}

exit(signal);
-}
\ No newline at end of file
+}
--
1.7.1

--
Best Regards,
Peng Haitao