Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix a strict-alias warning in tst-inet6_rth.
  • Loading branch information
Roland McGrath committed Nov 29, 2012
1 parent 2af1b32 commit e10c4e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
@@ -1,3 +1,7 @@
2012-11-29 Roland McGrath <roland@hack.frob.com>

* inet/tst-inet6_rth.c (do_test): Use a union rather than type punning.

2012-11-28 Jeff Law <law@redhat.com>

[BZ #13761]
Expand Down
14 changes: 9 additions & 5 deletions inet/tst-inet6_rth.c
Expand Up @@ -66,20 +66,24 @@ inet6_rth_segments returned wrong value after loop with third inet6_rth_add");
goto out;
}

char buf2[1000];
if (inet6_rth_reverse (p, buf2) != 0)
union
{
char buffer[1000];
struct ip6_rthdr0 rthdr0;
} buf2;
if (inet6_rth_reverse (p, buf2.buffer) != 0)
{
puts ("first inet6_rth_reverse call failed");
res = 1;
goto out;
}
if (((struct ip6_rthdr0 *) buf2)->ip6r0_segleft != nseg)
if (buf2.rthdr0.ip6r0_segleft != nseg)
{
puts ("segleft after first inet6_rth_reverse wrong");
res = 1;
}

if (inet6_rth_segments (p) != inet6_rth_segments (buf2))
if (inet6_rth_segments (p) != inet6_rth_segments (buf2.buffer))
{
puts ("number of seconds after first inet6_rth_reverse differs");
res = 1;
Expand All @@ -88,7 +92,7 @@ inet6_rth_segments returned wrong value after loop with third inet6_rth_add");

for (int i = 0; i < nseg; ++i)
{
struct in6_addr *addr = inet6_rth_getaddr (buf2, i);
struct in6_addr *addr = inet6_rth_getaddr (buf2.buffer, i);
if (addr == NULL)
{
printf ("call %d of first inet6_rth_getaddr failed\n",
Expand Down

0 comments on commit e10c4e4

Please sign in to comment.