lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Wed, 15 Aug 2007 18:42:30 -0400
From:	Chuck Lever <chuck.lever@...cle.com>
To:	Andi Kleen <andi@...stfloor.org>
CC:	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Eliminate result signage problem in asm-x86_64/bitops.h

I apologize for sending a separate cover letter for a single patch.

Andi Kleen wrote:
> On Wed, Aug 15, 2007 at 05:02:47PM -0400, Chuck Lever wrote:
>> The return type of __scanbit() doesn't match the return type of
>> find_{first,next}_bit().  Thus when you construct something like
>> this:
>>
>>    boolean ? __scanbit() : find_first_bit()
> 
> Why would you want to write this?  What is boolean?
> Do they have different arguments?

So here's the definition of the x86_64 find_first_bit() macro, straight 
from include/x86_64/bitops.h:

#define find_first_bit(addr,size) \
((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \
   (__scanbit(*(unsigned long *)addr,(size))) : \
   find_first_bit(addr,size)))

In this case "boolean" is:

    __builtin_constant_p(size) && (size) <= BITS_PER_LONG

the first arm of the conditional is:

    __scanbit(*(unsigned long *)addr,(size))

the second arm of the conditional is:

    find_first_bit(addr,size)

(this is the "function" version of find_first_bit, not the macro that's 
being defined.  The naming here is unfortunately confusing).

Thus, roughly speaking, when the type of "size" is smaller than a long, 
the macro's return type evaluates to unsigned long.  If "size" is larger 
than a long, the macro's return type evaluates to signed long.

By making the return type of __scanbit() an unsigned long, both arms of 
the conditional evaluate to the same result type.

> It's on my todo list for some time to special case
> f_f_b() and friends for smaller arguments. Would
> that eliminate this construct?

Well, I can only assume what you mean by this, but I think that would 
address the problem.

My real interest here is to eliminate a whole lot of compiler noise when 
I enable -Wsign-compare for certain parts of the kernel.

View attachment "chuck.lever.vcf" of type "text/x-vcard" (291 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ