[SSSD] [PATCH] test_resolv_fake: Fix alignment warning
Lukas Slebodnik
lslebodn at redhat.com
Wed Mar 25 13:59:14 UTC 2015
ehlo,
there is a problem with allignment in tests.
patch is attached.
LS
-------------- next part --------------
>From 82e7579d88ac720c3dfcdfbf3b52781a10fc6d40 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 14 Mar 2015 16:29:36 +0100
Subject: [PATCH 1/2] test_resolv_fake: Fix alignment warning
src/tests/cmocka/test_resolv_fake.c:60:9:
error: cast from 'uint8_t *' (aka 'unsigned char *') to 'HEADER *'
increases required alignment from 1 to 4 [-Werror,-Wcast-align]
h = (HEADER *) hb;
^~~~~~~~~~~~~
1 error generated.
---
src/tests/cmocka/test_resolv_fake.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/tests/cmocka/test_resolv_fake.c b/src/tests/cmocka/test_resolv_fake.c
index eac5697e49ce30224a89a686fe3fb5fdffe2b15b..2c846ce4cc63cbf80b30bd15091136002ec84cb3 100644
--- a/src/tests/cmocka/test_resolv_fake.c
+++ b/src/tests/cmocka/test_resolv_fake.c
@@ -52,20 +52,21 @@ struct srv_rrdata {
static ssize_t dns_header(unsigned char **buf, size_t ancount)
{
uint8_t *hb;
- HEADER *h;
+ HEADER h;
hb = *buf;
memset(hb, 0, NS_HFIXEDSZ);
+ memset(&h, 0, sizeof(h));
- h = (HEADER *) hb;
- h->id = res_randomid(); /* random query ID */
- h->qr = 1; /* response flag */
- h->rd = 1; /* recursion desired */
- h->ra = 1; /* resursion available */
+ h.id = res_randomid(); /* random query ID */
+ h.qr = 1; /* response flag */
+ h.rd = 1; /* recursion desired */
+ h.ra = 1; /* resursion available */
- h->qdcount = htons(1); /* no. of questions */
- h->ancount = htons(ancount); /* no. of answers */
- h->arcount = htons(0); /* no. of add'tl records */
+ h.qdcount = htons(1); /* no. of questions */
+ h.ancount = htons(ancount); /* no. of answers */
+ h.arcount = htons(0); /* no. of add'tl records */
+ memcpy(hb, &h, sizeof(h));
hb += NS_HFIXEDSZ; /* move past the header */
*buf = hb;
--
2.3.3
More information about the sssd-devel
mailing list