Skip to content

xdr_destroy and XDR_CONTROL should be expressions, not statements #29

@dmhayden

Description

@dmhayden

xdr_destroy and XDR_CONTROL are defined as "if" statements in xdr.h, but they should be expressions.
#define xdr_destroy(xdrs)
if ((xdrs)->x_ops->x_destroy)
(*(xdrs)->x_ops->x_destroy)(xdrs)

As an "if" statement, xdr_destroy() can't appear in the increment clause of a "for" statement:
for (cond; test; xdr_destroy(xp)) { ... } // syntax error

Much worse, it can cause unexpected results when used within an if statement. Consider:
if (cond)
xdr_destroy(xdrs);
else
oops();

If xdrs->x_ops->x_destroy is NULL, then oops() will be called, which is not what the programmer would expect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions