krb5 commit: Silence warnings in lib/rpc
Tom Yu
tlyu at mit.edu
Wed Sep 21 16:52:42 EDT 2016
https://github.com/krb5/krb5/commit/4f1afe0efdb0be43e04567b5636b646322965be8
commit 4f1afe0efdb0be43e04567b5636b646322965be8
Author: Tom Yu <tlyu at mit.edu>
Date: Tue Sep 20 15:58:50 2016 -0400
Silence warnings in lib/rpc
Cast through (void *) in xdr.c to silence pointer target width
warnings. In xdr_sizeof.c, use x_private and x_base as proper
pointers as in xdr_mem.c instead of trying to store an integer in a
pointer.
src/lib/rpc/xdr.c | 10 +++++-----
src/lib/rpc/xdr_sizeof.c | 26 +++++++++++++-------------
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/lib/rpc/xdr.c b/src/lib/rpc/xdr.c
index 4261108..2b7c17b 100644
--- a/src/lib/rpc/xdr.c
+++ b/src/lib/rpc/xdr.c
@@ -362,17 +362,17 @@ xdr_enum(XDR *xdrs, enum_t *ep)
break;
}
if (sizeof (enum sizecheck) == sizeof (long)) {
- return (xdr_long(xdrs, (long *)ep));
+ return (xdr_long(xdrs, (long *)(void *)ep));
} else if (sizeof (enum sizecheck) == sizeof (int)) {
- return (xdr_int(xdrs, (int *)ep));
+ return (xdr_int(xdrs, (int *)(void *)ep));
} else if (sizeof (enum sizecheck) == sizeof (short)) {
- return (xdr_short(xdrs, (short *)ep));
+ return (xdr_short(xdrs, (short *)(void *)ep));
} else {
return (FALSE);
}
#else
- (void) (xdr_short(xdrs, (short *)ep));
- return (xdr_long(xdrs, (long *)ep));
+ (void) (xdr_short(xdrs, (short *)(void *)ep));
+ return (xdr_long(xdrs, (long *)(void *)ep));
#endif
}
diff --git a/src/lib/rpc/xdr_sizeof.c b/src/lib/rpc/xdr_sizeof.c
index 145e387..5b77fa6 100644
--- a/src/lib/rpc/xdr_sizeof.c
+++ b/src/lib/rpc/xdr_sizeof.c
@@ -91,21 +91,21 @@ x_inline(xdrs, len)
if (xdrs->x_op != XDR_ENCODE) {
return (NULL);
}
- if (len < (int) xdrs->x_base) {
+ if (len < (int) ((caddr_t) xdrs->x_private - xdrs->x_base)) {
/* x_private was already allocated */
xdrs->x_handy += len;
return ((rpc_inline_t *) xdrs->x_private);
} else {
/* Free the earlier space and allocate new area */
- if (xdrs->x_private)
- free(xdrs->x_private);
- if ((xdrs->x_private = (caddr_t) malloc(len)) == NULL) {
- xdrs->x_base = 0;
+ if (xdrs->x_base)
+ free(xdrs->x_base);
+ if ((xdrs->x_base = (caddr_t) malloc(len)) == NULL) {
+ xdrs->x_private = NULL;
return (NULL);
}
- xdrs->x_base = (caddr_t) len;
+ xdrs->x_private = xdrs->x_base + len;
xdrs->x_handy += len;
- return ((rpc_inline_t *) xdrs->x_private);
+ return ((rpc_inline_t *) (void *) xdrs->x_base);
}
}
@@ -121,10 +121,10 @@ x_destroy(xdrs)
XDR *xdrs;
{
xdrs->x_handy = 0;
- xdrs->x_base = 0;
- if (xdrs->x_private) {
- free(xdrs->x_private);
- xdrs->x_private = NULL;
+ xdrs->x_private = NULL;
+ if (xdrs->x_base) {
+ free(xdrs->x_base);
+ xdrs->x_base = NULL;
}
return;
}
@@ -159,7 +159,7 @@ xdr_sizeof(func, data)
x.x_base = (caddr_t) 0;
stat = func(&x, data);
- if (x.x_private)
- free(x.x_private);
+ if (x.x_base)
+ free(x.x_base);
return (stat == TRUE ? (unsigned) x.x_handy: 0);
}
More information about the cvs-krb5
mailing list