public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] lib/tst_clocks.c: fix 'tst_clock_gettime()' and 'tst_clock_settime()'
@ 2020-08-18 18:48 Filip Bozuta
  2020-08-19  8:36 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Filip Bozuta @ 2020-08-18 18:48 UTC (permalink / raw)
  To: ltp

The type of 'struct tst_ts' has to be kept between function calls
because a function can be called with the wrong timespec type.
For that reason, a 'static' identifier is added for 'tts'
in 'tst_clock_gettime()' and 'tst_clock_settime()' as to make sure
the right timespec type is passed in 'clock_gettime()' and
'clock_settime()'.

Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
---
 lib/tst_clocks.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/tst_clocks.c b/lib/tst_clocks.c
index 7b465b1f6..cdcb9fc4f 100644
--- a/lib/tst_clocks.c
+++ b/lib/tst_clocks.c
@@ -57,7 +57,7 @@ int tst_clock_getres(clockid_t clk_id, struct timespec *res)
 
 int tst_clock_gettime(clockid_t clk_id, struct timespec *ts)
 {
-	struct tst_ts tts = { 0, };
+	static struct tst_ts tts = { 0, };
 	static mysyscall func;
 	int ret;
 
@@ -87,7 +87,7 @@ int tst_clock_gettime(clockid_t clk_id, struct timespec *ts)
 
 int tst_clock_settime(clockid_t clk_id, struct timespec *ts)
 {
-	struct tst_ts tts = { 0, };
+	static struct tst_ts tts = { 0, };
 	static mysyscall func;
 
 #if (__NR_clock_settime64 != __LTP__NR_INVALID_SYSCALL)
-- 
2.25.1


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

* [LTP] [PATCH] lib/tst_clocks.c: fix 'tst_clock_gettime()' and 'tst_clock_settime()'
  2020-08-18 18:48 [LTP] [PATCH] lib/tst_clocks.c: fix 'tst_clock_gettime()' and 'tst_clock_settime()' Filip Bozuta
@ 2020-08-19  8:36 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2020-08-19  8:36 UTC (permalink / raw)
  To: ltp

Hi!
Good catch, applied, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

end of thread, other threads:[~2020-08-19  8:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-18 18:48 [LTP] [PATCH] lib/tst_clocks.c: fix 'tst_clock_gettime()' and 'tst_clock_settime()' Filip Bozuta
2020-08-19  8:36 ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox