Warn-to-error on -Werror=cast-align
by Gix, Brian
In the BlueZ build, we apparently use stricter Warn to Error checking than what is currently set up for ELL.
I got my son a new Raspberry PI, and the first thing he tried to build was ELL and BlueZ... On THAT PATFORM
ONLY, Raspbian (Raspbian 10 (buster)) with kernel 4.19, we get failures building ell/dbus.c. Everything builds
correctly in the ELL tree, using standard bootstrap-configure, however when using -Werror=cast-align, I get the
following (see below) build issues in dbus.c, genl.c, dhcp-transport.c, plus a few unit tests... In BlueZ
these errors show up with the *default* build procedure:
So my question for Marcel is: Do we need the alignment check in BlueZ?
And for Denis and Marcel, Do we care if there are alignment warnings in ELL?
Here is a dump of the make output after:
$ export CFLAGS=-Werror=cast-align
$ ./bootstrap-configure
pi@raspberrypi:~/ell $ make -k
make --no-print-directory all-am
CC ell/genl.lo
ell/genl.c: In function ‘l_genl_attr_next’:
ell/genl.c:1677:5: error: cast increases required alignment of target type [-Werror=cast-align]
(struct nlattr*)(((char*)(nla)) + \
^
ell/genl.c:1738:20: note: in expansion of macro ‘NLA_NEXT’
attr->next_data = NLA_NEXT(nla, attr->next_len);
^~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:1864: ell/genl.lo] Error 1
CC ell/dbus.lo
In file included from ell/dbus.c:38:
ell/dbus.c: In function ‘classic_free’:
ell/util.h:40:3: error: cast increases required alignment of target type [-Werror=cast-align]
(type *)((char *) __mptr - offsetof(type, member)); \
^
ell/dbus.c:582:3: note: in expansion of macro ‘l_container_of’
l_container_of(dbus, struct l_dbus_classic, super);
^~~~~~~~~~~~~~
ell/dbus.c: In function ‘classic_recv_message’:
ell/util.h:40:3: error: cast increases required alignment of target type [-Werror=cast-align]
(type *)((char *) __mptr - offsetof(type, member)); \
^
ell/dbus.c:661:3: note: in expansion of macro ‘l_container_of’
l_container_of(dbus, struct l_dbus_classic, super);
^~~~~~~~~~~~~~
ell/dbus.c: In function ‘classic_add_match’:
ell/util.h:40:3: error: cast increases required alignment of target type [-Werror=cast-align]
(type *)((char *) __mptr - offsetof(type, member)); \
^
ell/dbus.c:812:3: note: in expansion of macro ‘l_container_of’
l_container_of(dbus, struct l_dbus_classic, super);
^~~~~~~~~~~~~~
ell/dbus.c: In function ‘classic_remove_match’:
ell/util.h:40:3: error: cast increases required alignment of target type [-Werror=cast-align]
(type *)((char *) __mptr - offsetof(type, member)); \
^
ell/dbus.c:836:3: note: in expansion of macro ‘l_container_of’
l_container_of(dbus, struct l_dbus_classic, super);
^~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:1864: ell/dbus.lo] Error 1
CC ell/dhcp-transport.lo
In file included from ell/dhcp-transport.c:44:
ell/dhcp-transport.c: In function ‘_dhcp_default_transport_broadcast’:
ell/util.h:40:3: error: cast increases required alignment of target type [-Werror=cast-align]
(type *)((char *) __mptr - offsetof(type, member)); \
^
ell/dhcp-transport.c:203:3: note: in expansion of macro ‘l_container_of’
l_container_of(s, struct dhcp_default_transport, super);
^~~~~~~~~~~~~~
ell/dhcp-transport.c: In function ‘_dhcp_default_transport_send’:
ell/util.h:40:3: error: cast increases required alignment of target type [-Werror=cast-align]
(type *)((char *) __mptr - offsetof(type, member)); \
^
ell/dhcp-transport.c:246:3: note: in expansion of macro ‘l_container_of’
l_container_of(s, struct dhcp_default_transport, super);
^~~~~~~~~~~~~~
ell/dhcp-transport.c: In function ‘_dhcp_default_transport_bind’:
ell/util.h:40:3: error: cast increases required alignment of target type [-Werror=cast-align]
(type *)((char *) __mptr - offsetof(type, member)); \
^
ell/dhcp-transport.c:316:3: note: in expansion of macro ‘l_container_of’
l_container_of(s, struct dhcp_default_transport, super);
^~~~~~~~~~~~~~
ell/dhcp-transport.c: In function ‘_dhcp_default_transport_open’:
ell/util.h:40:3: error: cast increases required alignment of target type [-Werror=cast-align]
(type *)((char *) __mptr - offsetof(type, member)); \
^
ell/dhcp-transport.c:454:3: note: in expansion of macro ‘l_container_of’
l_container_of(s, struct dhcp_default_transport, super);
^~~~~~~~~~~~~~
ell/dhcp-transport.c: In function ‘_dhcp_default_transport_close’:
ell/util.h:40:3: error: cast increases required alignment of target type [-Werror=cast-align]
(type *)((char *) __mptr - offsetof(type, member)); \
^
ell/dhcp-transport.c:476:3: note: in expansion of macro ‘l_container_of’
l_container_of(s, struct dhcp_default_transport, super);
^~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:1864: ell/dhcp-transport.lo] Error 1
CC unit/test-genl-msg.o
unit/test-genl-msg.c: In function ‘parse_set_station’:
unit/test-genl-msg.c:63:10: error: cast increases required alignment of target type [-Werror=cast-align]
nlmsg = (struct nlmsghdr *) set_station_request;
^
unit/test-genl-msg.c: In function ‘parse_set_rekey_offload’:
unit/test-genl-msg.c:159:10: error: cast increases required alignment of target type [-Werror=cast-align]
nlmsg = (struct nlmsghdr *) set_rekey_offload_request;
^
unit/test-genl-msg.c: In function ‘parse_libnl_nested’:
unit/test-genl-msg.c:287:10: error: cast increases required alignment of target type [-Werror=cast-align]
nlmsg = (struct nlmsghdr *) libnl_nested;
^
cc1: all warnings being treated as errors
make[1]: *** [Makefile:1848: unit/test-genl-msg.o] Error 1
CC unit/test-dbus-watch.o
In file included from ./ell/ell.h:23,
from unit/test-dbus-watch.c:30:
unit/test-dbus-watch.c: In function ‘test_add_match’:
./ell/util.h:40:3: error: cast increases required alignment of target type [-Werror=cast-align]
(type *)((char *) __mptr - offsetof(type, member)); \
^
unit/test-dbus-watch.c:111:3: note: in expansion of macro ‘l_container_of’
l_container_of(dbus, struct filter_test_state, dbus);
^~~~~~~~~~~~~~
unit/test-dbus-watch.c: In function ‘test_remove_match’:
./ell/util.h:40:3: error: cast increases required alignment of target type [-Werror=cast-align]
(type *)((char *) __mptr - offsetof(type, member)); \
^
unit/test-dbus-watch.c:127:3: note: in expansion of macro ‘l_container_of’
l_container_of(dbus, struct filter_test_state, dbus);
^~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:1848: unit/test-dbus-watch.o] Error 1
make[1]: Target 'all-am' not remade because of errors.
make: *** [Makefile:1199: all] Error 2
pi@raspberrypi:~/ell $
2 years, 5 months
[PATCH v3] dbus: Minor whitespace clean-up
by Brian Gix
---
ell/dbus-client.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ell/dbus-client.c b/ell/dbus-client.c
index 2d8120e..f735f33 100644
--- a/ell/dbus-client.c
+++ b/ell/dbus-client.c
@@ -651,8 +651,8 @@ LIB_EXPORT void l_dbus_client_destroy(struct l_dbus_client *client)
client->proxy_cb_data_destroy(client->proxy_cb_data);
if (client->objects_call)
- l_dbus_cancel(client->dbus, client->objects_call)
-;
+ l_dbus_cancel(client->dbus, client->objects_call);
+
l_queue_destroy(client->proxies,
(l_queue_destroy_func_t)dbus_proxy_destroy);
--
2.21.0
2 years, 6 months
[PATCH v3] dbus: NULL check proxy on method calls
by Brian Gix
l_dbus_proxy_method_call() seg-faults when called with a NULL proxy
pointer. This NULL check follows the pattern of NULL checks in the
other LIB_EXPORT methods in module.
---
ell/dbus-client.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/ell/dbus-client.c b/ell/dbus-client.c
index 541f3e8..2d8120e 100644
--- a/ell/dbus-client.c
+++ b/ell/dbus-client.c
@@ -301,6 +301,9 @@ LIB_EXPORT uint32_t l_dbus_proxy_method_call(struct l_dbus_proxy *proxy,
{
struct method_call_request *req;
+ if (unlikely(!proxy))
+ return 0;
+
req = l_new(struct method_call_request, 1);
req->proxy = proxy;
req->setup = setup;
--
2.21.0
2 years, 6 months
[PATCH v2] dbus: NULL check proxy on method calls
by Brian Gix
l_dbus_proxy_method_call() seg-faults when called with a NULL proxy
pointer. This NULL check follows the pattern of NULL checks in the
other LIB_EXPORT methods in module.
---
ell/dbus-client.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/ell/dbus-client.c b/ell/dbus-client.c
index 541f3e8..f735f33 100644
--- a/ell/dbus-client.c
+++ b/ell/dbus-client.c
@@ -301,6 +301,9 @@ LIB_EXPORT uint32_t l_dbus_proxy_method_call(struct l_dbus_proxy *proxy,
{
struct method_call_request *req;
+ if (unlikely(!proxy))
+ return 0;
+
req = l_new(struct method_call_request, 1);
req->proxy = proxy;
req->setup = setup;
@@ -648,8 +651,8 @@ LIB_EXPORT void l_dbus_client_destroy(struct l_dbus_client *client)
client->proxy_cb_data_destroy(client->proxy_cb_data);
if (client->objects_call)
- l_dbus_cancel(client->dbus, client->objects_call)
-;
+ l_dbus_cancel(client->dbus, client->objects_call);
+
l_queue_destroy(client->proxies,
(l_queue_destroy_func_t)dbus_proxy_destroy);
--
2.21.0
2 years, 6 months
[PATCH] dbus: NULL check proxy on method calls
by Brian Gix
l_dbus_proxy_method_call() seg-faults when called with a NULL proxy
pointer. This NULL check follows the pattern of NULL checks in the
other LIB_EXPORT methods in module.
---
ell/dbus-client.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/ell/dbus-client.c b/ell/dbus-client.c
index 541f3e8..f735f33 100644
--- a/ell/dbus-client.c
+++ b/ell/dbus-client.c
@@ -301,6 +301,9 @@ LIB_EXPORT uint32_t l_dbus_proxy_method_call(struct l_dbus_proxy *proxy,
{
struct method_call_request *req;
+ if (unlikely(!proxy))
+ return 0;
+
req = l_new(struct method_call_request, 1);
req->proxy = proxy;
req->setup = setup;
@@ -648,8 +651,8 @@ LIB_EXPORT void l_dbus_client_destroy(struct l_dbus_client *client)
client->proxy_cb_data_destroy(client->proxy_cb_data);
if (client->objects_call)
- l_dbus_cancel(client->dbus, client->objects_call)
-;
+ l_dbus_cancel(client->dbus, client->objects_call);
+
l_queue_destroy(client->proxies,
(l_queue_destroy_func_t)dbus_proxy_destroy);
--
2.21.0
2 years, 6 months
[PATCH] dbus: NULL check proxy on method calls
by Brian Gix
l_dbus_proxy_method_call() seg-faults when called with a NULL proxy
pointer. This NULL check follows the pattern of NULL checks in the
other LIB_EXPORT methods in module.
---
ell/dbus-client.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/ell/dbus-client.c b/ell/dbus-client.c
index 541f3e8..70131a8 100644
--- a/ell/dbus-client.c
+++ b/ell/dbus-client.c
@@ -301,6 +301,9 @@ LIB_EXPORT uint32_t l_dbus_proxy_method_call(struct l_dbus_proxy *proxy,
{
struct method_call_request *req;
+ if (unlikely(!proxy))
+ return NULL;
+
req = l_new(struct method_call_request, 1);
req->proxy = proxy;
req->setup = setup;
@@ -648,8 +651,8 @@ LIB_EXPORT void l_dbus_client_destroy(struct l_dbus_client *client)
client->proxy_cb_data_destroy(client->proxy_cb_data);
if (client->objects_call)
- l_dbus_cancel(client->dbus, client->objects_call)
-;
+ l_dbus_cancel(client->dbus, client->objects_call);
+
l_queue_destroy(client->proxies,
(l_queue_destroy_func_t)dbus_proxy_destroy);
--
2.21.0
2 years, 6 months
[PATCH] dhcp-lease: Fix typo
by Tim Kourt
Replace logical AND with OR.
---
ell/dhcp-lease.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ell/dhcp-lease.c b/ell/dhcp-lease.c
index 8f044fb..4d49190 100644
--- a/ell/dhcp-lease.c
+++ b/ell/dhcp-lease.c
@@ -104,7 +104,7 @@ struct l_dhcp_lease *_dhcp_lease_parse_options(struct dhcp_message_iter *iter)
}
break;
case L_DHCP_OPTION_DOMAIN_NAME:
- if (l < 1 && l > 253)
+ if (l < 1 || l > 253)
goto error;
/* Disallow embedded NUL bytes. */
--
2.13.6
2 years, 6 months
[PATCH 1/5] net: Add l_net_hostname_is_root
by Tim Kourt
The function identifies if the given hostname is root domain name.
---
ell/net.c | 23 +++++++++++++++++++++++
ell/net.h | 1 +
2 files changed, 24 insertions(+)
diff --git a/ell/net.c b/ell/net.c
index b5b5f9d..3b6e0dc 100644
--- a/ell/net.c
+++ b/ell/net.c
@@ -110,3 +110,26 @@ LIB_EXPORT char *l_net_get_name(uint32_t ifindex)
return l_strdup(ifr.ifr_name);
}
+
+/**
+ * l_net_hostname_is_root:
+ * @hostname: Hostname to validate
+ *
+ * Identifies if the hostname given by @hostname is root domain name or
+ * not.
+ *
+ * Returns: #true if the given hostname is root and #false otherwise.
+ **/
+LIB_EXPORT bool l_net_hostname_is_root(const char *hostname)
+{
+ if (unlikely(!hostname))
+ return false;
+
+ if (!strcmp(hostname, ""))
+ return true;
+
+ if (!strcmp(hostname, "."))
+ return true;
+
+ return false;
+}
diff --git a/ell/net.h b/ell/net.h
index 25b1ca2..7afcf86 100644
--- a/ell/net.h
+++ b/ell/net.h
@@ -32,6 +32,7 @@ extern "C" {
bool l_net_get_mac_address(uint32_t ifindex, uint8_t *out_addr);
char *l_net_get_name(uint32_t ifindex);
+bool l_net_hostname_is_root(const char *hostname);
#ifdef __cplusplus
}
--
2.13.6
2 years, 6 months
[PATCH] dhcp: Add domain name option handler
by Tim Kourt
Add parser and accessor for the domain name lease option.
---
ell/dhcp-lease.c | 24 +++++++++++++++++++++++-
ell/dhcp-private.h | 1 +
ell/dhcp.h | 1 +
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/ell/dhcp-lease.c b/ell/dhcp-lease.c
index 5f801e7..06ef76a 100644
--- a/ell/dhcp-lease.c
+++ b/ell/dhcp-lease.c
@@ -45,6 +45,8 @@ void _dhcp_lease_free(struct l_dhcp_lease *lease)
return;
l_free(lease->dns);
+ l_free(lease->domain_name);
+
l_free(lease);
}
@@ -99,6 +101,18 @@ struct l_dhcp_lease *_dhcp_lease_parse_options(struct dhcp_message_iter *iter)
}
}
break;
+ case L_DHCP_OPTION_DOMAIN_NAME:
+ if (l < 1)
+ break;
+
+ lease->domain_name = l_new(char, l + 1);
+
+ memcpy(lease->domain_name, v, l);
+
+ if (lease->domain_name[l - 1] != '\0')
+ lease->domain_name[l] = '\0';
+
+ break;
default:
break;
}
@@ -135,7 +149,7 @@ struct l_dhcp_lease *_dhcp_lease_parse_options(struct dhcp_message_iter *iter)
return lease;
error:
- l_free(lease);
+ _dhcp_lease_free(lease);
return NULL;
}
@@ -212,6 +226,14 @@ LIB_EXPORT char **l_dhcp_lease_get_dns(const struct l_dhcp_lease *lease)
return dns_list;
}
+LIB_EXPORT char *l_dhcp_lease_get_domain_name(const struct l_dhcp_lease *lease)
+{
+ if (unlikely(!lease))
+ return NULL;
+
+ return l_strdup(lease->domain_name);
+}
+
LIB_EXPORT uint32_t l_dhcp_lease_get_t1(const struct l_dhcp_lease *lease)
{
if (unlikely(!lease))
diff --git a/ell/dhcp-private.h b/ell/dhcp-private.h
index 6554fc6..a75bb8b 100644
--- a/ell/dhcp-private.h
+++ b/ell/dhcp-private.h
@@ -120,6 +120,7 @@ struct l_dhcp_lease {
uint32_t t2;
uint32_t router;
uint32_t *dns;
+ char *domain_name;
};
struct l_dhcp_lease *_dhcp_lease_new(void);
diff --git a/ell/dhcp.h b/ell/dhcp.h
index c3a4988..b8a5b41 100644
--- a/ell/dhcp.h
+++ b/ell/dhcp.h
@@ -95,6 +95,7 @@ char *l_dhcp_lease_get_netmask(const struct l_dhcp_lease *lease);
char *l_dhcp_lease_get_broadcast(const struct l_dhcp_lease *lease);
char *l_dhcp_lease_get_server_id(const struct l_dhcp_lease *lease);
char **l_dhcp_lease_get_dns(const struct l_dhcp_lease *lease);
+char *l_dhcp_lease_get_domain_name(const struct l_dhcp_lease *lease);
uint32_t l_dhcp_lease_get_t1(const struct l_dhcp_lease *lease);
uint32_t l_dhcp_lease_get_t2(const struct l_dhcp_lease *lease);
--
2.13.6
2 years, 6 months