Skip to contentSkip to conversation

settings: fix -std=c23 build failure

PATCH In review Sergei Trofimovich 2 participants 5 messages Nov 17, 2024 – Nov 18, 2024

lore
Share & tools
lore
#2 lore raw

PATCH 3/4 dbus: fix -std=c23 build failure

In reply to Sergei Trofimovich

gcc-15 switched to -std=c23 by default:

    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=55e3bd376b2214e200fa76d12b67ff259b06c212

As a result ell fails the build as:

ell/dbus.c:1700:24: error: incompatible types when returning type '_Bool' but 'void *' was expected
1700 | return false;
| ^~~~~

---
 ell/dbus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
ell/dbus.c +2 -2
index bd6e1b8..1ab4ded 100644
@@ -1697,10 +1697,10 @@ LIB_EXPORT void *l_dbus_object_get_data(struct l_dbus *dbus, const char *object,
 					const char *interface)
 {
 	if (unlikely(!dbus))
-		return false;
+		return NULL;
 
 	if (unlikely(!dbus->tree))
-		return false;
+		return NULL;
 
 	return _dbus_object_tree_get_interface_data(dbus->tree, object,
 							interface);
Signature · 1 line
2.47.0
#0 lore raw

PATCH 1/4 settings: fix -std=c23 build failure

gcc-15 switched to -std=c23 by default:

    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=55e3bd376b2214e200fa76d12b67ff259b06c212

As a result ell fails the build as:

ell/settings.c: In function 'l_settings_get_embedded_value':
ell/settings.c:1521:24: error: incompatible types when returning type '_Bool' but 'const char *' was expected
1521 | return false;
| ^~~~~

The change uses poiter instead of a bool to return the zero value.

---
 ell/settings.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ell/settings.c +1 -1
index a5f17d1..b46d00b 100644
@@ -1518,7 +1518,7 @@ LIB_EXPORT const char *l_settings_get_embedded_value(
 	struct embedded_group_data *group;
 
 	if (unlikely(!settings))
-		return false;
+		return NULL;
 
 	group = l_queue_find(settings->embedded_groups,
 					embedded_group_match, group_name);
Signature · 1 line
2.47.0
#1 lore raw

PATCH 2/4 cert: fix -std=c23 build failure

gcc-15 switched to -std=c23 by default:

    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=55e3bd376b2214e200fa76d12b67ff

259b06c212

As a result ell fails the build as:

ell/cert.c:390:32: error: incompatible types when returning type '_Bool' but 'const uint8_t *' {aka 'const unsigned char *'} was expected
390 | return false;
| ^~~~~

---
 ell/cert.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
ell/cert.c +4 -4
index 38bb01a..19a6556 100644
@@ -387,13 +387,13 @@ const uint8_t *cert_get_extension(struct l_cert *cert,
 
 		seq = asn1_der_find_elem(ext, end - ext, 0, &tag, &len);
 		if (unlikely(!seq || tag != ASN1_ID_SEQUENCE))
-			return false;
+			return NULL;
 
 		ext = seq + len;
 
 		oid = asn1_der_find_elem(seq, len, 0, &tag, &oid_len);
 		if (unlikely(!oid || tag != ASN1_ID_OID))
-			return false;
+			return NULL;
 
 		if (!asn1_oid_eq(ext_id, oid_len, oid))
 			continue;
@@ -403,7 +403,7 @@ const uint8_t *cert_get_extension(struct l_cert *cert,
 
 		if (data && tag == ASN1_ID_BOOLEAN) {
 			if (data_len != 1)
-				return false;
+				return NULL;
 
 			critical = *data != 0;	/* Tolerate BER booleans */
 
@@ -411,7 +411,7 @@ const uint8_t *cert_get_extension(struct l_cert *cert,
 		}
 
 		if (unlikely(!data || tag != ASN1_ID_OCTET_STRING))
-			return false;
+			return NULL;
 
 		if (out_critical)
 			*out_critical = critical;
Signature · 1 line
2.47.0
#3 lore raw

PATCH 4/4 test-rtnl: fix -std=c23 build failure

In reply to Sergei Trofimovich

gcc-15 switched to -std=c23 by default:

    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=55e3bd376b2214e200fa76d12b67ff259b06c212

As a result ell fails the build as:

unit/test-rtnl.c: In function 'test_run':
unit/test-rtnl.c:501:24: error:
passing argument 1 of 'l_idle_oneshot' from incompatible pointer type [-Wincompatible-pointer-types]
501 | l_idle_oneshot(test_next, NULL, NULL);
| ^~~~~~~~~
| |
| void (*)(void)

---
 unit/test-rtnl.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
unit/test-rtnl.c +7 -1
index 59d8492..6fbac9e 100644
@@ -358,6 +358,12 @@ static void test_next()
 	test->start(rtnl, test->data);
 }
 
+static void test_next_cb(void * unused)
+{
+	(void)unused;
+	test_next();
+}
+
 #define test_assert(cond)	\
 	do {	\
 		if (!(cond)) {	\
@@ -498,7 +504,7 @@ static void test_run(void)
 {
 	success = false;
 
-	l_idle_oneshot(test_next, NULL, NULL);
+	l_idle_oneshot(test_next_cb, NULL, NULL);
 	l_main_run_with_signal(signal_handler, NULL);
 }
 
Signature · 1 line
2.47.0
#4 lore raw
In reply to Sergei Trofimovich

Hi Sergei,

Quoted 11 lines · Sergei Trofimovich

gcc-15 switched to -std=c23 by default:

     https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=55e3bd376b2214e200fa76d12b67ff259b06c212

As a result ell fails the build as:

ell/settings.c: In function 'l_settings_get_embedded_value':
ell/settings.c:1521:24: error: incompatible types when returning type '_Bool' but 'const char *' was expected
1521 | return false;
| ^~~~~

Quoted 5 lines

The change uses poiter instead of a bool to return the zero value.

---
  ell/settings.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

All applied, thanks.

Regards,
-Denis