public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
From: Punit Agrawal <punitagrawal@gmail.com>
To: jkacur@redhat.com
Cc: Punit Agrawal <punit1.agrawal@toshiba.co.jp>,
	williams@redhat.com, linux-rt-users@vger.kernel.org
Subject: [RFC 2/7] rt-tests: cyclictest: Simplify duplicate initialization of "stop"
Date: Thu, 14 Oct 2021 16:12:42 +0900	[thread overview]
Message-ID: <20211014071247.4165329-3-punitagrawal@gmail.com> (raw)
In-Reply-To: <20211014071247.4165329-1-punitagrawal@gmail.com>

From: Punit Agrawal <punit1.agrawal@toshiba.co.jp>

The timespec structure "stop" is initialised whether it is used or not
as the compiler is not smart enough to figure out that it's use is
always guarded by the "duration" variable. As a result, "stop" needs
to be initialised whether it's used or not to avoid a compiler
warning.

Replace the duplicate memset statements by initializing "stop" using
structure initialiser.

Signed-off-by: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
---
 src/cyclictest/cyclictest.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 0c1e6617e0e1..d06ed01c58f4 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -507,7 +507,7 @@ static void *timerthread(void *param)
 	struct sigevent sigev;
 	sigset_t sigset;
 	timer_t timer;
-	struct timespec now, next, interval, stop;
+	struct timespec now, next, interval, stop = { 0 };
 	struct itimerval itimer;
 	struct itimerspec tspec;
 	struct thread_stat *stat = par->stats;
@@ -516,8 +516,6 @@ static void *timerthread(void *param)
 	pthread_t thread;
 	unsigned long smi_now, smi_old = 0;
 
-	memset(&stop, 0, sizeof(stop));
-
 	/* 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);
@@ -598,7 +596,6 @@ static void *timerthread(void *param)
 	tsnorm(&next);
 
 	if (duration) {
-		memset(&stop, 0, sizeof(stop)); /* grrr */
 		stop = now;
 		stop.tv_sec += duration;
 	}
-- 
2.32.0


  parent reply	other threads:[~2021-10-14  7:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14  7:12 [RFC 0/7] rt-tests: cyclictest: Add support to report standard deviation Punit Agrawal
2021-10-14  7:12 ` [RFC 1/7] rt-tests: cyclictest: Drop unused defines Punit Agrawal
2021-10-14 18:23   ` John Kacur
2021-11-11 20:28   ` John Kacur
2021-10-14  7:12 ` Punit Agrawal [this message]
2021-10-14 18:29   ` [RFC 2/7] rt-tests: cyclictest: Simplify duplicate initialization of "stop" John Kacur
2021-11-11 20:32   ` John Kacur
2021-10-14  7:12 ` [RFC 3/7] rt-tests: cyclictest: Drop unnecessary variable "stopped" Punit Agrawal
2021-10-14  7:12 ` [RFC 4/7] rt-tests: cyclictest: Drop unnecessary variable "bufsize" Punit Agrawal
2021-10-14 18:29   ` John Kacur
2021-10-15  8:05     ` Punit Agrawal
2021-10-15 13:07       ` John Kacur
2021-11-11 20:36   ` John Kacur
2021-10-14  7:12 ` [RFC 5/7] rt-tests: cyclictest: Move signal handler to avoid function declaration Punit Agrawal
2021-10-14 18:31   ` John Kacur
2021-10-15  8:21     ` Punit Agrawal
2021-10-14  7:12 ` [RFC 6/7] rt-tests: cyclictest: Use streaming algorithm to calculate averages Punit Agrawal
2021-10-14  7:12 ` [RFC 7/7] rt-tests: cyclictest: Add support to report standard deviation Punit Agrawal
2021-10-14 11:50   ` Daniel Wagner
2021-10-15  7:58     ` Punit Agrawal
2021-10-15  8:22       ` Daniel Wagner
2021-10-15 16:37 ` [RFC 0/7] " Joseph Salisbury
2021-10-18  0:28   ` Punit Agrawal

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=20211014071247.4165329-3-punitagrawal@gmail.com \
    --to=punitagrawal@gmail.com \
    --cc=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=punit1.agrawal@toshiba.co.jp \
    --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