From c7e0f3e6b8711596b7533c8018acbd57beafa6fc Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 18 Mar 2024 10:45:28 +0000 Subject: [PATCH 1/2] girparser: Adjust signedness() to avoid compiler warnings No functional change intended. Signed-off-by: Simon McVittie --- girepository/girparser.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/girepository/girparser.c b/girepository/girparser.c index e0cf42427..ca736c8ee 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -454,16 +454,7 @@ typedef struct { unsigned int is_signed : 1; } IntegerAliasInfo; -/* Ignore warnings from use of signedness() */ -#if G_GNUC_CHECK_VERSION(4, 6) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wtype-limits" -#elif defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wtype-limits" -#endif - -#define signedness(T) (((T) -1) < 0) +#define signedness(T) (((T) -1) <= 0) G_STATIC_ASSERT (signedness (int) == 1); G_STATIC_ASSERT (signedness (unsigned int) == 0); @@ -493,12 +484,6 @@ static IntegerAliasInfo integer_aliases[] = { #undef INTEGER_ALIAS }; -#if G_GNUC_CHECK_VERSION(4, 6) -#pragma GCC diagnostic pop -#elif defined(__clang__) -#pragma clang diagnostic pop -#endif - typedef struct { const char *str; int tag; From d9ee53d0ebf8f7a4b012c59680e3bb969724c5e1 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 18 Mar 2024 10:46:13 +0000 Subject: [PATCH 2/2] girparser: Add a pseudo-doc-comment for signedness() We could consider adding this to gmacros if it's useful anywhere else. Signed-off-by: Simon McVittie --- girepository/girparser.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/girepository/girparser.c b/girepository/girparser.c index ca736c8ee..c80574f3f 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -454,6 +454,12 @@ typedef struct { unsigned int is_signed : 1; } IntegerAliasInfo; +/* + * signedness: + * @T: a numeric type + * + * Returns: 1 if @T is signed, 0 if it is unsigned + */ #define signedness(T) (((T) -1) <= 0) G_STATIC_ASSERT (signedness (int) == 1); G_STATIC_ASSERT (signedness (unsigned int) == 0);