Subject: bin/18866: minor rpcgen change to reduce compiler warnings
To: None <gnats-bugs@gnats.netbsd.org>
From: David Holland <dholland@eecs.harvard.edu>
List: netbsd-bugs
Date: 10/30/2002 18:11:51
>Number:         18866
>Category:       bin
>Synopsis:       missing const keyword in rpcgen output
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 30 15:12:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     David A. Holland <dholland@eecs.harvard.edu>
>Release:        NetBSD 1.6H
>Organization:
   - David A. Holland / dholland@eecs.harvard.edu
>Environment:

System: NetBSD alicante 1.6H NetBSD 1.6H (ALICANTE) #4: Fri Sep 20 14:00:10 EDT 2002 dholland@alicante:/usr/src/sys/arch/i386/compile/ALICANTE i386
Architecture: i386
Machine: i386

>Description:

	If you compile certain rpcgen server output with
	-Wwrite-strings, gcc issues a warning calling the
	internally-generated function "_msgout" because it's 
	passing a string constant to a char *.

	This can be fixed by arranging for the function to be 
	declared to take a const char *.

	The enclosed patch applies in src/usr.bin/rpcgen and is
	against the latest version of rpc_svcout.c (1.16).

	It only affects the output if the "output ANSI C" flag is
	specified, so it's ok to use "const".

>How-To-Repeat:

	Generate a *_svc.c file with rpcgen using -C and not -L (which
	inhibits generation of the affected function) and compile it
	with -Wwrite-strings.

>Fix:

Index: rpc_svcout.c
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/rpcgen/rpc_svcout.c,v
retrieving revision 1.16
diff -U5 -r1.16 rpc_svcout.c
--- rpc_svcout.c	2002/02/05 22:41:47	1.16
+++ rpc_svcout.c	2002/10/30 23:01:46
@@ -720,11 +720,11 @@
 	f_print(fout, "static\n");
 	if (!Cflag) {
 		f_print(fout, "void _msgout(msg)\n");
 		f_print(fout, "\tchar *msg;\n");
 	} else {
-		f_print(fout, "void _msgout(char *msg)\n");
+		f_print(fout, "void _msgout(const char *msg)\n");
 	}
 	f_print(fout, "{\n");
 	f_print(fout, "#ifdef RPC_SVC_FG\n");
 	if (inetdflag || pmflag)
 		f_print(fout, "\tif (_rpcpmstart)\n");

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