bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#50507: New function in Emacs GnuTLS implementation


From: Robert Pluim
Subject: bug#50507: New function in Emacs GnuTLS implementation
Date: Fri, 30 Sep 2022 16:32:16 +0200

>>>>> On Fri, 30 Sep 2022 09:49:30 -0400, Nikolaos Chatzikonstantinou 
>>>>> <nchatz314@gmail.com> said:
    Nikolaos> +static unsigned int
    Nikolaos> +key_file2_aux (Lisp_Object flags)
    Nikolaos> +{
    Nikolaos> +  unsigned int rv = 0;
    Nikolaos> +  Lisp_Object tail = flags;
    Nikolaos> +  FOR_EACH_TAIL_SAFE (tail)
    Nikolaos> +    {
    Nikolaos> +      Lisp_Object flag = XCAR (tail);
    Nikolaos> +      if (EQ (flag, Qgnutls_pkcs_plain))
    Nikolaos> + rv |= GNUTLS_PKCS_PLAIN;
    Nikolaos> +      else if(EQ (flag, Qgnutls_pkcs_pkcs12_3des))

Space after 'if' here and in the rest of the function

    Nikolaos> +# ifdef HAVE_GNUTLS_CERTIFICATE_SET_X509_KEY_FILE2
    Nikolaos> +       if (STRINGP (pass))
    Nikolaos> +         ret = gnutls_certificate_set_x509_key_file2
    Nikolaos> +           (x509_cred, SSDATA (certfile), SSDATA (keyfile), 
file_format,
    Nikolaos> +            SSDATA (pass), key_file2_aux (flags));
    Nikolaos> +       else if (NILP (pass) && plist_member (proplist, QCpass))
    Nikolaos> +         ret = gnutls_certificate_set_x509_key_file2
    Nikolaos> +           (x509_cred, SSDATA (certfile), SSDATA (keyfile), 
file_format,
    Nikolaos> +            NULL, key_file2_aux (flags));
    Nikolaos> +       else
    Nikolaos> +         ret = gnutls_certificate_set_x509_key_file
    Nikolaos> +           (x509_cred, SSDATA (certfile), SSDATA (keyfile), 
file_format);
    Nikolaos> +# else
    Nikolaos>         ret = gnutls_certificate_set_x509_key_file
    Nikolaos>           (x509_cred, SSDATA (certfile), SSDATA (keyfile), 
file_format);
    Nikolaos> +# endif

2 minor points:

- If you use an intermediate variable for
the C version of pass, you can set it correctly based on `plist_member'
etc, and only have one call to _file2 (as it is itʼs kind of
difficult to quickly see the difference between the two calls)
- I think you can then rework the #else/#endif here to avoid repetition of
the call to the  _file variant

Robert
-- 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]