Skip to contentSkip to conversation

ugly warnings with likely/unlikely

DISCUSSION Andi Kleen 2 participants 2 messages Jan 13, 2002 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Andi Kleen

author
#1 lore raw
Quoted 6 lines · [email protected] (Oliver Neukum) writes:

Hi,

if (likely(stru->pointer))

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

Just use

if (!stru->pointer) { 
	...
}

instead. gcc and a lot of other compilers predict all pointer tests against NULL as unlikely, unless you override that.

-Andi (who is a bit worried about the unlikelies multiplicating like rabbits)

#2 lore raw
Quoted 1 line · Andi Kleen

-Andi (who is a bit worried about the unlikelies multiplicating like rabbits)

Indeed. People need to realize unlikely is not a free ride.

Robert Love