sprinkle _DIAGASSERT() around

This commit is contained in:
lukem 2001-01-04 01:45:30 +00:00
parent 596f0820de
commit 29e8291322
1 changed files with 95 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: xdr.c,v 1.22 2000/07/06 03:10:35 christos Exp $ */
/* $NetBSD: xdr.c,v 1.23 2001/01/04 01:45:30 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -35,7 +35,7 @@
static char *sccsid = "@(#)xdr.c 1.35 87/08/12";
static char *sccsid = "@(#)xdr.c 2.1 88/07/29 4.0 RPCSRC";
#else
__RCSID("$NetBSD: xdr.c,v 1.22 2000/07/06 03:10:35 christos Exp $");
__RCSID("$NetBSD: xdr.c,v 1.23 2001/01/04 01:45:30 lukem Exp $");
#endif
#endif
@ -51,6 +51,7 @@ __RCSID("$NetBSD: xdr.c,v 1.22 2000/07/06 03:10:35 christos Exp $");
#include "namespace.h"
#include <assert.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
@ -140,6 +141,9 @@ xdr_int(xdrs, ip)
{
long l;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(ip != NULL);
switch (xdrs->x_op) {
case XDR_ENCODE:
@ -170,6 +174,9 @@ xdr_u_int(xdrs, up)
{
u_long l;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(up != NULL);
switch (xdrs->x_op) {
case XDR_ENCODE:
@ -200,6 +207,10 @@ xdr_long(xdrs, lp)
XDR *xdrs;
long *lp;
{
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(lp != NULL);
switch (xdrs->x_op) {
case XDR_ENCODE:
return (XDR_PUTLONG(xdrs, lp));
@ -221,6 +232,10 @@ xdr_u_long(xdrs, ulp)
XDR *xdrs;
u_long *ulp;
{
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(ulp != NULL);
switch (xdrs->x_op) {
case XDR_ENCODE:
return (XDR_PUTLONG(xdrs, (long *)ulp));
@ -245,6 +260,9 @@ xdr_int32_t(xdrs, int32_p)
{
long l;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(int32_p != NULL);
switch (xdrs->x_op) {
case XDR_ENCODE:
@ -276,6 +294,9 @@ xdr_u_int32_t(xdrs, u_int32_p)
{
u_long l;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(u_int32_p != NULL);
switch (xdrs->x_op) {
case XDR_ENCODE:
@ -307,6 +328,9 @@ xdr_short(xdrs, sp)
{
long l;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(sp != NULL);
switch (xdrs->x_op) {
case XDR_ENCODE:
@ -337,6 +361,9 @@ xdr_u_short(xdrs, usp)
{
u_long l;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(usp != NULL);
switch (xdrs->x_op) {
case XDR_ENCODE:
@ -368,6 +395,9 @@ xdr_int16_t(xdrs, int16_p)
{
long l;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(int16_p != NULL);
switch (xdrs->x_op) {
case XDR_ENCODE:
@ -398,6 +428,9 @@ xdr_u_int16_t(xdrs, u_int16_p)
{
u_long l;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(u_int16_p != NULL);
switch (xdrs->x_op) {
case XDR_ENCODE:
@ -429,6 +462,9 @@ xdr_char(xdrs, cp)
{
int i;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(cp != NULL);
i = (*cp);
if (!xdr_int(xdrs, &i)) {
return (FALSE);
@ -447,6 +483,9 @@ xdr_u_char(xdrs, cp)
{
u_int u;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(cp != NULL);
u = (*cp);
if (!xdr_u_int(xdrs, &u)) {
return (FALSE);
@ -465,6 +504,9 @@ xdr_bool(xdrs, bp)
{
long lb;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(bp != NULL);
switch (xdrs->x_op) {
case XDR_ENCODE:
@ -495,6 +537,9 @@ xdr_enum(xdrs, ep)
{
enum sizecheck { SIZEVAL }; /* used to find the size of an enum */
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(ep != NULL);
/*
* enums are treated as ints
*/
@ -523,6 +568,9 @@ xdr_opaque(xdrs, cp, cnt)
u_int rndup;
static int crud[BYTES_PER_XDR_UNIT];
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(cp != NULL);
/*
* if no data we are done
*/
@ -573,9 +621,15 @@ xdr_bytes(xdrs, cpp, sizep, maxsize)
u_int *sizep;
u_int maxsize;
{
char *sp = *cpp; /* sp is the actual string pointer */
char *sp; /* sp is the actual string pointer */
u_int nodesize;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(cpp != NULL);
_DIAGASSERT(sizep != NULL);
sp = *cpp;
/*
* first deal with the length since xdr bytes are counted
*/
@ -628,6 +682,9 @@ xdr_netobj(xdrs, np)
struct netobj *np;
{
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(np != NULL);
return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ));
}
@ -647,11 +704,17 @@ xdr_union(xdrs, dscmp, unp, choices, dfault)
XDR *xdrs;
enum_t *dscmp; /* enum to decide which arm to work on */
char *unp; /* the union itself */
const struct xdr_discrim *choices; /* [value, xdr proc] for each arm */
const struct xdr_discrim *choices; /* [value, xdr proc] for each arm */
xdrproc_t dfault; /* default xdr routine */
{
enum_t dscm;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(dscmp != NULL);
_DIAGASSERT(unp != NULL);
_DIAGASSERT(choices != NULL);
/* dfault may be NULL */
/*
* we deal with the discriminator; it's an enum
*/
@ -697,10 +760,15 @@ xdr_string(xdrs, cpp, maxsize)
char **cpp;
u_int maxsize;
{
char *sp = *cpp; /* sp is the actual string pointer */
char *sp; /* sp is the actual string pointer */
u_int size;
u_int nodesize;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(cpp != NULL);
sp = *cpp;
/*
* first deal with the length since xdr strings are counted-strings
*/
@ -763,6 +831,10 @@ xdr_wrapstring(xdrs, cpp)
XDR *xdrs;
char **cpp;
{
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(cpp != NULL);
return xdr_string(xdrs, cpp, LASTUNSIGNED);
}
@ -784,6 +856,9 @@ xdr_int64_t(xdrs, llp)
{
u_long ul[2];
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(llp != NULL);
switch (xdrs->x_op) {
case XDR_ENCODE:
ul[0] = (u_long)((u_int64_t)*llp >> 32) & 0xffffffff;
@ -817,6 +892,9 @@ xdr_u_int64_t(xdrs, ullp)
{
u_long ul[2];
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(ullp != NULL);
switch (xdrs->x_op) {
case XDR_ENCODE:
ul[0] = (u_long)(*ullp >> 32) & 0xffffffff;
@ -849,6 +927,9 @@ xdr_hyper(xdrs, llp)
longlong_t *llp;
{
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(llp != NULL);
/*
* Don't bother open-coding this; it's a fair amount of code. Just
* call xdr_int64_t().
@ -866,6 +947,9 @@ xdr_u_hyper(xdrs, ullp)
u_longlong_t *ullp;
{
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(ullp != NULL);
/*
* Don't bother open-coding this; it's a fair amount of code. Just
* call xdr_u_int64_t().
@ -883,6 +967,9 @@ xdr_longlong_t(xdrs, llp)
longlong_t *llp;
{
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(llp != NULL);
/*
* Don't bother open-coding this; it's a fair amount of code. Just
* call xdr_int64_t().
@ -900,6 +987,9 @@ xdr_u_longlong_t(xdrs, ullp)
u_longlong_t *ullp;
{
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(ullp != NULL);
/*
* Don't bother open-coding this; it's a fair amount of code. Just
* call xdr_u_int64_t().