From: Collin Funk Date: Mon, 26 May 2025 19:56:22 +0000 (-0700) Subject: crypto/gc: Simplify the previous change. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a90d0ae6c84f3496d247d251194fc3eab150304e;p=thirdparty%2Fgnulib.git crypto/gc: Simplify the previous change. Suggested by Bruno Haible in: . * lib/gc-gnulib.c (gc_cipher_setkey, gc_cipher_setiv): Remove cast and perform a bitwise AND with an unsigned constant. --- diff --git a/ChangeLog b/ChangeLog index a6728386ac..9351692a28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2025-05-26 Collin Funk + crypto/gc: Simplify the previous change. + Suggested by Bruno Haible in: + . + * lib/gc-gnulib.c (gc_cipher_setkey, gc_cipher_setiv): Remove cast and + perform a bitwise AND with an unsigned constant. + crypto/gc: Pacify -Wformat warnings. * lib/gc-gnulib.c (gc_cipher_setkey, gc_cipher_setiv): Cast the argument since "%02x" expects the argument to be unsigned. diff --git a/lib/gc-gnulib.c b/lib/gc-gnulib.c index 85b7a62b74..9b53feb886 100644 --- a/lib/gc-gnulib.c +++ b/lib/gc-gnulib.c @@ -290,8 +290,7 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key) char keyMaterial[RIJNDAEL_MAX_KEY_SIZE + 1]; for (i = 0; i < keylen; i++) - sprintf (&keyMaterial[2 * i], "%02x", - (unsigned int) (key[i] & 0xFF)); + sprintf (&keyMaterial[2 * i], "%02x", key[i] & 0xFFU); rc = rijndaelMakeKey (&ctx->aesEncKey, RIJNDAEL_DIR_ENCRYPT, keylen * 8, keyMaterial); @@ -349,8 +348,7 @@ gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv) char ivMaterial[2 * RIJNDAEL_MAX_IV_SIZE + 1]; for (i = 0; i < ivlen; i++) - sprintf (&ivMaterial[2 * i], "%02x", - (unsigned int) (iv[i] & 0xFF)); + sprintf (&ivMaterial[2 * i], "%02x", iv[i] & 0xFFU); rc = rijndaelCipherInit (&ctx->aesContext, RIJNDAEL_MODE_CBC, ivMaterial);