From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDYW4-0002km-AS for qemu-devel@nongnu.org; Fri, 10 Jul 2015 09:39:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZDYW0-0007am-O7 for qemu-devel@nongnu.org; Fri, 10 Jul 2015 09:39:00 -0400 Received: from mail-vn0-f51.google.com ([209.85.216.51]:35983) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDYW0-0007aX-KD for qemu-devel@nongnu.org; Fri, 10 Jul 2015 09:38:56 -0400 Received: by vnbg129 with SMTP id g129so38199482vnb.3 for ; Fri, 10 Jul 2015 06:38:56 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20150710133131.GB3818@potion.brq.redhat.com> References: <1436531615-30183-1-git-send-email-rkrcmar@redhat.com> <20150710133131.GB3818@potion.brq.redhat.com> From: Peter Maydell Date: Fri, 10 Jul 2015 14:38:36 +0100 Message-ID: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] crypt: fix build with nettle >= 3.0.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Cc: QEMU Developers On 10 July 2015 at 14:31, Radim Kr=C4=8Dm=C3=A1=C5=99 = wrote: > 2015-07-10 13:56+0100, Peter Maydell: >> On 10 July 2015 at 13:33, Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: >>> @@ -83,8 +87,8 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgori= thm alg, >>> - ctx->alg_encrypt =3D (nettle_crypt_func *)des_encrypt; >>> - ctx->alg_decrypt =3D (nettle_crypt_func *)des_decrypt; >>> + ctx->alg_encrypt =3D (nettle_cipher_func *)des_encrypt; >>> + ctx->alg_decrypt =3D (nettle_cipher_func *)des_decrypt; >>> @@ -98,8 +102,8 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgor= ithm alg, >>> - ctx->alg_encrypt =3D (nettle_crypt_func *)aes_encrypt; >>> - ctx->alg_decrypt =3D (nettle_crypt_func *)aes_decrypt; >>> + ctx->alg_encrypt =3D (nettle_cipher_func *)aes_encrypt; >>> + ctx->alg_decrypt =3D (nettle_cipher_func *)aes_decrypt; >> >> Why do we need the casts here at all? If the functions >> we're passing around don't have the right signature >> anyway we're in big trouble and casting them is >> just going to hide the problem until runtime... > > Yes. > > We pass 'ctx' as a 'void *' in the code, but these functions accept > specialized structures, which makes them incompatible: > > void nettle_cipher_func(const void *ctx, size_t length, [...]) > > void aes_decrypt(const struct aes_ctx *ctx, size_t length, [...]) > void des_decrypt(const struct des_ctx *ctx, size_t length, [...]) But aren't both the typedef and the aes/des_decrypt functions provided by the nettle library? Why is the library providing functions whose prototypes don't match its own typedef? -- PMM