From: John Kacur <jkacur@redhat.com>
To: rolf.freitag@email.de
Cc: linux-rt-users@vger.kernel.org
Subject: Re: [PATCH] no compile warnings from cyclictest
Date: Thu, 8 Jun 2017 16:26:24 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.20.1706081622010.5309@riemann> (raw)
In-Reply-To: <trinity-e47892ae-17fb-4f87-8381-f313303cfe09-1496484084736@3capp-webde-bs10>
[-- Attachment #1: Type: text/plain, Size: 3406 bytes --]
On Sat, 3 Jun 2017, rolf.freitag@email.de wrote:
> Hi,
>
> compiling cyclictest gives 4 warnings of type
>
> warning: ignoring return value of 'write'
>
> and three of type
>
> warning: ... may be used uninitialized in this function
>
> So i eleminated the first sort with a trash variable, which adds up
> the return values and recycles them (their entropy) at the end via
> srand(). This also avoids a write-only variable.
> I eleminated the second sort by initializing the variables.
>
> --- a/src/cyclictest/cyclictest.c
> +++ b/src/cyclictest/cyclictest.c
> @@ -222,6 +222,7 @@ static int use_fifo = 0;
> static pthread_t fifo_threadid;
> static int laptop = 0;
> static int use_histfile = 0;
> +static unsigned int trash; // for unused return values, to avoid compiler warnings because of ignored return values
>
> #ifdef ARCH_HAS_SMI_COUNTER
> static int smi = 0;
> @@ -491,10 +492,10 @@ static void tracemark(char *fmt, ...)
> va_end(ap);
>
> /* write the tracemark message */
> - write(tracemark_fd, tracebuf, len);
> + trash += write(tracemark_fd, tracebuf, len);
>
> /* now stop any trace */
> - write(trace_fd, "0\n", 2);
> + trash += write(trace_fd, "0\n", 2);
> }
>
>
> @@ -510,7 +511,7 @@ static void tracing(int on)
> case KV_26_LT24: prctl(0, 1); break;
> case KV_26_33:
> case KV_30:
> - write(trace_fd, "1", 1);
> + trash += write(trace_fd, "1", 1);
> break;
> default: break;
> }
> @@ -520,7 +521,7 @@ static void tracing(int on)
> case KV_26_LT24: prctl(0, 0); break;
> case KV_26_33:
> case KV_30:
> - write(trace_fd, "0", 1);
> + trash += write(trace_fd, "0", 1);
> break;
> default: break;
> }
> @@ -984,8 +985,10 @@ static void *timerthread(void *param)
> int stopped = 0;
> cpu_set_t mask;
> pthread_t thread;
> - unsigned long smi_now, smi_old;
> + unsigned long smi_now, smi_old=0;
>
> + memset(&stop, 0, sizeof(stop)); /* grrr */
> +
> /* if we're running in numa mode, set our memory node */
> if (par->node != -1)
> rt_numa_set_numa_run_on_node(par->node, par->cpu);
> @@ -1066,7 +1069,6 @@ static void *timerthread(void *param)
> tsnorm(&next);
>
> if (duration) {
> - memset(&stop, 0, sizeof(stop)); /* grrr */
> stop = now;
> stop.tv_sec += duration;
> }
> @@ -2623,5 +2625,7 @@ int main(int argc, char **argv)
> if (affinity_mask)
> rt_bitmask_free(affinity_mask);
>
> + srand(trash); // recycling of the trash (unused return values)
> +
> exit(ret);
> }
> --
I seen to recall some old conversations on lkml where these kind of
patches to supress compiler warnings were considered worse than the
warnings. It is possible to supress warnings that we need to deal with.
In addition I see that some of your patch touches on tracing, which
I'm planning on ripping out and replacing with the ability to do the same
kind of tracing with external programs, specifically trace-cmd.
Thanks
John
prev parent reply other threads:[~2017-06-08 14:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-03 10:01 [PATCH] no compile warnings from cyclictest rolf.freitag
2017-06-04 9:47 ` Uwe Kleine-König
2017-06-08 14:26 ` John Kacur [this message]
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.1706081622010.5309@riemann \
--to=jkacur@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=rolf.freitag@email.de \
/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).