From: Jeff King <peff@peff.net>
To: Johannes Sixt <j6t@kdbg.org>
Cc: "René Scharfe" <l.s.r@web.de>,
"Git Mailing List" <git@vger.kernel.org>,
"Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCH] run-command: introduce CHILD_PROCESS_INIT
Date: Sun, 17 Aug 2014 04:48:32 -0400 [thread overview]
Message-ID: <20140817084832.GL23808@peff.net> (raw)
In-Reply-To: <53F05DE2.5080806@kdbg.org>
On Sun, Aug 17, 2014 at 09:46:42AM +0200, Johannes Sixt wrote:
> This is a step in the right direction, IMO. This way to initialize the
> struct feels mucth better because it does not depend on that the bit
> pattern of the NULL pointer is all zeros.
I think platforms with NULL as something besides all-bits-zero are a
lost cause with git. There are so many struct memsets that depend on
this (and it's probably not actually worth caring about).
> > +#define CHILD_PROCESS_INIT { NULL }
>
> I would have expected this to read
>
> #define CHILD_PROCESS_INIT { NULL, ARGV_ARRAY_INIT }
>
> It does change the bit pattern of the initialized struct child_process
> because ARGV_ARRAY_INIT uses a non-NULL address. But IMHO
> ARGV_ARRAY_INIT should be used here as a defensive measure.
I'd be OK with that. The argv_array code is specifically OK with an
all-bits-zero initialization. The only thing you don't get is that an
empty array is non-NULL, but that should never matter here (true, we'd
segfault if you didn't add anything to the array, but that is clearly a
bug that needs to be fixed either way).
I'm a little worried, though, that use sites without initializers would
be left behind. For example, git_proxy_connect uses xcalloc to allocate
the child_process, which results in all-bits-zero. If we want to start
caring about the initialization, we probably need to provide a
child_process_init() function and use it consistently.
-Peff
next prev parent reply other threads:[~2014-08-17 8:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-16 22:55 [PATCH] run-command: introduce CHILD_PROCESS_INIT René Scharfe
2014-08-17 7:12 ` Jeff King
2014-08-17 7:25 ` René Scharfe
2014-08-17 7:29 ` Jeff King
2014-08-17 7:46 ` Johannes Sixt
2014-08-17 8:48 ` Jeff King [this message]
2014-08-18 16:59 ` Junio C Hamano
2014-08-19 19:09 ` [PATCH v2 1/4] " René Scharfe
2014-08-19 19:10 ` [PATCH v2 2/4] run-command: introduce child_process_init() René Scharfe
2014-08-19 19:11 ` [PATCH v2 3/4] run-command: call run_command_v_opt_cd_env() instead of duplicating it René Scharfe
2014-08-19 19:11 ` [PATCH v2 4/4] run-command: inline prepare_run_command_v_opt() René Scharfe
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=20140817084832.GL23808@peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.org \
--cc=l.s.r@web.de \
/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.