On Sat, 2014-12-06 at 09:59 +0100, Niels Möller wrote:
> The idea of this macro is that
>
> 1. It should be possible to pass a context with the cipher element typed
> as a struct aes128_ctx, and encrypt as the function aes128_encrypt,
> without errors or warnings. To have the cast in one place, instead of
> sprinkled throughout application code.
>
> 2. The expression after the 0 ? should give some additional
> typechecking, so that, e.g, having a ctx->cipher of type aes128_ctx
> and encrypt as the function camellia128_crypt, you will get a warning
> from the compiler about bad first argument to camellia128_crypt.
>
> If you pass an encrypt function of type nettle_cipher_func (with a const
> void *) first argument, you get less type checking, but at least you
> should get a check on number of arguments, and integers vs pointers.
In modern compilers you cannot rely on that. The constructions if(0){}
and other impossible situations are optimized out early.
> Can you give an example usage where you'd want to get a compiler
> warning, but you don't get one?
The change of the cipher_func to accept a size_t instead of unsigned.
https://gitorious.org/gnutls/gnutls/commit/488cfe9a57840faeb2e35250757d8d33da32064f
regards,
Nikos
_______________________________________________
nettle-bugs mailing list
[email protected]
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs