* [LTP] [PATCH] syslogtst.c: fix a bug of assert() is used wrong
@ 2011-02-24 6:17 Peng Haitao
2011-02-24 7:32 ` Garrett Cooper
0 siblings, 1 reply; 4+ messages in thread
From: Peng Haitao @ 2011-02-24 6:17 UTC (permalink / raw)
To: Garrett Cooper; +Cc: ltp-list
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
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [LTP] [PATCH] syslogtst.c: fix a bug of assert() is used wrong
2011-02-24 6:17 [LTP] [PATCH] syslogtst.c: fix a bug of assert() is used wrong Peng Haitao
@ 2011-02-24 7:32 ` Garrett Cooper
2011-02-24 7:59 ` Peng Haitao
0 siblings, 1 reply; 4+ messages in thread
From: Garrett Cooper @ 2011-02-24 7:32 UTC (permalink / raw)
To: Peng Haitao; +Cc: ltp-list
[-- Attachment #1: Type: text/plain, Size: 268 bytes --]
On Wed, Feb 23, 2011 at 10:17 PM, Peng Haitao <penght@cn.fujitsu.com> wrote:
> Hi Garrett,
>
> When executing "./syslogtst 1", the error message is follows:
> syslogtst: syslogtst.c:93: main: Assertion `ch1 != -1' failed.
How about this instead?
Thanks,
-Garrett
[-- Attachment #2: syslogtst-fixes.patch --]
[-- Type: text/x-patch, Size: 869 bytes --]
diff --git a/testcases/kernel/syscalls/syslog/syslogtst.c b/testcases/kernel/syscalls/syslog/syslogtst.c
index a229688..a56f22d 100644
--- a/testcases/kernel/syscalls/syslog/syslogtst.c
+++ b/testcases/kernel/syscalls/syslog/syslogtst.c
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
else if (argc == 2) {
ch = atoi(argv[1]);
- if (atoi(argv[1]) == 2 || atoi(argv[1]) == 8) {
+ if (ch == 2 || ch == 8) {
if (ch == 2)
ch1 = random() % 8;
if (ch == 8)
@@ -90,7 +90,8 @@ int main(int argc, char *argv[])
ch1 = atoi(argv[2]);
}
- assert (ch1 != -1);
+ /* Ensure ch1 is properly allocated when ch == 2 or ch == 8. */
+ assert (!((ch == 2 || ch == 8) && ch1 == -1));
/*
* Send syslog messages according to the case number, which
@@ -343,4 +344,4 @@ void sig_handler(int signal)
}
exit(signal);
-}
\ No newline at end of file
+}
[-- Attachment #3: Type: text/plain, Size: 429 bytes --]
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
[-- Attachment #4: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [LTP] [PATCH] syslogtst.c: fix a bug of assert() is used wrong
2011-02-24 7:32 ` Garrett Cooper
@ 2011-02-24 7:59 ` Peng Haitao
2011-02-24 16:47 ` Garrett Cooper
0 siblings, 1 reply; 4+ messages in thread
From: Peng Haitao @ 2011-02-24 7:59 UTC (permalink / raw)
To: Garrett Cooper; +Cc: ltp-list
Hi Garrett,
Garrett Cooper said the following on 2011-2-24 15:32:
>> When executing "./syslogtst 1", the error message is follows:
>> syslogtst: syslogtst.c:93: main: Assertion `ch1 != -1' failed.
>
> How about this instead?
The patch is OK, thanks.
--
Best Regards,
Peng Haitao
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] syslogtst.c: fix a bug of assert() is used wrong
2011-02-24 7:59 ` Peng Haitao
@ 2011-02-24 16:47 ` Garrett Cooper
0 siblings, 0 replies; 4+ messages in thread
From: Garrett Cooper @ 2011-02-24 16:47 UTC (permalink / raw)
To: Peng Haitao; +Cc: ltp-list
On Wed, Feb 23, 2011 at 11:59 PM, Peng Haitao <penght@cn.fujitsu.com> wrote:
> Hi Garrett,
>
> Garrett Cooper said the following on 2011-2-24 15:32:
>>> When executing "./syslogtst 1", the error message is follows:
>>> syslogtst: syslogtst.c:93: main: Assertion `ch1 != -1' failed.
>>
>> How about this instead?
>
> The patch is OK, thanks.
Committed -- thanks!
-Garrett
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-02-24 16:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-24 6:17 [LTP] [PATCH] syslogtst.c: fix a bug of assert() is used wrong Peng Haitao
2011-02-24 7:32 ` Garrett Cooper
2011-02-24 7:59 ` Peng Haitao
2011-02-24 16:47 ` Garrett Cooper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox