git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Alex Riesen <raa.lkml@gmail.com>
Cc: Thiago Farina <tfransosi@gmail.com>,
	git@vger.kernel.org, jrnieder@gmail.com, srabbelier@gmail.com
Subject: Re: [PATCH] string-list.h: Add STRING_LIST_INIT macro and make use of  it.
Date: Mon, 28 Jun 2010 22:43:25 -0700	[thread overview]
Message-ID: <7v4ogmcs1u.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: AANLkTim14fh1RRSoYFK5uIqi8OrkB2zHahInDpO80gws@mail.gmail.com

Alex Riesen <raa.lkml@gmail.com> writes:

>> But I wonder if this is worth it (not this "more complete", but your
>> patch). We convert 16 or so instances of initialization for "no strdup"
>> list, but there are about the same number of "strdup" instances still
>> spelled out:
>>
>>    $ git grep -e 'struct string_list [^ ]* = {.*'
>>    $ git grep -e 'struct string_list [^ ]* = {.*1'
>>
>> Wouldn't it be more sensible to use this instead?
>>
>>    #define STRING_LIST_INIT(pleasedup) { NULL, 0, 0, (pleasedup) }
>
> This begs for using strdup(string-to-dup) in the macro argument, which
> will not compile with ancient compilers which don't allow code in an
> initializer.

Err, one of us must be confused.

I was suggesting to rewrite things like these, found in builtin/remote.c
(add and rm):

	struct string_list track = { NULL, 0, 0, 0 };
	struct string_list branches = { NULL, 0, 0, 1 };

like so:

	#define STRING_LIST_INIT(pleasedup) { NULL, 0, 0, (pleasedup) }
	struct string_list track = STRING_LIST_INIT(0);
        struct string_list branches = STRING_LIST_INIT(1);

I don't see strdup in macro argument anywhere.

The original patch in this thread proposed to do this instead:

	#define STRING_LIST_INIT { NULL, 0, 0, 0 }
	struct string_list track = STRING_LIST_INIT;
        struct string_list branches = { NULL, 0, 0, 1 };

converting about half of initializers to the macro, and leaving the other
half spelled out.

  reply	other threads:[~2010-06-29  5:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-26 22:34 [PATCH] string-list.h: Add STRING_LIST_INIT macro and make use of it Thiago Farina
2010-06-26 22:53 ` Sverre Rabbelier
2010-06-26 23:04 ` Jonathan Nieder
2010-06-26 23:44   ` Thiago Farina
2010-06-26 23:40 ` Thiago Farina
2010-06-26 23:47   ` Thiago Farina
2010-06-27 16:44     ` Junio C Hamano
2010-06-28  8:29       ` Alex Riesen
2010-06-29  5:43         ` Junio C Hamano [this message]
2010-06-29  8:15           ` Peter Kjellerstedt
2010-06-29  8:33           ` Alex Riesen
2010-07-02 19:15       ` [PATCH] string_list: " Thiago Farina
2010-07-02 19:30         ` Jonathan Nieder
2010-07-02 19:47           ` Thiago Farina
2010-07-02 20:22             ` Jonathan Nieder
2010-07-04 19:46               ` Thiago Farina
2010-07-07 15:19                 ` Jonathan Nieder
2010-07-07 16:55                   ` Junio C Hamano
2010-07-10  5:01                   ` Thiago Farina
2010-07-10 22:41                     ` Jonathan Nieder
2010-08-19 13:28               ` Thiago Farina

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=7v4ogmcs1u.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=raa.lkml@gmail.com \
    --cc=srabbelier@gmail.com \
    --cc=tfransosi@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).