Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Oct 1999 18:10:02 -0700 (PDT)
From:      Bruce Evans <bde@zeta.org.au>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/14142: sendmail: mci.c: bad pointer conversion in debug print
Message-ID:  <199910060110.SAA02518@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/14142; it has been noted by GNATS.

From: Bruce Evans <bde@zeta.org.au>
To: Valentin Nechayev <netch@lucky.net>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/14142: sendmail: mci.c: bad pointer conversion in debug
 print
Date: Wed, 6 Oct 1999 10:59:25 +1000 (EST)

 > The following piece of mci_dump() uses bad conversion:
 > 
 >         snprintf(p, SPACELEFT(buf, p), "MCI@%lx: ",
 >                 sizeof(void *) == sizeof(u_long) ?
 >                 (u_long)(void *)mci : (u_long)(u_int)(void *)mci);
 >  
 > On Alpha architecture, conversion from void* to u_int loses significant bits.
 
 On FreeBSD-alpha sizeof(void *) == sizeof(long), so the conversion from
 void * to u_int is never executed.  Unfortunately, gcc apparently warns
 about casts from pointers to integers of a different size even in dead
 code.
 
 On FreeBSD_i386-with-64-bit-longs, gcc warns about the dead code in the
 other arm of the if and about 3 casts from pointers to u_longs.  All these
 problems can be fixed better now by casting pointers to
 (u_long)(uintptr_t)(void *) and printing them with %lx, or if the format
 doesn't matter, by casting pointers to (void *) and printing them with %p.
 
 > These conversions are FreeBSD-specific; original Allman's sendmail
 > does not contain them.
 
 The original code was broken at runtime (it shows only the low 32 bits of
 pointers on FreeBSD-alpha).
 
 Bruce
 
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199910060110.SAA02518>