unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH 1/2] cli: abstract common config get/set code
Date: Wed, 15 Jan 2014 09:24:53 -0400	[thread overview]
Message-ID: <871u09js2i.fsf@zancas.localnet> (raw)
In-Reply-To: <1376839205-5115-1-git-send-email-jani@nikula.org>

Jani Nikula <jani@nikula.org> writes:

> Pretty straightforward abstraction similar to get/set list.
> ---
>  notmuch-config.c |   80 ++++++++++++++++++++----------------------------------
>  1 file changed, 29 insertions(+), 51 deletions(-)
>
> diff --git a/notmuch-config.c b/notmuch-config.c
> index befe9b5..305d213 100644
> --- a/notmuch-config.c
> +++ b/notmuch-config.c
> @@ -496,6 +496,29 @@ notmuch_config_is_new (notmuch_config_t *config)
>      return config->is_new;
>  }
>  
> +static const char *
> +_config_get (notmuch_config_t *config, char **field,
> +	     const char *group, const char *key)
> +{
> +    if (*field == NULL) {
> +	char *value;
> +	value = g_key_file_get_string (config->key_file, group, key, NULL);
> +	if (value) {
> +	    *field = talloc_strdup (config, value);
> +	    free (value);
> +	}
> +    }
> +    return *field;
> +}
> +

The use of NULL here is clear enough in the context of the patch, but I
think it deserves a comment in the code; it is not obviously just code
movement after the patch is applied.

      parent reply	other threads:[~2014-01-15 13:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-18 15:20 [PATCH 1/2] cli: abstract common config get/set code Jani Nikula
2013-08-18 15:20 ` [PATCH 2/2] cli: define config getters and setters using a macro Jani Nikula
2013-08-18 18:09   ` Tomi Ollila
2014-01-15 13:29   ` David Bremner
2014-01-15 13:24 ` David Bremner [this message]

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: https://notmuchmail.org/

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

  git send-email \
    --in-reply-to=871u09js2i.fsf@zancas.localnet \
    --to=david@tethera.net \
    --cc=jani@nikula.org \
    --cc=notmuch@notmuchmail.org \
    /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://yhetil.org/notmuch.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).