All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Stephen Boyd <bebarino@gmail.com>,
	Felipe Contreras <felipe.contreras@gmail.com>,
	git@vger.kernel.org
Subject: Re: [PATCH] Fix a bunch of pointer declarations (codestyle)
Date: Fri, 01 May 2009 15:59:57 -0700	[thread overview]
Message-ID: <7veiv8v382.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20090501203910.GA15549@coredump.intra.peff.net> (Jeff King's message of "Fri, 1 May 2009 16:39:10 -0400")

Jeff King <peff@peff.net> 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@gmail.com> 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);

  reply	other threads:[~2009-05-01 23:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-01  9:06 [PATCH] Fix a bunch of pointer declarations (codestyle) Felipe Contreras
2009-05-01  9:07 ` Felipe Contreras
2009-05-01 19:20 ` Stephen Boyd
2009-05-01 20:39   ` Jeff King
2009-05-01 22:59     ` Junio C Hamano [this message]
2009-05-01 22:37 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7veiv8v382.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=bebarino@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.