[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 5/6] Handle warnings introduced by updated gnulib
From: |
Robbie Harwood |
Subject: |
[PATCH v7 5/6] Handle warnings introduced by updated gnulib |
Date: |
Wed, 2 Mar 2022 12:45:56 -0500 |
- 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>
---
config.h.in | 5 +++++
grub-core/disk/luks2.c | 4 ++--
grub-core/lib/posix_wrap/limits.h | 6 +++++-
include/grub/compiler.h | 4 ++--
include/grub/list.h | 2 +-
5 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/config.h.in b/config.h.in
index a333cf73d..133f07ba1 100644
--- a/config.h.in
+++ b/config.h.in
@@ -74,4 +74,9 @@
# 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
diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c
index ccfacb63a..bf741d70f 100644
--- a/grub-core/disk/luks2.c
+++ b/grub-core/disk/luks2.c
@@ -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;
diff --git a/grub-core/lib/posix_wrap/limits.h
b/grub-core/lib/posix_wrap/limits.h
index 7217138ff..26918c8a0 100644
--- a/grub-core/lib/posix_wrap/limits.h
+++ b/grub-core/lib/posix_wrap/limits.h
@@ -25,7 +25,11 @@
#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
diff --git a/include/grub/compiler.h b/include/grub/compiler.h
index 8f3be3ae7..0c5519387 100644
--- a/include/grub/compiler.h
+++ b/include/grub/compiler.h
@@ -30,10 +30,10 @@
/* 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)
diff --git a/include/grub/list.h b/include/grub/list.h
index b13acb962..21f4b4b44 100644
--- a/include/grub/list.h
+++ b/include/grub/list.h
@@ -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)
--
2.34.1
- [PATCH v7 0/6] Update gnulib version and drop most gnulib patches, Robbie Harwood, 2022/03/02
- [PATCH v7 1/6] Use visual indentation in config.h.in, Robbie Harwood, 2022/03/02
- [PATCH v7 2/6] Where present, ensure config-util.h precedes config.h, Robbie Harwood, 2022/03/02
- [PATCH v7 4/6] Drop gnulib no-abort.patch, Robbie Harwood, 2022/03/02
- [PATCH v7 3/6] Drop gnulib fix-base64.patch, Robbie Harwood, 2022/03/02
- [PATCH v7 5/6] Handle warnings introduced by updated gnulib,
Robbie Harwood <=
- [PATCH v7 6/6] Update gnulib version and drop most gnulib patches, Robbie Harwood, 2022/03/02