Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/rpcgen Deal with other sizeof() return issues. We us...



details:   https://anonhg.NetBSD.org/src/rev/ae068e0320d0
branches:  trunk
changeset: 521796:ae068e0320d0
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Feb 05 22:41:47 2002 +0000

description:
Deal with other sizeof() return issues. We usually cast it to u_int, because
this is what the rpc function argument passing expects, or use socklen_t
as appropriate...

diffstat:

 usr.bin/rpcgen/rpc_cout.c   |   8 ++++----
 usr.bin/rpcgen/rpc_svcout.c |  14 +++++++-------
 usr.bin/rpcgen/rpc_tblout.c |   9 +++++----
 3 files changed, 16 insertions(+), 15 deletions(-)

diffs (122 lines):

diff -r 85b1cfd73f26 -r ae068e0320d0 usr.bin/rpcgen/rpc_cout.c
--- a/usr.bin/rpcgen/rpc_cout.c Tue Feb 05 22:05:42 2002 +0000
+++ b/usr.bin/rpcgen/rpc_cout.c Tue Feb 05 22:41:47 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rpc_cout.c,v 1.20 2002/02/05 22:05:42 christos Exp $   */
+/*     $NetBSD: rpc_cout.c,v 1.21 2002/02/05 22:41:47 christos Exp $   */
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)rpc_cout.c 1.13 89/02/22 (C) 1987 SMI";
 #else
-__RCSID("$NetBSD: rpc_cout.c,v 1.20 2002/02/05 22:05:42 christos Exp $");
+__RCSID("$NetBSD: rpc_cout.c,v 1.21 2002/02/05 22:41:47 christos Exp $");
 #endif
 #endif
 
@@ -220,9 +220,9 @@
        char   *type;
 {
        if (streq(type, "bool")) {
-               f_print(fout, ", sizeof(bool_t), (xdrproc_t)xdr_bool");
+               f_print(fout, ", (u_int)sizeof(bool_t), (xdrproc_t)xdr_bool");
        } else {
-               f_print(fout, ", sizeof(");
+               f_print(fout, ", (u_int)sizeof(");
                if (undefined(type) && prefix) {
                        f_print(fout, "%s ", prefix);
                }
diff -r 85b1cfd73f26 -r ae068e0320d0 usr.bin/rpcgen/rpc_svcout.c
--- a/usr.bin/rpcgen/rpc_svcout.c       Tue Feb 05 22:05:42 2002 +0000
+++ b/usr.bin/rpcgen/rpc_svcout.c       Tue Feb 05 22:41:47 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rpc_svcout.c,v 1.15 2002/01/31 19:36:49 tv Exp $       */
+/*     $NetBSD: rpc_svcout.c,v 1.16 2002/02/05 22:41:47 christos Exp $ */
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)rpc_svcout.c 1.29 89/03/30 (C) 1987 SMI";
 #else
-__RCSID("$NetBSD: rpc_svcout.c,v 1.15 2002/01/31 19:36:49 tv Exp $");
+__RCSID("$NetBSD: rpc_svcout.c,v 1.16 2002/02/05 22:41:47 christos Exp $");
 #endif
 #endif
 
@@ -536,7 +536,7 @@
                print_return("\t\t");
                f_print(fout, "\t}\n");
 
-               f_print(fout, "\t(void) memset((char *)&%s, 0, sizeof (%s));\n", ARG, ARG);
+               f_print(fout, "\t(void) memset(&%s, 0, sizeof(%s));\n", ARG, ARG);
                printif("getargs", TRANSP, "(caddr_t)&", ARG);
                printerr("decode", TRANSP);
                print_return("\t\t");
@@ -630,15 +630,15 @@
        f_print(fout, "\tint sock;\n");
        f_print(fout, "\tint proto = 0;\n");
        f_print(fout, "\tstruct sockaddr_in saddr;\n");
-       f_print(fout, "\tint asize = sizeof (saddr);\n");
+       f_print(fout, "\tsocklen_t asize = (socklen_t)sizeof(saddr);\n");
        f_print(fout, "\n");
        f_print(fout,
            "\tif (getsockname(0, (struct sockaddr *)&saddr, &asize) == 0) {\n");
-       f_print(fout, "\t\tint ssize = sizeof (int);\n\n");
+       f_print(fout, "\t\tsocklen_t ssize = (socklen_t)sizeof(int);\n\n");
        f_print(fout, "\t\tif (saddr.sin_family != AF_INET)\n");
        f_print(fout, "\t\t\texit(1);\n");
        f_print(fout, "\t\tif (getsockopt(0, SOL_SOCKET, SO_TYPE,\n");
-       f_print(fout, "\t\t\t\t(char *)&_rpcfdtype, &ssize) == -1)\n");
+       f_print(fout, "\t\t\t\t(void *)&_rpcfdtype, &ssize) == -1)\n");
        f_print(fout, "\t\t\texit(1);\n");
        f_print(fout, "\t\tsock = 0;\n");
        f_print(fout, "\t\t_rpcpmstart = 1;\n");
@@ -805,7 +805,7 @@
 
        P("     prev = actual.sin_addr;\n\n");
 
-       P("     hp = gethostbyaddr((char *) &actual.sin_addr, sizeof(actual.sin_addr), AF_INET);\n");
+       P("     hp = gethostbyaddr((char *)&actual.sin_addr, sizeof(actual.sin_addr), AF_INET);\n");
        P("     if (hp == NULL) {                       /* dummy one up */\n");
        P("             extern char *inet_ntoa();\n");
        P("             strcpy(cname, inet_ntoa(actual.sin_addr));\n");
diff -r 85b1cfd73f26 -r ae068e0320d0 usr.bin/rpcgen/rpc_tblout.c
--- a/usr.bin/rpcgen/rpc_tblout.c       Tue Feb 05 22:05:42 2002 +0000
+++ b/usr.bin/rpcgen/rpc_tblout.c       Tue Feb 05 22:41:47 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rpc_tblout.c,v 1.9 2002/01/31 19:36:49 tv Exp $        */
+/*     $NetBSD: rpc_tblout.c,v 1.10 2002/02/05 22:41:47 christos Exp $ */
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)rpc_tblout.c 1.4 89/02/22 (C) 1988 SMI";
 #else
-__RCSID("$NetBSD: rpc_tblout.c,v 1.9 2002/01/31 19:36:49 tv Exp $");
+__RCSID("$NetBSD: rpc_tblout.c,v 1.10 2002/02/05 22:41:47 christos Exp $");
 #endif
 #endif
 
@@ -61,7 +61,8 @@
  \t(xdrproc_t)xdr_void,\t\t0,\n\
  \t(xdrproc_t)xdr_void,\t\t0,\n";
 
-static const char tbl_nproc[] = "int %s_nproc =\n\tsizeof(%s_table)/sizeof(%s_table[0]);\n\n";
+static const char tbl_nproc[] =
+    "u_int %s_nproc =\n\t(u_int)(sizeof(%s_table)/sizeof(%s_table[0]));\n\n";
 
 static void write_table __P((definition *));
 static void printit __P((char *, char *));
@@ -170,7 +171,7 @@
        if (streq(type, "void")) {
                f_print(fout, "0");
        } else {
-               f_print(fout, "sizeof ( ");
+               f_print(fout, "(u_int)sizeof(");
                /* XXX: should "follow" be 1 ??? */
                ptype(prefix, type, 0);
                f_print(fout, ")");



Home | Main Index | Thread Index | Old Index