git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Govind Salinas" <govind@sophiasuchtig.com>
To: "Junio C Hamano" <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [Janitors] value could be NULL in config parser
Date: Fri, 8 Feb 2008 19:20:34 -0600	[thread overview]
Message-ID: <5d46db230802081720x122a807do6c63b6b3e435b4c5@mail.gmail.com> (raw)
In-Reply-To: <7v63x0lzhw.fsf@gitster.siamese.dyndns.org>

On 2/8/08, Junio C Hamano <gitster@pobox.com> wrote:
> A callback function of git_config() is called when the command
> reads value from .git/config and friends.  The function takes
> two parameters, var and value.  var is never NULL and it is the
> name of the configuration variable found in the file being
> read.  value could be either string or NULL.
>
> A NULL value is boolean "true".  For example, on MS-DOS, you may
> have something like this:
>
>         [core]
>                 autocrlf
>
> and your callback will be called with var = "core.autocrlf" and
> value = NULL in such a case.
>
> If you want to fix them (you do not have to do all of them, and
> if you would like to help, please make one patch per function
> fixed), the procedure is:
>

I think I got all the erroneous ones.  I did

find . -name "*.c" | xargs grep git_config\( | awk '{ idx = index($2,
")"); p = substr($2, 12, idx - 12); print  p }' | sort | uniq -u

To try and get a list of all the ones that might need updating.  I did
notice that most functions never check value for null, but they don't
directly access them.  They pass them off to other methods.  As far as
I can tell, some of these methods don't validate the NULL.  So they
will need to be updated.

Question.  Wouldn't it reduce the amount of validation we have to do
if whoever is calling back checked null and assigned an empty string?
If so, we can probably replace all these patches with one patch.

-Govind

  parent reply	other threads:[~2008-02-09  1:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-08  6:43 [Janitors] value could be NULL in config parser Junio C Hamano
2008-02-08 14:26 ` [PATCH] archive-tar.c: guard config parser from value=NULL Miklos Vajna
2008-02-08 14:26 ` [PATCH] builtin-gc.c: " Miklos Vajna
2008-02-08 14:26 ` [PATCH] remote.c: " Miklos Vajna
2008-02-08 16:34   ` Michele Ballabio
2008-02-08 14:27 ` [PATCH] setup.c: " Miklos Vajna
2008-02-08 16:34   ` Michele Ballabio
2008-02-08 21:29     ` Miklos Vajna
2008-02-08 17:07 ` [Janitors] value could be NULL in config parser Govind Salinas
2008-02-09  1:20 ` Govind Salinas [this message]
2008-02-09  5:41   ` Christian Couder
2008-02-09  6:04     ` Junio C Hamano
2008-02-09 10:18   ` Christian Couder
2008-02-09 13:15     ` Christian Couder
2008-02-09 20:11       ` Govind Salinas

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=5d46db230802081720x122a807do6c63b6b3e435b4c5@mail.gmail.com \
    --to=govind@sophiasuchtig.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
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 NNTP newsgroup(s).