public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* ugly warnings with likely/unlikely
@ 2002-01-13 12:05 Oliver Neukum
  2002-01-13 15:07 ` Alan Cox
  0 siblings, 1 reply; 6+ messages in thread
From: Oliver Neukum @ 2002-01-13 12:05 UTC (permalink / raw)
  To: linux-kernel

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ugly warnings with likely/unlikely
  2002-01-13 15:07 ` Alan Cox
@ 2002-01-13 15:06   ` Oliver Neukum
  2002-01-13 20:12   ` Andrew Morton
  1 sibling, 0 replies; 6+ messages in thread
From: Oliver Neukum @ 2002-01-13 15:06 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel

On Sunday 13 January 2002 16:07, Alan Cox wrote:
> > 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ugly warnings with likely/unlikely
  2002-01-13 12:05 ugly warnings with likely/unlikely Oliver Neukum
@ 2002-01-13 15:07 ` Alan Cox
  2002-01-13 15:06   ` Oliver Neukum
  2002-01-13 20:12   ` Andrew Morton
  0 siblings, 2 replies; 6+ messages in thread
From: Alan Cox @ 2002-01-13 15:07 UTC (permalink / raw)
  To: Oliver.Neukum; +Cc: linux-kernel

> 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 ?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ugly warnings with likely/unlikely
       [not found] <16PjOb-0oLbCCC@fwd11.sul.t-online.com.suse.lists.linux.kernel>
@ 2002-01-13 17:27 ` Andi Kleen
  2002-01-13 18:26   ` Robert Love
  0 siblings, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2002-01-13 17:27 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: linux-kernel

520047054719-0001@t-online.de (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)
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ugly warnings with likely/unlikely
  2002-01-13 17:27 ` Andi Kleen
@ 2002-01-13 18:26   ` Robert Love
  0 siblings, 0 replies; 6+ messages in thread
From: Robert Love @ 2002-01-13 18:26 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Oliver Neukum, linux-kernel

On Sun, 2002-01-13 at 12:27, Andi Kleen wrote:

> -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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ugly warnings with likely/unlikely
  2002-01-13 15:07 ` Alan Cox
  2002-01-13 15:06   ` Oliver Neukum
@ 2002-01-13 20:12   ` Andrew Morton
  1 sibling, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2002-01-13 20:12 UTC (permalink / raw)
  To: Alan Cox; +Cc: Oliver.Neukum, linux-kernel

Alan Cox wrote:
> 
> > 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)

?

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-01-13 20:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-01-13 12:05 ugly warnings with likely/unlikely Oliver Neukum
2002-01-13 15:07 ` Alan Cox
2002-01-13 15:06   ` Oliver Neukum
2002-01-13 20:12   ` Andrew Morton
     [not found] <16PjOb-0oLbCCC@fwd11.sul.t-online.com.suse.lists.linux.kernel>
2002-01-13 17:27 ` Andi Kleen
2002-01-13 18:26   ` Robert Love

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox