All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] lib: Cache kernel_bits value
@ 2021-11-15 15:20 Richard Palethorpe via ltp
  2021-11-15 15:20 ` [LTP] [PATCH 2/2] lib: Add .skip_in_compat flag Richard Palethorpe via ltp
  2021-11-15 16:01 ` [LTP] [PATCH 1/2] lib: Cache kernel_bits value Cyril Hrubis
  0 siblings, 2 replies; 5+ messages in thread
From: Richard Palethorpe via ltp @ 2021-11-15 15:20 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

This is primarily to avoid printing the uname info two or more
times. Which is increasingly likely with using tst_kernel_bits in
other library functions. Also with features like test variants where
setup may be run multiple times.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 lib/tst_kernel.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/tst_kernel.c b/lib/tst_kernel.c
index c908bb04c..6db85bff0 100644
--- a/lib/tst_kernel.c
+++ b/lib/tst_kernel.c
@@ -37,7 +37,12 @@ static int get_kernel_bits_from_uname(struct utsname *buf)
 int tst_kernel_bits(void)
 {
 	struct utsname buf;
-	int kernel_bits = get_kernel_bits_from_uname(&buf);
+	static int kernel_bits;
+
+	if (kernel_bits)
+		return kernel_bits;
+
+	kernel_bits = get_kernel_bits_from_uname(&buf);
 
 	if (kernel_bits == -1)
 		return -1;
-- 
2.33.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2021-11-16  8:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-15 15:20 [LTP] [PATCH 1/2] lib: Cache kernel_bits value Richard Palethorpe via ltp
2021-11-15 15:20 ` [LTP] [PATCH 2/2] lib: Add .skip_in_compat flag Richard Palethorpe via ltp
2021-11-15 16:07   ` Cyril Hrubis
2021-11-16  8:41     ` Richard Palethorpe
2021-11-15 16:01 ` [LTP] [PATCH 1/2] lib: Cache kernel_bits value Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.