lib/vsprintf: Use EXPORT_SYMBOL_IF_KUNIT() to export symbols

Replace EXPORT_SYMBOL_FOR_MODULES() with EXPORT_SYMBOL_IF_KUNIT()
to mark the symbols as visible only if CONFIG_KUNIT is enabled.

Kunit test should import the namespace EXPORTED_FOR_KUNIT_TESTING to
use these marked symbols. This is the standard way for all KUnit
tests.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Tamir Duberstein <tamird@kernel.org>
Link: https://patch.msgid.link/20260714122143.743227-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Petr Mladek <pmladek@suse.com>
This commit is contained in:
Andy Shevchenko 2026-07-14 14:21:43 +02:00 committed by Petr Mladek
parent b80fc54890
commit a75d9cc33d
2 changed files with 6 additions and 3 deletions

View File

@ -876,3 +876,4 @@ kunit_test_suite(printf_test_suite);
MODULE_AUTHOR("Rasmus Villemoes <linux@rasmusvillemoes.dk>");
MODULE_DESCRIPTION("Test cases for printf facility");
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");

View File

@ -25,6 +25,7 @@
#include <linux/module.h> /* for KSYM_SYMBOL_LEN */
#include <linux/types.h>
#include <linux/string.h>
#include <linux/string_helpers.h>
#include <linux/ctype.h>
#include <linux/hex.h>
#include <linux/kernel.h>
@ -54,12 +55,13 @@
#include <asm/byteorder.h> /* cpu_to_le16 */
#include <linux/unaligned.h>
#include <linux/string_helpers.h>
#include <kunit/visibility.h>
#include "kstrtox.h"
/* Disable pointer hashing if requested */
bool no_hash_pointers __ro_after_init;
EXPORT_SYMBOL_FOR_MODULES(no_hash_pointers, "printf_kunit");
EXPORT_SYMBOL_IF_KUNIT(no_hash_pointers);
/*
* Hashed pointers policy selected by "hash_pointers=..." boot param
@ -847,7 +849,7 @@ static char *default_pointer(char *buf, char *end, const void *ptr,
}
int kptr_restrict __read_mostly;
EXPORT_SYMBOL_FOR_MODULES(kptr_restrict, "printf_kunit");
EXPORT_SYMBOL_IF_KUNIT(kptr_restrict);
static noinline_for_stack
char *restricted_pointer(char *buf, char *end, const void *ptr,