On Mon, Mar 2, 2009 at 8:23 AM, Sandeep K Sinha <[email protected]> wrote:
>>>>>> new_transaction = kzalloc(sizeof(*new_transaction),
>
> Here new_transaction is a pointer and *new_transaction is its value.
> So, the value can be zero here ?
> Am I going wrong somewhere, manish ?
Yes, In C pointers, *new_transaction with sizeof will give the sizeof object.
/home/mkatiyar/progs> cat z.c
#include<stdio.h>
int main() {
int *ptr;
int i = 0;
ptr = &i;
printf("*ptr = %d, size = %d\n", *ptr, sizeof(*ptr));
return 0;
}
/home/mkatiyar/progs> ./a.out
*ptr = 0, size = 4
>
> If not then,
> May be its all about defensive programming, you know !!!
I also think so, and that is why I think this can be
removed.....because there are many places in current kernel code where
we are not checking for NULL after using __GFP_NOFAIL
Thanks -
Manish
>
> On Sun, Mar 1, 2009 at 10:59 PM, Manish Katiyar <[email protected]> wrote:
>> On Sun, Mar 1, 2009 at 10:42 PM, Sandeep K Sinha
>> <[email protected]> wrote:
>>> I meant, what if you invoke kzalloc with '0' by any chance.
>>> It will return and that too with a NULL.
>>
>> But here it is sizeof(transaction_t), which is definitely not zero.
>>
>> Thanks -
>> Manish
>>
>>
>>>
>>>
>>> On Sun, Mar 1, 2009 at 6:39 PM, Manish Katiyar <[email protected]> wrote:
>>>> On Sun, Mar 1, 2009 at 4:39 PM, Sandeep K Sinha <[email protected]>
>>>> wrote:
>>>>> On Sun, Mar 1, 2009 at 2:09 PM, Manish Katiyar <[email protected]> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> While going through jbd code, I was wondering why do we need to check
>>>>>> new_transaction for NULL, if we are passing __GFP_NOFAIL ?
>>>>>> Last code change around this code was when Ted converted kmalloc to
>>>>>> kzalloc, but since he also didn't remove it I am guessing there would
>>>>>> be some good reason for it. Can someone enlighten me ?
>>>>>>
>>>>>> start_this_handle() {
>>>>>> ..........
>>>>>> ..........
>>>>>> new_transaction = kzalloc(sizeof(*new_transaction),
>>>>>> GFP_NOFS|__GFP_NOFAIL);
>>>>>> if (!new_transaction) {
>>>>>> ret = -ENOMEM;
>>>>>> goto out;
>>>>>> }
>>>>>> ..........
>>>>>> }
>>>>>>
>>>>> True.
>>>>> I agree. What if (*new_transaction) is zero ???
>>>>
>>>> Sorry......... I didn't get you .
>>>>
>>>> Thanks -
>>>> Manish
>>>>
>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> Thanks -
>>>>>> Manish
>>>>>>
>>>>>> --
>>>>>> To unsubscribe from this list: send an email with
>>>>>> "unsubscribe kernelnewbies" to [email protected]
>>>>>> Please read the FAQ at http://kernelnewbies.org/FAQ
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Sandeep.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> “To learn is to change. Education is a process that changes the learner.”
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Regards,
>>> Sandeep.
>>>
>>>
>>>
>>>
>>>
>>>
>>> “To learn is to change. Education is a process that changes the learner.”
>>>
>>
>
>
>
> --
> Regards,
> Sandeep.
>
>
>
>
>
>
> “To learn is to change. Education is a process that changes the learner.”
>
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ