unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
To: Notmuch Mail <notmuch@notmuchmail.org>
Subject: Re: [PATCH 4/6] cli: intialize crypto structure in show and reply
Date: Fri, 18 May 2012 13:09:54 -0400	[thread overview]
Message-ID: <4FB68262.5010408@fifthhorseman.net> (raw)
In-Reply-To: <87txzdew84.fsf@nikula.org>

[-- Attachment #1: Type: text/plain, Size: 2087 bytes --]

On 05/18/2012 04:20 AM, Jani Nikula wrote:
> We have -Wextra, which enables -Wmissing-field-initializers, which
> requires us to use full initialization of struct fields when doing
> regular, non-designated initialization. The point is that you might
> introduce subtle bugs if you added new struct fields and forgot to check
> the initializations. (This is why we have e.g. { 0, 0, 0, 0, 0 } instead
> of just { 0 } in the initialization of notmuch_opt_desc_t arrays.)

i think we can agree that this is the right choice.  We might even want
to discourage non-designated initializations entirely.

> IMHO the whole point of designated initializers is that the
> initialization is not vulnerable to struct changes, and you can pick
> which fields you choose to initialize explicitly. Also, it has the added
> benefit of documenting the fields that are initialized, without having
> to look at the struct definition.

Agreed.

> Do we now want to initialize all struct fields explicitly, everywhere,
> even when using designated initializers? Isn't that the question then?

I'm not sure it has to be this dramatic and "all or nothing".  For
example, it could be reasonable to explicitly initialize some subobjects
and not others.  For example, the notmuch_crypto_t jamie is proposing
would effectively encode the default setting for the --verify and
--decrypt flags.  I could see wanting to explicitly initialize those
default policy choices, even if they happen to be identical to the
implicit "zero"ing.

> Won't that maintain and promote the misconception that explicit
> initialization is required, when it's really not, failing to educate the
> non-experts and planting a seed of doubt in the experts...?

i see your point here, which is why i'm not arguing that all subobjects
need to be explicitly initialized all the time.

> It's not always clear whether something is a matter of taste, style, or
> language paradigm. If it feels like a paradigm, sticking with it
> ultimately benefits *both* perspectives.

yep, understood.

	--dkg


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 1030 bytes --]

  reply	other threads:[~2012-05-18 17:10 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-16 21:55 [PATCH 0/6] cli: improve handling of crypto parameters contexts Jameson Graef Rollins
2012-05-16 21:55 ` [PATCH 1/6] cli: new crypto structure to store crypto contexts and parameters Jameson Graef Rollins
2012-05-16 21:55   ` [PATCH 2/6] cli: modify mime_node_context to use the new notmuch_crypto_t Jameson Graef Rollins
2012-05-16 21:55     ` [PATCH 3/6] cli: modify mime_node_open to take crypto struct as argument Jameson Graef Rollins
2012-05-16 21:55       ` [PATCH 4/6] cli: intialize crypto structure in show and reply Jameson Graef Rollins
2012-05-16 21:55         ` [PATCH 5/6] cli: new crypto verify flag to handle verification Jameson Graef Rollins
2012-05-16 21:55           ` [PATCH 6/6] cli: lazily create the crypto gpg context only when needed Jameson Graef Rollins
2012-05-17 22:29             ` Austin Clements
2012-05-17  7:47         ` [PATCH 4/6] cli: intialize crypto structure in show and reply Jani Nikula
2012-05-17 14:26           ` Jameson Graef Rollins
2012-05-17 16:31             ` Jani Nikula
2012-05-17 16:45               ` Jameson Graef Rollins
2012-05-17 20:23                 ` Jani Nikula
2012-05-17 20:53                   ` Jameson Graef Rollins
2012-05-17 21:51                 ` Daniel Kahn Gillmor
2012-05-18  6:59                   ` Tomi Ollila
2012-05-18  8:20                   ` Jani Nikula
2012-05-18 17:09                     ` Daniel Kahn Gillmor [this message]
2012-05-17 22:29         ` Austin Clements
2012-05-17  7:40       ` [PATCH 3/6] cli: modify mime_node_open to take crypto struct as argument Jani Nikula
2012-05-17 22:26       ` Austin Clements
2012-05-17  7:37     ` [PATCH 2/6] cli: modify mime_node_context to use the new notmuch_crypto_t Jani Nikula
2012-05-17  7:36   ` [PATCH 1/6] cli: new crypto structure to store crypto contexts and parameters Jani Nikula

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=4FB68262.5010408@fifthhorseman.net \
    --to=dkg@fifthhorseman.net \
    --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).