linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ntp: use memset and offsetof init
@ 2021-01-20  2:51 Yejune Deng
  2021-01-20  9:32 ` [kbuild] " Dan Carpenter
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Yejune Deng @ 2021-01-20  2:51 UTC (permalink / raw)
  To: john.stultz, tglx, sboyd; +Cc: linux-kernel, yejune.deng

In pps_fill_timex(), use memset and offsetof instead of '= 0'.

Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
---
 kernel/time/ntp.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 87389b9e21ab..3416c0381104 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -225,14 +225,11 @@ static inline int is_error_status(int status)
 static inline void pps_fill_timex(struct __kernel_timex *txc)
 {
 	/* PPS is not implemented, so these are zero */
-	txc->ppsfreq	   = 0;
-	txc->jitter	   = 0;
-	txc->shift	   = 0;
-	txc->stabil	   = 0;
-	txc->jitcnt	   = 0;
-	txc->calcnt	   = 0;
-	txc->errcnt	   = 0;
-	txc->stbcnt	   = 0;
+	int offset, len;
+
+	offset = offsetof(struct __kernel_timex, ppsfreq);
+	len    = offsetof(struct __kernel_timex, tai) - offset;
+	memset(txc + offset, 0, len);
 }
 
 #endif /* CONFIG_NTP_PPS */
-- 
2.29.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-08  9:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20  2:51 [PATCH] ntp: use memset and offsetof init Yejune Deng
2021-01-20  9:32 ` [kbuild] " Dan Carpenter
2021-01-26  7:44 ` [ntp] a29bace5d3: BUG:Bad_rss-counter_state_mm:#type:MM_FILEPAGES_val kernel test robot
2021-02-05 17:33 ` [PATCH] ntp: use memset and offsetof init Thomas Gleixner
2021-02-08  9:28   ` David Laight

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).