Skip to contentSkip to conversation

Fix usage of true and false as field names in struct taint_flag

PATCH In review Valdis Kletnieks 2 participants 3 messages Dec 27, 2016 – Jan 3, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix usage of true and false as field names in struct taint_flag

The commit 7fd8329ba502ef76dd ("taint/module: Clean up global and module taint flags handling") contains this chunk:

+struct taint_flag {

+       char true;      /* character printed when tainted */
+       char false;     /* character printed when not tainted */
+       bool module;    /* also show as a per-module taint flag */

+};

and hilarity ensues when an out-of-tree module has this:

# ifndef true
#  define true  (1)
# endif
# ifndef false
#  define false (0)
# endif

Change the field names to not shadow something likely to be used by third-party modules.

include/linux/kernel.h +2 -2
index 56aec84237ad..420d4b87feb0 100644
@@ -514,8 +514,8 @@ extern enum system_states {
 #define TAINT_FLAGS_COUNT		16
 
 struct taint_flag {
-	char true;	/* character printed when tainted */
-	char false;	/* character printed when not tainted */
+	char tainted;	/* character printed when tainted */
+	char untainted;	/* character printed when not tainted */
 	bool module;	/* also show as a per-module taint flag */
 };
 
kernel/module.c +1 -1
index f7482db0f843..6a0434de5dbd 100644
@@ -1145,7 +1145,7 @@ static size_t module_flags_taint(struct module *mod, char *buf)
 
 	for (i = 0; i < TAINT_FLAGS_COUNT; i++) {
 		if (taint_flags[i].module && test_bit(i, &mod->taints))
-			buf[l++] = taint_flags[i].true;
+			buf[l++] = taint_flags[i].tainted;
 	}
 
 	return l;
kernel/panic.c +1 -1
index c51edaa04fce..e02da0928910 100644
@@ -355,7 +355,7 @@ const char *print_tainted(void)
 		for (i = 0; i < TAINT_FLAGS_COUNT; i++) {
 			const struct taint_flag *t = &taint_flags[i];
 			*s++ = test_bit(i, &tainted_mask) ?
-					t->true : t->false;
+					t->tainted : t->untainted;
 		}
 		*s = 0;
 	} else
#1 lore raw

+++ Valdis Kletnieks [26/12/16 18:49 -0500]:

Quoted 18 lines

The commit 7fd8329ba502ef76dd ("taint/module: Clean up global and module taint flags handling") contains this chunk:

(quoted diff) +5 -0
+struct taint_flag {
+       char true;      /* character printed when tainted */
+       char false;     /* character printed when not tainted */
+       bool module;    /* also show as a per-module taint flag */
+};

and hilarity ensues when an out-of-tree module has this:

# ifndef true
#  define true  (1)
# endif
# ifndef false
#  define false (0)
# endif
Quoted 5 lines

Change the field names to not shadow something likely to be used by third-party modules.

[ added Rusty and Larry to CC ]

Hm, you and Larry Finger sent the exact same fix at around the same time, although I think people are leaning towards the other patch (it's just a naming preference), see here:

https://lkml.kernel.org/r/[email protected]

I plan to take the other patch, but since you first reported the issue to lkml, and additionally sent a fix in response, I will add a
Reported-by: tag to the patch so I can also give you credit.

Thanks Valdis!

Jessica

#2 lore raw
Quoted 9 lines · Jessica Yu

Hm, you and Larry Finger sent the exact same fix at around the same time, although I think people are leaning towards the other patch (it's just a naming preference), see here:

   https://lkml.kernel.org/r/[email protected]

I plan to take the other patch, but since you first reported the issue to lkml, and additionally sent a fix in response, I will add a
Reported-by: tag to the patch so I can also give you credit.

Works for me, thanks..