Mercurial > nomad
changeset 847:fecec851b5d6
common: work around BSD and other system XDR getlong differences
FreeBSD and OpenBSD zero extend the temporary variable while glibc and
illumos sign extend it.
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Sat, 16 Mar 2019 11:28:30 -0400 |
parents | 547f3f8961dc |
children | 2bd3ee5a7f8b |
files | src/common/xdrfd.c |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/common/xdrfd.c Mon Apr 13 16:10:48 2020 -0400 +++ b/src/common/xdrfd.c Sat Mar 16 11:28:30 2019 -0400 @@ -150,7 +150,19 @@ if (!xdrfd_getint32(xdrs, &tmp)) return FALSE; - *p = (long) tmp; + /* + * HACK ALERT! + * + * Different XDR implementations behave differently. At the very + * least: + * - solaris/illumos/unleashed/glibc sign extend + * - freebsd/openbsd zero extends + */ +#if defined(__FreeBSD__) + *p = (uint32_t) tmp; +#else + *p = (long) tmp; +#endif return TRUE; }