From f14989c3ee872225c22024012583986a7db43f06 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Fri, 6 Feb 2009 05:22:34 +0000 Subject: [PATCH] Do not assume sizeof(bool_t) == sizeof(krb5_boolean) bool_t is defined as int, krb5_boolean as unsigned int. These are similar size but someone someday might change the krb5_boolean. Instead of passing a krb5_boolean * to xdr_bool, implement xdr_krb5_boolean which keeps the different types separate. This cleans up a number of warnings. ticket: 6374 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21906 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/kadm5/kadm_rpc_xdr.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/lib/kadm5/kadm_rpc_xdr.c b/src/lib/kadm5/kadm_rpc_xdr.c index 7f283f2d0..4e9e4080d 100644 --- a/src/lib/kadm5/kadm_rpc_xdr.c +++ b/src/lib/kadm5/kadm_rpc_xdr.c @@ -220,6 +220,29 @@ xdr_krb5_ui_2(XDR *xdrs, krb5_ui_2 *objp) +static bool_t xdr_krb5_boolean(XDR *xdrs, krb5_boolean *kbool) +{ + bool_t val; + + switch (xdrs->x_op) { + case XDR_DECODE: + if (!xdr_bool(xdrs, &val)) + return FALSE; + + *kbool = (val == FALSE) ? FALSE : TRUE; + return TRUE; + + case XDR_ENCODE: + val = *kbool ? TRUE : FALSE; + return xdr_bool(xdrs, &val); + + case XDR_FREE: + return TRUE; + } + + return FALSE; +} + bool_t xdr_krb5_key_data_nocontents(XDR *xdrs, krb5_key_data *objp) { /* @@ -655,7 +678,7 @@ xdr_chpass3_arg(XDR *xdrs, chpass3_arg *objp) if (!xdr_krb5_principal(xdrs, &objp->princ)) { return (FALSE); } - if (!xdr_bool(xdrs, &objp->keepold)) { + if (!xdr_krb5_boolean(xdrs, &objp->keepold)) { return (FALSE); } if (!xdr_array(xdrs, (caddr_t *)&objp->ks_tuple, @@ -715,7 +738,7 @@ xdr_setkey3_arg(XDR *xdrs, setkey3_arg *objp) if (!xdr_krb5_principal(xdrs, &objp->princ)) { return (FALSE); } - if (!xdr_bool(xdrs, &objp->keepold)) { + if (!xdr_krb5_boolean(xdrs, &objp->keepold)) { return (FALSE); } if (!xdr_array(xdrs, (caddr_t *) &objp->ks_tuple, @@ -752,7 +775,7 @@ xdr_chrand3_arg(XDR *xdrs, chrand3_arg *objp) if (!xdr_krb5_principal(xdrs, &objp->princ)) { return (FALSE); } - if (!xdr_bool(xdrs, &objp->keepold)) { + if (!xdr_krb5_boolean(xdrs, &objp->keepold)) { return (FALSE); } if (!xdr_array(xdrs, (caddr_t *)&objp->ks_tuple, -- 2.26.2