[gnutls-devel] GnuTLS | Mark second argument of function gnutls_x509_crt_equals2 as const (!1000)

Development of GNU's TLS library gnutls-devel at lists.gnutls.org
Tue May 21 18:41:46 CEST 2019




Uhg, that is hard-to-recognize issue with typedef'ing pointers. A good reason not to do so.

gcc -Wall shows it:
```
#include <string.h>
#include <stdio.h>

typedef char *str;
typedef const char *str_const;

int main(void)
{
        str s1 = strdup("a");
        str_const s2 = strdup("b");
        const str s3 = strdup("c"); // same as 'str const s3'

        *s1 = 'x'; // OK
        *s2 = 'y'; // error
        *s3 = 'z'; // OK
        s3 = NULL; // error, s3 is 'char * const' not a 'const char *'

        return 0;
}
```

That means we need an extra typedef to make use of 'const' for typedef'ed pointers. Ugly.

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/merge_requests/1000#note_172906659
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20190521/ba64670f/attachment.html>


More information about the Gnutls-devel mailing list