Re: [PATCH] Fix a bunch of pointer declarations (codestyle)

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

 



Jeff King <peff@xxxxxxxx> writes:

> On Fri, May 01, 2009 at 12:20:08PM -0700, Stephen Boyd wrote:
>
>> On Fri, May 1, 2009 at 2:06 AM, Felipe Contreras
>> <felipe.contreras@xxxxxxxxx> wrote:
>> >
>> > -       *argv = xmalloc(sizeof(char*) * size);
>> > +       *argv = xmalloc(sizeof(char *) * size);
>> >
>> 
>> I don't think this is what the coding guidelines is talking about. A
>> pointer isn't being declared here plus there isn't any variable the
>> star should be sticking to.

I think either way is fine although I personally prefer the way the patch
did.  The "prefer sizeof(var) over sizeof(type)" principle is good, but
that should be a follow-up patch, as it is very likely such a conversion
will introduce a silly mistake, perhaps like this one.

> Besides that, don't we usually prefer sizeof() on the actual variable
> instead of the type, which is less error prone? IOW,
>
>   *argv = xmalloc(sizeof(**argv) * size);
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]