Re: [PATCH] Fix up uses of BUG

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

 



On Thu, Jul 3, 2008 at 8:48 AM, Rik van Riel <riel@xxxxxxxxxxx> wrote:
> On Thu, 3 Jul 2008 04:02:50 -0500
> "Stoyan Gaydarov" <stoyboyker@xxxxxxxxx> wrote:
>
>> This is a patch based on the linux-2.6.26-rc8 kernel and it changes
>> the if(condition) BUG(); to the more desirable BUG_ON(condition);
>>
>> diff -uprN vanila/linux-2.6.26-rc8/fs/afs/rxrpc.c devel/fs/afs/rxrpc.c
>> --- vanila/linux-2.6.26-rc8/fs/afs/rxrpc.c      2008-07-03
>> 03:28:52.000000000 -0500
>> +++ devel/fs/afs/rxrpc.c        2008-07-03 03:31:40.000000000 -0500
>> @@ -139,8 +139,7 @@ static void afs_data_delivered(struct sk
>>         } else {
>>                 _debug("DLVR %p{%u} [%d]",
>>                        skb, skb->mark, atomic_read(&afs_outstanding_skbs));
>> -               if (atomic_dec_return(&afs_outstanding_skbs) == -1)
>> -                       BUG();
>> +               BUG_ON(atomic_dec_return(&afs_outstanding_skbs) == -1);
>
> This is a problem.
>
> Some embedded people compile their kernel without any debugging
> whatsoever, and will happily "#define BUG_ON(x) /* nothing */".
>
> This is OK for something like BUG_ON(a == NULL) because that
> only tests a variable (it has no side effects).

Thank you for the clarification, I wasn't too sure about the meaning
of no side effects in the case of BUG() and so this defiantly helps
clarify it. If I understand it correctly, because there is a function
call inside the BUG_ON() it would cause the unwanted side effect of
ignoring the line when debugging is turned off with the above
mentioned #define. Where as with (a==null) it is just comparing the
returned value which regardless of debugging settings will have its
value calculated even if its:
a = foo();
if(a==null)
   BUG();

>
> However, your patch would mean that the atomic_dec_return()
> would not be executed at all in those configurations!
>
> --
> All rights reversed.
>

Thank you for the feedback. I will look into trying a different file,
also I wanted to know if the Signed-off was done correctly because I
am not sure where else to put it.

-Stoyan

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux