]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
gnulib: Handle warnings introduced by updated gnulib
authorRobbie Harwood <rharwood@redhat.com>
Tue, 15 Mar 2022 18:05:43 +0000 (14:05 -0400)
committerDaniel Kiper <daniel.kiper@oracle.com>
Mon, 21 Mar 2022 18:17:50 +0000 (19:17 +0100)
- Fix type of size variable in luks2_verify_key()
- Avoid redefinition of SIZE_MAX and ATTRIBUTE_ERROR
- Work around gnulib's int types on older compilers

Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
config.h.in
grub-core/disk/luks2.c
grub-core/lib/posix_wrap/limits.h
include/grub/compiler.h
include/grub/list.h

index 75d0bd650e64a2157151ab82411038442920b55f..01dcbbfc82f0c19ce202eadaae328bb7d2904a80 100644 (file)
@@ -149,4 +149,9 @@ typedef __UINT_FAST32_TYPE__ uint_fast32_t;
 #    define abort __builtin_trap
 #  endif /* !_GL_INLINE_HEADER_BEGIN */
 
+/* gnulib doesn't build cleanly with older compilers. */
+#  if __GNUC__ < 11
+_Pragma ("GCC diagnostic ignored \"-Wtype-limits\"")
+#  endif
+
 #endif
index ccfacb63a3d2216084e368548a8e6b6eb8890f56..bf741d70f3705e358ba1d9f3ebb17762a0753392 100644 (file)
@@ -390,7 +390,7 @@ luks2_verify_key (grub_luks2_digest_t *d, grub_uint8_t *candidate_key,
 {
   grub_uint8_t candidate_digest[GRUB_CRYPTODISK_MAX_KEYLEN];
   grub_uint8_t digest[GRUB_CRYPTODISK_MAX_KEYLEN], salt[GRUB_CRYPTODISK_MAX_KEYLEN];
-  grub_size_t saltlen = sizeof (salt), digestlen = sizeof (digest);
+  idx_t saltlen = sizeof (salt), digestlen = sizeof (digest);
   const gcry_md_spec_t *hash;
   gcry_err_code_t gcry_ret;
 
@@ -429,7 +429,7 @@ luks2_decrypt_key (grub_uint8_t *out_key,
   grub_uint8_t area_key[GRUB_CRYPTODISK_MAX_KEYLEN];
   grub_uint8_t salt[GRUB_CRYPTODISK_MAX_KEYLEN];
   grub_uint8_t *split_key = NULL;
-  grub_size_t saltlen = sizeof (salt);
+  idx_t saltlen = sizeof (salt);
   char cipher[32], *p;
   const gcry_md_spec_t *hash;
   gcry_err_code_t gcry_ret;
index 7217138ffd6befa47729fcbe49c4679f0fcf4003..26918c8a01bc8f9c93d5a364fb979f4d8b13e578 100644 (file)
 #define USHRT_MAX GRUB_USHRT_MAX
 #define UINT_MAX GRUB_UINT_MAX
 #define ULONG_MAX GRUB_ULONG_MAX
-#define SIZE_MAX GRUB_SIZE_MAX
+
+/* gnulib also defines this type */
+#ifndef SIZE_MAX
+#  define SIZE_MAX GRUB_SIZE_MAX
+#endif
 
 #define SCHAR_MIN GRUB_SCHAR_MIN
 #define SCHAR_MAX GRUB_SCHAR_MAX
index 8f3be3ae70665026c4eff85b242e9711e891b63a..0c5519387b25e5fe09c6b8a486b0c093bcfa2033 100644 (file)
 
 /* Does this compiler support compile-time error attributes? */
 #if GNUC_PREREQ(4,3)
-#  define ATTRIBUTE_ERROR(msg) \
+#  define GRUB_ATTRIBUTE_ERROR(msg) \
        __attribute__ ((__error__ (msg)))
 #else
-#  define ATTRIBUTE_ERROR(msg) __attribute__ ((noreturn))
+#  define GRUB_ATTRIBUTE_ERROR(msg) __attribute__ ((noreturn))
 #endif
 
 #if GNUC_PREREQ(4,4)
index b13acb96243cb7db76f396972468f4ad0cf802f7..21f4b4b44a126aa82fdd7f18a83587d0c29fc263 100644 (file)
@@ -40,7 +40,7 @@ void EXPORT_FUNC(grub_list_remove) (grub_list_t item);
 
 static inline void *
 grub_bad_type_cast_real (int line, const char *file)
-     ATTRIBUTE_ERROR ("bad type cast between incompatible grub types");
+     GRUB_ATTRIBUTE_ERROR ("bad type cast between incompatible grub types");
 
 static inline void *
 grub_bad_type_cast_real (int line, const char *file)