public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/10] use safer test on the result of find_first_zero_bit
@ 2014-06-04  9:07 Julia Lawall
  2014-06-04  9:07 ` [PATCH 8/10] s390/pci: " Julia Lawall
  2014-06-04  9:35 ` [PATCH 0/10] " Geert Uytterhoeven
  0 siblings, 2 replies; 12+ messages in thread
From: Julia Lawall @ 2014-06-04  9:07 UTC (permalink / raw)
  To: linux-rdma
  Cc: devel, linux-s390, linux-fbdev, linux-scsi, iss_storagedev,
	linux-sh, kernel-janitors, linux-wireless, linux-kernel, ath10k,
	adi-buildroot-devel, netdev

Find_first_zero_bit considers BITS_PER_LONG bits at a time, and thus may
return a larger number than the maximum position argument if that position
is not a multiple of BITS_PER_LONG.


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

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

* [PATCH 8/10] s390/pci: use safer test on the result of find_first_zero_bit
  2014-06-04  9:07 [PATCH 0/10] use safer test on the result of find_first_zero_bit Julia Lawall
@ 2014-06-04  9:07 ` Julia Lawall
  2014-06-04 11:09   ` Sebastian Ott
  2014-06-04  9:35 ` [PATCH 0/10] " Geert Uytterhoeven
  1 sibling, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2014-06-04  9:07 UTC (permalink / raw)
  To: Sebastian Ott
  Cc: kernel-janitors, Gerald Schaefer, Martin Schwidefsky,
	Heiko Carstens, linux390, linux-s390, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Find_first_zero_bit considers BITS_PER_LONG bits at a time, and thus may
return a larger number than the maximum position argument if that position
is not a multiple of BITS_PER_LONG.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e1,e2,e3;
statement S1,S2;
@@

e1 = find_first_zero_bit(e2,e3)
...
if (e1 
- ==
+ >=
  e3)
S1 else S2
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 arch/s390/pci/pci.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -566,7 +566,7 @@ static int zpci_alloc_iomap(struct zpci_
 
 	spin_lock(&zpci_iomap_lock);
 	entry = find_first_zero_bit(zpci_iomap, ZPCI_IOMAP_MAX_ENTRIES);
-	if (entry == ZPCI_IOMAP_MAX_ENTRIES) {
+	if (entry >= ZPCI_IOMAP_MAX_ENTRIES) {
 		spin_unlock(&zpci_iomap_lock);
 		return -ENOSPC;
 	}
@@ -746,7 +746,7 @@ static int zpci_alloc_domain(struct zpci
 {
 	spin_lock(&zpci_domain_lock);
 	zdev->domain = find_first_zero_bit(zpci_domain, ZPCI_NR_DEVICES);
-	if (zdev->domain == ZPCI_NR_DEVICES) {
+	if (zdev->domain >= ZPCI_NR_DEVICES) {
 		spin_unlock(&zpci_domain_lock);
 		return -ENOSPC;
 	}

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

* Re: [PATCH 0/10] use safer test on the result of find_first_zero_bit
  2014-06-04  9:07 [PATCH 0/10] use safer test on the result of find_first_zero_bit Julia Lawall
  2014-06-04  9:07 ` [PATCH 8/10] s390/pci: " Julia Lawall
@ 2014-06-04  9:35 ` Geert Uytterhoeven
  2014-06-04  9:38   ` Julia Lawall
  1 sibling, 1 reply; 12+ messages in thread
From: Geert Uytterhoeven @ 2014-06-04  9:35 UTC (permalink / raw)
  To: Julia Lawall
  Cc: driverdevel, linux-s390, Linux Fbdev development list, scsi,
	iss_storagedev, Linux-sh list, linux-rdma, linux-wireless,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	ath10k, adi-buildroot-devel, netdev@vger.kernel.org

Hi Julia,

On Wed, Jun 4, 2014 at 11:07 AM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> Find_first_zero_bit considers BITS_PER_LONG bits at a time, and thus may
> return a larger number than the maximum position argument if that position
> is not a multiple of BITS_PER_LONG.

Shouldn't this be fixed in find_first_zero_bit() instead?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

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

* Re: [PATCH 0/10] use safer test on the result of find_first_zero_bit
  2014-06-04  9:35 ` [PATCH 0/10] " Geert Uytterhoeven
@ 2014-06-04  9:38   ` Julia Lawall
  2014-06-04  9:46     ` David Laight
  0 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2014-06-04  9:38 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: driverdevel, linux-s390, Linux Fbdev development list, scsi,
	iss_storagedev, Linux-sh list, linux-rdma, linux-wireless,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	ath10k, adi-buildroot-devel, Julia Lawall, netdev@vger.kernel.org



On Wed, 4 Jun 2014, Geert Uytterhoeven wrote:

> Hi Julia,
>
> On Wed, Jun 4, 2014 at 11:07 AM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> > Find_first_zero_bit considers BITS_PER_LONG bits at a time, and thus may
> > return a larger number than the maximum position argument if that position
> > is not a multiple of BITS_PER_LONG.
>
> Shouldn't this be fixed in find_first_zero_bit() instead?

OK, I could do that as well.  Most of the callers currently test with >=.
Should they be left as is, or changed to use ==?

julia

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

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

* RE: [PATCH 0/10] use safer test on the result of find_first_zero_bit
  2014-06-04  9:38   ` Julia Lawall
@ 2014-06-04  9:46     ` David Laight
  2014-06-04  9:52       ` Julia Lawall
  0 siblings, 1 reply; 12+ messages in thread
From: David Laight @ 2014-06-04  9:46 UTC (permalink / raw)
  To: 'Julia Lawall', Geert Uytterhoeven
  Cc: driverdevel, linux-s390, Linux Fbdev development list, scsi,
	iss_storagedev@hp.com, Linux-sh list, linux-rdma, linux-wireless,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	ath10k@lists.infradead.org,
	adi-buildroot-devel@lists.sourceforge.net, netdev@vger.kernel.org

From: Julia Lawall
> On Wed, 4 Jun 2014, Geert Uytterhoeven wrote:
> 
> > Hi Julia,
> >
> > On Wed, Jun 4, 2014 at 11:07 AM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> > > Find_first_zero_bit considers BITS_PER_LONG bits at a time, and thus may
> > > return a larger number than the maximum position argument if that position
> > > is not a multiple of BITS_PER_LONG.
> >
> > Shouldn't this be fixed in find_first_zero_bit() instead?
> 
> OK, I could do that as well.  Most of the callers currently test with >=.
> Should they be left as is, or changed to use ==?

Do we want to add an extra test to find_first_zero_bit() and effectively
slow down all the calls - especially those where the length is a
multiple of 8 (probably the most common).

Maybe the documented return code should be changed to allow for the
existing behaviour.

	David




_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

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

* RE: [PATCH 0/10] use safer test on the result of find_first_zero_bit
  2014-06-04  9:46     ` David Laight
@ 2014-06-04  9:52       ` Julia Lawall
  2014-06-04 10:55         ` Geert Uytterhoeven
  0 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2014-06-04  9:52 UTC (permalink / raw)
  To: David Laight
  Cc: driverdevel, linux-s390, Linux Fbdev development list, scsi,
	iss_storagedev@hp.com, Linux-sh list, linux-rdma, linux-wireless,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	ath10k@lists.infradead.org,
	adi-buildroot-devel@lists.sourceforge.net, 'Julia Lawall',
	Geert Uytterhoeven, netdev@vger.kernel.org



On Wed, 4 Jun 2014, David Laight wrote:

> From: Julia Lawall
> > On Wed, 4 Jun 2014, Geert Uytterhoeven wrote:
> >
> > > Hi Julia,
> > >
> > > On Wed, Jun 4, 2014 at 11:07 AM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> > > > Find_first_zero_bit considers BITS_PER_LONG bits at a time, and thus may
> > > > return a larger number than the maximum position argument if that position
> > > > is not a multiple of BITS_PER_LONG.
> > >
> > > Shouldn't this be fixed in find_first_zero_bit() instead?
> >
> > OK, I could do that as well.  Most of the callers currently test with >=.
> > Should they be left as is, or changed to use ==?
>
> Do we want to add an extra test to find_first_zero_bit() and effectively
> slow down all the calls - especially those where the length is a
> multiple of 8 (probably the most common).

Currently, most of the calls test with >=, and most of the others seem to
need to (either the size value did not look like a multiple of anything in
particular, or it was eg read from a device).

Note that it is BITS_PER_LONG, so it seems like it is typically 32 or 64,
not 8.

> Maybe the documented return code should be changed to allow for the
> existing behaviour.

Sorry, I'm not sure to understand what you suggest here.

thanks,
julia

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

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

* Re: [PATCH 0/10] use safer test on the result of find_first_zero_bit
  2014-06-04  9:52       ` Julia Lawall
@ 2014-06-04 10:55         ` Geert Uytterhoeven
  2014-06-04 11:00           ` Julia Lawall
  0 siblings, 1 reply; 12+ messages in thread
From: Geert Uytterhoeven @ 2014-06-04 10:55 UTC (permalink / raw)
  To: Julia Lawall
  Cc: driverdevel, linux-s390, Linux Fbdev development list, scsi,
	iss_storagedev@hp.com, Linux-sh list, linux-rdma, linux-wireless,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	ath10k@lists.infradead.org,
	adi-buildroot-devel@lists.sourceforge.net, David Laight,
	Arnd Bergmann, netdev@vger.kernel.org

Hi Julia,

On Wed, Jun 4, 2014 at 11:52 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> Maybe the documented return code should be changed to allow for the
>> existing behaviour.
>
> Sorry, I'm not sure to understand what you suggest here.

include/asm-generic/bitops/find.h:

| /**
|  * find_first_zero_bit - find the first cleared bit in a memory region
|  * @addr: The address to start the search at
|  * @size: The maximum number of bits to search
|  *
|  * Returns the bit number of the first cleared bit.
|  * If no bits are zero, returns @size.

"If no bits are zero, returns @size or a number larger than @size."

|  */
| extern unsigned long find_first_zero_bit(const unsigned long *addr,
|                                          unsigned long size);

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

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

* Re: [PATCH 0/10] use safer test on the result of find_first_zero_bit
  2014-06-04 10:55         ` Geert Uytterhoeven
@ 2014-06-04 11:00           ` Julia Lawall
  2014-06-04 11:07             ` Geert Uytterhoeven
  0 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2014-06-04 11:00 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: driverdevel, linux-s390, Linux Fbdev development list, scsi,
	iss_storagedev@hp.com, Linux-sh list, linux-rdma, linux-wireless,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	ath10k@lists.infradead.org,
	adi-buildroot-devel@lists.sourceforge.net, Julia Lawall,
	David Laight, Arnd Bergmann, netdev@vger.kernel.org



On Wed, 4 Jun 2014, Geert Uytterhoeven wrote:

> Hi Julia,
>
> On Wed, Jun 4, 2014 at 11:52 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >> Maybe the documented return code should be changed to allow for the
> >> existing behaviour.
> >
> > Sorry, I'm not sure to understand what you suggest here.
>
> include/asm-generic/bitops/find.h:
>
> | /**
> |  * find_first_zero_bit - find the first cleared bit in a memory region
> |  * @addr: The address to start the search at
> |  * @size: The maximum number of bits to search
> |  *
> |  * Returns the bit number of the first cleared bit.
> |  * If no bits are zero, returns @size.
>
> "If no bits are zero, returns @size or a number larger than @size."

OK, thanks.  I was only looking at the C code.

But the C code contains a loop that is followed by:

        if (!size)
                return result;
        tmp = *p;

found_first:
        tmp |= ~0UL << size;
        if (tmp == ~0UL)        /* Are any bits zero? */
                return result + size;   /* Nope. */

In the first return, it would seem that result == size.  Could the second
one be changed to just return size?  It should not hurt performance.

julia

>
> |  */
> | extern unsigned long find_first_zero_bit(const unsigned long *addr,
> |                                          unsigned long size);
>
> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds
>

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

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

* Re: [PATCH 0/10] use safer test on the result of find_first_zero_bit
  2014-06-04 11:00           ` Julia Lawall
@ 2014-06-04 11:07             ` Geert Uytterhoeven
  2014-06-04 13:12               ` Julia Lawall
  0 siblings, 1 reply; 12+ messages in thread
From: Geert Uytterhoeven @ 2014-06-04 11:07 UTC (permalink / raw)
  To: Julia Lawall
  Cc: driverdevel, linux-s390, Linux Fbdev development list, scsi,
	iss_storagedev@hp.com, Linux-sh list, linux-rdma, linux-wireless,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	ath10k@lists.infradead.org,
	adi-buildroot-devel@lists.sourceforge.net, David Laight,
	Arnd Bergmann, netdev@vger.kernel.org

Hi Julia,

On Wed, Jun 4, 2014 at 1:00 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> OK, thanks.  I was only looking at the C code.
>
> But the C code contains a loop that is followed by:
>
>         if (!size)
>                 return result;
>         tmp = *p;
>
> found_first:
>         tmp |= ~0UL << size;
>         if (tmp == ~0UL)        /* Are any bits zero? */
>                 return result + size;   /* Nope. */
>
> In the first return, it would seem that result == size.  Could the second
> one be changed to just return size?  It should not hurt performance.

"size" may have been changed between function entry and this line.
So you have to store it in a temporary.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

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

* Re: [PATCH 8/10] s390/pci: use safer test on the result of find_first_zero_bit
  2014-06-04  9:07 ` [PATCH 8/10] s390/pci: " Julia Lawall
@ 2014-06-04 11:09   ` Sebastian Ott
  0 siblings, 0 replies; 12+ messages in thread
From: Sebastian Ott @ 2014-06-04 11:09 UTC (permalink / raw)
  To: Julia Lawall
  Cc: kernel-janitors, Gerald Schaefer, Martin Schwidefsky,
	Heiko Carstens, linux390, linux-s390, linux-kernel

On Wed, 4 Jun 2014, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> Find_first_zero_bit considers BITS_PER_LONG bits at a time, and thus may
> return a larger number than the maximum position argument if that position
> is not a multiple of BITS_PER_LONG.
> 
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> expression e1,e2,e3;
> statement S1,S2;
> @@
> 
> e1 = find_first_zero_bit(e2,e3)
> ...
> if (e1 
> - ==
> + >=
>   e3)
> S1 else S2
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
>  arch/s390/pci/pci.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff -u -p a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -566,7 +566,7 @@ static int zpci_alloc_iomap(struct zpci_
> 
>  	spin_lock(&zpci_iomap_lock);
>  	entry = find_first_zero_bit(zpci_iomap, ZPCI_IOMAP_MAX_ENTRIES);
> -	if (entry == ZPCI_IOMAP_MAX_ENTRIES) {
> +	if (entry >= ZPCI_IOMAP_MAX_ENTRIES) {
>  		spin_unlock(&zpci_iomap_lock);
>  		return -ENOSPC;
>  	}
> @@ -746,7 +746,7 @@ static int zpci_alloc_domain(struct zpci
>  {
>  	spin_lock(&zpci_domain_lock);
>  	zdev->domain = find_first_zero_bit(zpci_domain, ZPCI_NR_DEVICES);
> -	if (zdev->domain == ZPCI_NR_DEVICES) {
> +	if (zdev->domain >= ZPCI_NR_DEVICES) {
>  		spin_unlock(&zpci_domain_lock);
>  		return -ENOSPC;
>  	}
> 
> 

Thanks, applied.
Sebastian

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

* Re: [PATCH 0/10] use safer test on the result of find_first_zero_bit
  2014-06-04 11:07             ` Geert Uytterhoeven
@ 2014-06-04 13:12               ` Julia Lawall
  2014-06-04 13:34                 ` David Laight
  0 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2014-06-04 13:12 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: driverdevel, linux-s390, Linux Fbdev development list, scsi,
	iss_storagedev@hp.com, Linux-sh list, linux-rdma, linux-wireless,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	ath10k@lists.infradead.org,
	adi-buildroot-devel@lists.sourceforge.net, Julia Lawall,
	David Laight, Arnd Bergmann, netdev@vger.kernel.org, sebott



On Wed, 4 Jun 2014, Geert Uytterhoeven wrote:

> Hi Julia,
>
> On Wed, Jun 4, 2014 at 1:00 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> > OK, thanks.  I was only looking at the C code.
> >
> > But the C code contains a loop that is followed by:
> >
> >         if (!size)
> >                 return result;
> >         tmp = *p;
> >
> > found_first:
> >         tmp |= ~0UL << size;
> >         if (tmp == ~0UL)        /* Are any bits zero? */
> >                 return result + size;   /* Nope. */
> >
> > In the first return, it would seem that result == size.  Could the second
> > one be changed to just return size?  It should not hurt performance.
>
> "size" may have been changed between function entry and this line.
> So you have to store it in a temporary.

Sorry, after reflection it seems that indeed size + result is always the
original size, so it is actually all of the code that uses >= that is
doing something unnecessary.  == for the failure test is fine.

julia

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

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

* RE: [PATCH 0/10] use safer test on the result of find_first_zero_bit
  2014-06-04 13:12               ` Julia Lawall
@ 2014-06-04 13:34                 ` David Laight
  0 siblings, 0 replies; 12+ messages in thread
From: David Laight @ 2014-06-04 13:34 UTC (permalink / raw)
  To: 'Julia Lawall', Geert Uytterhoeven
  Cc: driverdevel, linux-s390, Linux Fbdev development list, scsi,
	iss_storagedev@hp.com, Linux-sh list, linux-rdma, linux-wireless,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	ath10k@lists.infradead.org,
	adi-buildroot-devel@lists.sourceforge.net, Arnd Bergmann,
	netdev@vger.kernel.org, sebott@linux.vnet.ibm.com

From: Julia Lawall
> On Wed, 4 Jun 2014, Geert Uytterhoeven wrote:
> 
> > Hi Julia,
> >
> > On Wed, Jun 4, 2014 at 1:00 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> > > OK, thanks.  I was only looking at the C code.
> > >
> > > But the C code contains a loop that is followed by:
> > >
> > >         if (!size)
> > >                 return result;
> > >         tmp = *p;
> > >
> > > found_first:
> > >         tmp |= ~0UL << size;
> > >         if (tmp == ~0UL)        /* Are any bits zero? */
> > >                 return result + size;   /* Nope. */
> > >
> > > In the first return, it would seem that result == size.  Could the second
> > > one be changed to just return size?  It should not hurt performance.
> >
> > "size" may have been changed between function entry and this line.
> > So you have to store it in a temporary.
> 
> Sorry, after reflection it seems that indeed size + result is always the
> original size, so it is actually all of the code that uses >= that is
> doing something unnecessary.  == for the failure test is fine.

There is nothing wrong with defensive coding.
The 'tmp |= ~0UL << size' ensures that the return value is 'correct'
when there are no bits set.
The function could have been defined so that this wasn't needed.

If you assume that the 'no zero bits' is unlikely, then checking the
return value from ffz() could well be slightly faster.
Not that anything is likely to notice.

	David




_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

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

end of thread, other threads:[~2014-06-04 13:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-04  9:07 [PATCH 0/10] use safer test on the result of find_first_zero_bit Julia Lawall
2014-06-04  9:07 ` [PATCH 8/10] s390/pci: " Julia Lawall
2014-06-04 11:09   ` Sebastian Ott
2014-06-04  9:35 ` [PATCH 0/10] " Geert Uytterhoeven
2014-06-04  9:38   ` Julia Lawall
2014-06-04  9:46     ` David Laight
2014-06-04  9:52       ` Julia Lawall
2014-06-04 10:55         ` Geert Uytterhoeven
2014-06-04 11:00           ` Julia Lawall
2014-06-04 11:07             ` Geert Uytterhoeven
2014-06-04 13:12               ` Julia Lawall
2014-06-04 13:34                 ` David Laight

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