[PATCH 4/6] cli: intialize crypto structure in show and reply
Austin Clements
amdragon at MIT.EDU
Thu May 17 15:29:04 PDT 2012
Quoth Jameson Graef Rollins on May 16 at 2:55 pm:
> This makes sure it has proper initialization values when it's created.
> ---
> notmuch-reply.c | 5 ++++-
> notmuch-show.c | 10 +++++++++-
> 2 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/notmuch-reply.c b/notmuch-reply.c
> index 6662adb..3c967a0 100644
> --- a/notmuch-reply.c
> +++ b/notmuch-reply.c
> @@ -673,7 +673,10 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
> char *query_string;
> int opt_index, ret = 0;
> int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_crypto_t *crypto, notmuch_bool_t reply_all);
> - notmuch_crypto_t crypto = { .decrypt = FALSE };
> + notmuch_crypto_t crypto = {
> + .decrypt = FALSE,
> + .gpgctx = NULL,
> + };
> int format = FORMAT_DEFAULT;
> int reply_all = TRUE;
>
> diff --git a/notmuch-show.c b/notmuch-show.c
> index 8b4d308..c606333 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -983,7 +983,15 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
> char *query_string;
> int opt_index, ret;
> const notmuch_show_format_t *format = &format_text;
> - notmuch_show_params_t params = { .part = -1, .omit_excluded = TRUE };
> + notmuch_crypto_t crypto = {
> + .decrypt = FALSE,
> + .gpgctx = NULL,
> + };
> + notmuch_show_params_t params = {
> + .part = -1,
> + .omit_excluded = TRUE,
> + .crypto = crypto,
> + };
You can omit the temporary variable and avoid the struct copy by doing
something like this:
notmuch_show_params_t params = {
.part = -1,
.omit_excluded = TRUE,
.crypto = {
.decrypt = FALSE,
.gpgctx = NULL,
},
};
> int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
> notmuch_bool_t verify = FALSE;
> int exclude = EXCLUDE_TRUE;
More information about the notmuch
mailing list