From: Ronnie Sahlberg Date: Thu, 5 Jul 2012 11:13:04 +0000 (+1000) Subject: Dont just cast *enum_t to *uint32_t X-Git-Tag: upstream/1.9.6^2~242^2~14 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=442b829a054a0e02f26bc050346f3e4df18c579d;p=deb_libnfs.git Dont just cast *enum_t to *uint32_t go via a temporary variable in case these scalars are different size --- diff --git a/include/libnfs-zdr.h b/include/libnfs-zdr.h index 4962a4b..c5794b6 100644 --- a/include/libnfs-zdr.h +++ b/include/libnfs-zdr.h @@ -231,7 +231,7 @@ bool_t libnfs_zdr_u_quad_t(ZDR *zdrs, uint64_t *u); bool_t libnfs_zdr_quad_t(ZDR *zdrs, int64_t *i); #define zdr_enum libnfs_zdr_enum -bool_t libnfs_zdr_enum(ZDR *zdrs, int32_t *e); +bool_t libnfs_zdr_enum(ZDR *zdrs, enum_t *e); #define zdr_bool libnfs_zdr_bool bool_t libnfs_zdr_bool(ZDR *zdrs, bool_t *b); diff --git a/lib/libnfs-zdr.c b/lib/libnfs-zdr.c index fd80a8d..8a60491 100644 --- a/lib/libnfs-zdr.c +++ b/lib/libnfs-zdr.c @@ -160,9 +160,15 @@ bool_t libnfs_zdr_bytes(ZDR *zdrs, char **bufp, uint32_t *size, uint32_t maxsize } -bool_t libnfs_zdr_enum(ZDR *zdrs, int32_t *e) +bool_t libnfs_zdr_enum(ZDR *zdrs, enum_t *e) { - return libnfs_zdr_u_int(zdrs, (uint32_t *)e); + bool_t ret; + int32_t i = *e; + + ret = libnfs_zdr_u_int(zdrs, (uint32_t *)&i); + *e = i; + + return ret; } bool_t libnfs_zdr_bool(ZDR *zdrs, bool_t *b)