]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
all: avoid various "-Wcast-align=strict" warnings 25636/head
authorThomas Haller <thaller@redhat.com>
Thu, 1 Dec 2022 13:07:22 +0000 (14:07 +0100)
committerThomas Haller <thaller@redhat.com>
Fri, 9 Dec 2022 07:58:07 +0000 (08:58 +0100)
src/basic/fd-util.c
src/basic/hashmap.c
src/libsystemd-network/sd-dhcp6-client.c
src/libsystemd-network/sd-dhcp6-lease.c

index 01a45e4384daacc7b8efd5b05a0f0d21cb1c1a66..b97039284cdab820ce393ee529eac8ec73f7e5e9 100644 (file)
@@ -501,7 +501,8 @@ void cmsg_close_all(struct msghdr *mh) {
 
         CMSG_FOREACH(cmsg, mh)
                 if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS)
-                        close_many((int*) CMSG_DATA(cmsg), (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int));
+                        close_many(CMSG_TYPED_DATA(cmsg, int),
+                                   (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int));
 }
 
 bool fdname_is_valid(const char *s) {
index d19627595f07aedc8319282b62998b43ceb5ed41..de7d16c3970ad99cf55537a3b5df5445bf16f689 100644 (file)
@@ -373,8 +373,9 @@ static void get_hash_key(uint8_t hash_key[HASH_KEY_SIZE], bool reuse_is_ok) {
 }
 
 static struct hashmap_base_entry* bucket_at(HashmapBase *h, unsigned idx) {
-        return (struct hashmap_base_entry*)
-                ((uint8_t*) storage_ptr(h) + idx * hashmap_type_info[h->type].entry_size);
+        return CAST_ALIGN_PTR(
+                        struct hashmap_base_entry,
+                        (uint8_t *) storage_ptr(h) + idx * hashmap_type_info[h->type].entry_size);
 }
 
 static struct plain_hashmap_entry* plain_bucket_at(Hashmap *h, unsigned idx) {
index ee48160046005f992e319b4a2e5f7cdc0656307f..3f34b46280894f7a5833e3eb78121ddc3fb9f8a8 100644 (file)
@@ -1293,7 +1293,7 @@ static int client_receive_message(
                 if (cmsg->cmsg_level == SOL_SOCKET &&
                     cmsg->cmsg_type == SO_TIMESTAMP &&
                     cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval)))
-                        triple_timestamp_from_realtime(&t, timeval_load((struct timeval*) CMSG_DATA(cmsg)));
+                        triple_timestamp_from_realtime(&t, timeval_load(CMSG_TYPED_DATA(cmsg, struct timeval)));
         }
 
         if (client->transaction_id != (message->transaction_id & htobe32(0x00ffffff)))
index 57c23965eda3ab3b73b0bfdf61856213fa879756..3dcccf1729e6186157a68d49acd0d87e430e16a7 100644 (file)
@@ -619,7 +619,7 @@ static int dhcp6_lease_parse_message(
                                 return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
                                                               "Received information refresh time option with an invalid length (%zu).", optlen);
 
-                        irt = unaligned_read_be32((be32_t *) optval) * USEC_PER_SEC;
+                        irt = unaligned_read_be32(optval) * USEC_PER_SEC;
                         break;
                 }
         }