From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDXr6-0005Pg-FA for qemu-devel@nongnu.org; Fri, 10 Jul 2015 08:56:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZDXr3-0002X6-8G for qemu-devel@nongnu.org; Fri, 10 Jul 2015 08:56:40 -0400 Received: from mail-vn0-f46.google.com ([209.85.216.46]:34455) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDXr3-0002Wz-4X for qemu-devel@nongnu.org; Fri, 10 Jul 2015 08:56:37 -0400 Received: by vnbf7 with SMTP id f7so31586705vnb.1 for ; Fri, 10 Jul 2015 05:56:36 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1436531615-30183-1-git-send-email-rkrcmar@redhat.com> References: <1436531615-30183-1-git-send-email-rkrcmar@redhat.com> From: Peter Maydell Date: Fri, 10 Jul 2015 13:56:17 +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 13:33, Radim Kr=C4=8Dm=C3=A1=C5=99 = wrote: > In nettle 3, cbc_encrypt() accepts 'nettle_cipher_func' instead of > 'nettle_crypt_func' and these two differ in 'const' qualifier of the > first argument. The build fails with: > > In file included from crypto/cipher.c:71:0: > ./crypto/cipher-nettle.c: In function =E2=80=98qcrypto_cipher_encrypt= =E2=80=99: > ./crypto/cipher-nettle.c:154:38: error: passing argument 2 of > =E2=80=98nettle_cbc_encrypt=E2=80=99 from incompatible pointer type > cbc_encrypt(ctx->ctx_encrypt, ctx->alg_encrypt, > ^ > In file included from ./crypto/cipher-nettle.c:24:0, > from crypto/cipher.c:71: > /usr/include/nettle/cbc.h:48:1: note: expected > =E2=80=98void (*)(const void *, size_t, uint8_t *, const uint8_t *) > but argument is of type > =E2=80=98void (*)( void *, size_t, uint8_t *, const uint8_t *) > > To allow both versions, we switch to the new definition and #if typedef > it for old versions. > > Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 > --- > I don't know if we want to kill the #if compatibility after a while > (so QEMU doesn't become glibc-like) -- I could split this patch into > two, where the first one would just be reverted. We might eventually kill the compat, but we'd probably want to do it while retaining a version check in configure, so I'd just leave it as one patch. > @@ -83,8 +87,8 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorith= m alg, > des_set_key(ctx->ctx_encrypt, rfbkey); > g_free(rfbkey); > > - 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; > > ctx->niv =3D DES_BLOCK_SIZE; > break; > @@ -98,8 +102,8 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorit= hm alg, > aes_set_encrypt_key(ctx->ctx_encrypt, nkey, key); > aes_set_decrypt_key(ctx->ctx_decrypt, nkey, key); > > - 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... thanks -- PMM