From: John Kacur <jkacur@redhat.com>
To: Henrik Austad <haustad@cisco.com>
Cc: linux-rt-users@vger.kernel.org, Clark Williams <williams@redhat.com>
Subject: Re: [PATCH 2/4] signaltest: properly test return value from system()
Date: Wed, 7 Oct 2015 12:44:07 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.20.1510071240120.14006@riemann> (raw)
In-Reply-To: <1444122503-8112-2-git-send-email-haustad@cisco.com>
On Tue, 6 Oct 2015, Henrik Austad wrote:
> signaltest writes to several /proc/sys/kernel attributes without testing
> if the system() call succeeds or not. We expect the writes from echo to
> suceed (i.e. yield '0' in return), so we test explicitly for that.
>
> Signed-off-by: Henrik Austad <haustad@cisco.com>
> Cc: Clark Williams <williams@redhat.com>
> Cc: John Kacur <jkacur@redhat.com>
> ---
> src/signaltest/signaltest.c | 25 +++++++++++++++----------
> 1 file changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
> index b80969b..8074b68 100644
> --- a/src/signaltest/signaltest.c
> +++ b/src/signaltest/signaltest.c
> @@ -65,6 +65,11 @@ struct thread_stat {
> int threadstarted;
> int tid;
> };
> +#define SYSTEM_W(x) \
> + if (system((x)) != 0) { \
> + fprintf(stderr, "Trouble running %s\n", (x)); \
> + return NULL; \
> + } \
>
> static int shutdown;
> static int tracelimit = 0;
> @@ -102,16 +107,16 @@ void *signalthread(void *param)
> int first = 1;
>
> if (tracelimit) {
> - system("echo 1 > /proc/sys/kernel/trace_all_cpus");
> - system("echo 1 > /proc/sys/kernel/trace_enabled");
> - system("echo 1 > /proc/sys/kernel/trace_freerunning");
> - system("echo 0 > /proc/sys/kernel/trace_print_at_crash");
> - system("echo 1 > /proc/sys/kernel/trace_user_triggered");
> - system("echo -1 > /proc/sys/kernel/trace_user_trigger_irq");
> - system("echo 0 > /proc/sys/kernel/trace_verbose");
> - system("echo 0 > /proc/sys/kernel/preempt_thresh");
> - system("echo 0 > /proc/sys/kernel/wakeup_timing");
> - system("echo 0 > /proc/sys/kernel/preempt_max_latency");
> + SYSTEM_W("echo 1 > /proc/sys/kernel/trace_all_cpus");
> + SYSTEM_W("echo 1 > /proc/sys/kernel/trace_enabled");
> + SYSTEM_W("echo 1 > /proc/sys/kernel/trace_freerunning");
> + SYSTEM_W("echo 0 > /proc/sys/kernel/trace_print_at_crash");
> + SYSTEM_W("echo 1 > /proc/sys/kernel/trace_user_triggered");
> + SYSTEM_W("echo -1 > /proc/sys/kernel/trace_user_trigger_irq");
> + SYSTEM_W("echo 0 > /proc/sys/kernel/trace_verbose");
> + SYSTEM_W("echo 0 > /proc/sys/kernel/preempt_thresh");
> + SYSTEM_W("echo 0 > /proc/sys/kernel/wakeup_timing");
> + SYSTEM_W("echo 0 > /proc/sys/kernel/preempt_max_latency");
> }
>
> stat->tid = gettid();
> --
> 1.9.1
>
I really don't like patches like this that just exist to shut-up the
compiler's overzealous warnings. Are you actually having a problem with
this program that you need to debug? If you are, is the message "Trouble
running echo num to some /proc" file really useful? Have you carefully
read the system man page to see what kind of errors can be returned and
why? I'm going to pass on this one for now.
Sorry
John
next prev parent reply other threads:[~2015-10-07 10:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-06 9:08 [PATCH 1/4] Properly test for return-values from read() and write() Henrik Austad
2015-10-06 9:08 ` [PATCH 2/4] signaltest: properly test return value from system() Henrik Austad
2015-10-07 10:44 ` John Kacur [this message]
2015-10-06 9:08 ` [PATCH 3/4] Android: clean up the bypass ifdeffery Henrik Austad
2015-10-07 10:34 ` John Kacur
2015-10-07 11:14 ` Henrik Austad
2015-10-07 11:55 ` John Kacur
2015-10-06 9:08 ` [PATCH 4/4] cyclictest: move redefine of CPUSET back to uclib Henrik Austad
2015-10-07 10:28 ` John Kacur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.2.20.1510071240120.14006@riemann \
--to=jkacur@redhat.com \
--cc=haustad@cisco.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=williams@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).