]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: stick-tables: use read_u32() to display a node's key
authorWilly Tarreau <w@1wt.eu>
Tue, 25 Feb 2020 08:41:22 +0000 (09:41 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 25 Feb 2020 08:41:22 +0000 (09:41 +0100)
This fixes another aliasing issue that pops up in stick_table.c
and peers.c's debug code.

src/peers.c
src/stick_table.c

index 659992cffcda234cda763bc7ec595d5c17adf719..f5a4f18655fdf0b0a63333d6f6170bcfc95b7b16 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <common/compat.h>
 #include <common/config.h>
+#include <common/net_helper.h>
 #include <common/time.h>
 #include <common/standard.h>
 #include <common/hathreads.h>
@@ -475,7 +476,7 @@ static int peer_prepare_updatemsg(char *msg, size_t size, struct peer_prep_param
                cursor += stlen;
        }
        else if (st->table->type == SMP_T_SINT) {
-               netinteger = htonl(*((uint32_t *)ts->key.key));
+               netinteger = htonl(read_u32(ts->key.key));
                memcpy(cursor, &netinteger, sizeof(netinteger));
                cursor += sizeof(netinteger);
        }
index 9937f115f08e74d0d3cadb6edaefbf54c25cd2f6..665cc37680c0a97c0169c1b4cf30b1674940c31f 100644 (file)
@@ -19,6 +19,7 @@
 #include <common/initcall.h>
 #include <common/memory.h>
 #include <common/mini-clist.h>
+#include <common/net_helper.h>
 #include <common/standard.h>
 #include <common/time.h>
 
@@ -3366,7 +3367,7 @@ static int table_dump_entry_to_buffer(struct buffer *msg,
                chunk_appendf(msg, " key=%s", addr);
        }
        else if (t->type == SMP_T_SINT) {
-               chunk_appendf(msg, " key=%u", *(unsigned int *)entry->key.key);
+               chunk_appendf(msg, " key=%u", read_u32(entry->key.key));
        }
        else if (t->type == SMP_T_STR) {
                chunk_appendf(msg, " key=");