Subject: misc/14066: rpcgen with -N generates invalid C code
To: None <gnats-bugs@gnats.netbsd.org>
From: None <cwlh@nortelnetworks.com>
List: netbsd-bugs
Date: 09/25/2001 14:41:55
>Number:         14066
>Category:       misc
>Synopsis:       rpcgen with -N generates invalid C code
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 25 14:43:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Chris Hobbs
>Release:        1.5.1
>Organization:
Nortel Networks
>Environment:
NetBSD kanNetBsd1 1.5.1 NetBSD 1.5.1 (GENERIC) #56: 
Mon Jul  2 15:54:23 CEST 2001     
he@nsa.uninett.no:/usr/src/sys/arch/i386/compile/GENERIC i386
>Description:
When the following interface definition is compiled with "rpcgen -N"
then the code generated contains a C syntax error.

program BUG
    {
    version ONE
        {
        void doit( void ) = 1;
        } = 1;
    } = 0x2000001;

The generated code in tryit_clnt.c is as follows:

/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#include "tryit.h"

/* Default timeout can be changed using clnt_control() */
static struct timeval TIMEOUT = { 25, 0 };

void *
doit_1(clnt)
        CLIENT *clnt;
{
        static char clnt_res;

        memset((char *)&clnt_res, 0, sizeof(clnt_res));
        if (clnt_call(clnt, doit, xdr_void, NULL, xdr_void, &clnt_res, TIMEOUT) 
!= RPC_SUCCESS) {
                return (NULL);
        return ((void *)&clnt_res);
}

It can be seen that the opening brace in the if (clnt_call .... is not
closed. This, obviously, causes a compilation error.
>How-To-Repeat:
Enter the tryit.x file given in the problem description and type
"rpcgen -N tryit.x". Of course, it is more normal to use the command 
"rpcgen -C -N tryit.x" but this also causes invalid code to be
generated.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted: