[PATCH 4/6] cli: intialize crypto structure in show and reply

Jani Nikula jani at nikula.org
Thu May 17 09:31:59 PDT 2012


On May 17, 2012 5:26 PM, "Jameson Graef Rollins" <jrollins at finestructure.net>
wrote:
>
> On Thu, May 17 2012, Jani Nikula <jani at nikula.org> wrote:
> > On Thu, 17 May 2012, Jameson Graef Rollins <jrollins at finestructure.net>
wrote:
> >> This makes sure it has proper initialization values when it's created.
> >
> > Please don't do this. It's unnecessary; if one field is initialized with
> > a designated initializer, the rest are initialized to zero (or NULL).
>
> It may be technically unnecessary, but why is that a reason to not do
> it?  I intentionally did this to make it clear what the defaults are.
> Otherwise the defaults are essentially undefined, which is not good.
> Maybe the structure initializes to the correct defaults, but why count
> on that when we can set them to the correct default, and have it clear
> to readers of the code?

The values are not undefined, they are properly initialized, and we can
count on it. For sure, not maybe. If you want to explicitly set them for
clarity, it's a matter of taste. Personally I find it too verbose, but then
again notmuch code is generally fairly verbose. If you insist on it, please
at least drop the extra temp crypto variable, and initialize the struct in
one initializer.

BR,
Jani.

>
> jamie.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20120517/789057d3/attachment-0001.html>


More information about the notmuch mailing list