[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gcc extension in get_user_pages



On Fri, May 16, 2003 at 05:33:58PM -0400, Ed L Cashin wrote:
> Hi.  In get_user_pages there is a C conditional operator with an
> omitted second operand:
> 
> 
>   if ( !vma || (pages && vma->vm_flags & VM_IO) || !(flags & vma->vm_flags) )
>         return i ? : -EFAULT;
> 
> I was unfamiliar with that syntax, couldn't find it in the C99
> standard, and finally found it in the gcc documentation, which says
> that
>    x ? : y 
> .. is the same as 
>    x ? x : y 
> 
> But it also says the extension is only useful when the first operand
> may contain a side effect.  In get_user_pages, i is a simple integer,
> and so the extension is just a confusing shorthand.  Is that right or
> is there some better reason than being one character shorter -- like
> maybe better asm gets produced when the extension is used?

I would bet it's used because it's two characters less to type... and
perhaps because anyone who wrote it is used to it and it's more readable
for them.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/