Re: [PATCH] printk: avoid -Wsometimes-uninitialized warning
From: Steven Rostedt
Date: Mon Sep 27 2021 - 12:21:41 EST
On Mon, 27 Sep 2021 14:19:18 +0100
Chris Down <chris@xxxxxxxxxxxxxx> wrote:
> Having IS_ENABLED and then an #ifdef seems to hurt code readability to me.
I agree.
Would this be a better solution?
-- Steve
diff --git a/kernel/printk/index.c b/kernel/printk/index.c
index d3709408debe..ce3a0c8c5770 100644
--- a/kernel/printk/index.c
+++ b/kernel/printk/index.c
@@ -26,10 +26,10 @@ static struct pi_entry *pi_get_entry(const struct module *mod, loff_t pos)
if (mod) {
entries = mod->printk_index_start;
nr_entries = mod->printk_index_size;
- }
+ } else
#endif
+ {
- if (!mod) {
/* vmlinux, comes from linker symbols */
entries = __start_printk_index;
nr_entries = __stop_printk_index - __start_printk_index;