[gnutls-devel] GnuTLS | Datum.c cleanup (!1002)
Development of GNU's TLS library
gnutls-devel at lists.gnutls.org
Tue May 28 17:23:40 CEST 2019
Tim Rühsen commented on a discussion on lib/datum.c: https://gitlab.com/gnutls/gnutls/merge_requests/1002#note_175405708
>
> /* ensures that the data set are null-terminated
> * The function always returns an allocated string in @dat on success.
> + * On error, @dat is not changed.
> */
> int
> _gnutls_set_strdatum(gnutls_datum_t * dat, const void *data, size_t data_size)
> {
> - if (data_size == 0 || data == NULL) {
> - dat->data = gnutls_calloc(1, 1);
> - dat->size = 0;
> - return 0;
> - }
> + if (data == NULL)
`data` comes from sources that are not trackable, e.g. by build-scan. Thus, using a `nonnull` attribute would lead to warnings that you can't easily work around. Also, `nonnull` will remove checks against NULL when optimization is on. The only way currently is to check data against NULL and not use `nonnull`.
We *could* remove that check if `data_size` is 0 and `data` is NULL. Not sure if that is guaranteed everywhere (it should, though). Your above comments made me nervous about that.
--
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/merge_requests/1002#note_175405708
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/20190528/53f32328/attachment.html>
More information about the Gnutls-devel
mailing list