[PATCH v3 03/16] make shared crypto code behave library-like
David Bremner
david at tethera.net
Tue Feb 9 18:37:04 PST 2016
Daniel Kahn Gillmor <dkg at fifthhorseman.net> writes:
> -static GMimeCryptoContext*
> -create_gpg_context (_notmuch_crypto_t *crypto)
> +static notmuch_status_t
> +get_gpg_context (_notmuch_crypto_t *crypto, GMimeCryptoContext **ctx)
I was a littled puzzled by this renaming. I guess it's fine, it just
creates a bit more diff noise.
> /* Create a PKCS7 context (GMime 2.6) */
> -static notmuch_crypto_context_t *
> -create_pkcs7_context (notmuch_crypto_t *crypto)
> +static notmuch_status_t
> +create_pkcs7_context (_notmuch_crypto_t *crypto, GMimeCryptoContext **ctx)
Especially since you only renamed the gpg version. Or did I miss
something?
> +notmuch_status_t
> +_notmuch_crypto_get_gmime_ctx_for_protocol (_notmuch_crypto_t *crypto,
> + const char *protocol,
> + GMimeCryptoContext **ctx)
> {
> - GMimeCryptoContext *cryptoctx = NULL;
> - size_t i;
> -
> - if (! protocol) {
> - fprintf (stderr, "Cryptographic protocol is empty.\n");
> - return cryptoctx;
> - }
> + if (! protocol)
> + return NOTMUCH_STATUS_MALFORMED_CRYPTO_PROTOCOL;
>
> /* As per RFC 1847 section 2.1: "the [protocol] value token is
> * comprised of the type and sub-type tokens of the Content-Type".
> @@ -112,15 +112,12 @@ _notmuch_crypto_get_gmime_context (_notmuch_crypto_t *crypto, const char *protoc
> * parameter names as defined in this document are
> * case-insensitive." Thus, we use strcasecmp for the protocol.
> */
> - for (i = 0; i < ARRAY_SIZE (protocols); i++) {
> + for (size_t i = 0; i < ARRAY_SIZE (protocols); i++) {
I forget whether we are using C99 for loop variable declarations. I
like them myself. If someone figures out the answer, maybe they can
update devel/STYLE.
d
More information about the notmuch
mailing list