Skip to contentSkip to conversation

ugly warnings with likely/unlikely

DISCUSSION Oliver Neukum 3 participants 4 messages Jan 13, 2002

lore
Share & tools
lore
#0 lore raw

Hi,

if (likely(stru->pointer))

results in an ugly warning about using pointer as int. Is there something that could be done against that ?

Regards
Oliver

#1 lore raw
Quoted 4 lines

if (likely(stru->pointer))

results in an ugly warning about using pointer as int. Is there something that could be done against that ?

	if (likely(stru->pointer == NULL))

Perhaps ?

#2 lore raw
Quoted 8 lines · Alan Cox
Quoted 4 lines

if (likely(stru->pointer))

results in an ugly warning about using pointer as int. Is there something that could be done against that ?

	if (likely(stru->pointer == NULL))

Perhaps ?

That works. But it's so much work to type it.

Regards
Oliver

#3 lore raw
In reply to Oliver Neukum
Quoted 8 lines · Alan Cox
Quoted 5 lines

if (likely(stru->pointer))

results in an ugly warning about using pointer as int. Is there something that could be done against that ?

        if (likely(stru->pointer == NULL))
-#define likely(x)       __builtin_expect((x),1)
-#define unlikely(x)     __builtin_expect((x),0)
+#define likely(x)       __builtin_expect((x)!=0,1)
+#define unlikely(x)     __builtin_expect((x)!=0,0)

?