bin/62615: [PATCH] fix ypxfr/ypxfr_misc.c strict aliasing error
Roop Nanuwa
roop at hqst.com
Mon Feb 9 20:50:21 PST 2004
>Number: 62615
>Category: bin
>Synopsis: [PATCH] fix ypxfr/ypxfr_misc.c strict aliasing error
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Feb 09 20:50:20 PST 2004
>Closed-Date:
>Last-Modified:
>Originator: Roop Nanuwa
>Release: FreeBSD 5.2-CURRENT i386
>Organization:
>Environment:
System: FreeBSD h24-82-165-92.va.shawcable.net 5.2-CURRENT FreeBSD 5.2-CURRENT #0: Sat Feb 7 15:13:01 PST 2004 roop at h24-82-165-92.va.shawcable.net:/usr/obj/usr/src/sys/TURING i386
>Description:
ypxfr_misc.c contains an error that violates strict aliasing rules. When compiling with -O2
optimizations (or just -fstrict-aliasing) the code refuses to compile. The variable 'order'
was created as an unsigned long and then passed by reference as type int* which caused
the compilation error. The variable is only used to return the order value as an unsigned
long. The fix changes the type of 'order' to 'unsigned int' and then passes that to the
yp_order function without breaking aliasing rules. The only need for it to actually
be an unsigned long is for the return type which it is safely up-cast as.
>How-To-Repeat:
Attempt to buildworld with -O2 or -fstrict-aliasing. Among many other locations
one of the errors will be in usr.sbin/rpc.ypxfr which is caused by the above
problem.
>Fix:
--- libexec/ypxfr/ypxfr_misc.c.old Sat May 3 17:59:13 2003
+++ libexec/ypxfr/ypxfr_misc.c Mon Feb 9 20:17:07 2004
@@ -194,9 +194,9 @@
ypxfr_get_order(char *domain, char *map, char *source, const int yplib)
{
if (yplib) {
- unsigned long order;
+ unsigned int order;
int res;
- if ((res = yp_order(domain, map, (int *)&order))) {
+ if ((res = yp_order(domain, map, &order))) {
switch (res) {
case YPERR_DOMAIN:
yp_errno = YPXFR_NODOM;
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list