* Add 'static' before some functions and global variables.

* Change 'aliascheck', 'funccheck', 'structcheck' and 'valuecheck' to
  non-return because of the ignore return value.

* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg...@cn.fujitsu.com>
---
 testcases/network/lib6/runcc.c | 83 +++++++++++++++++-------------------------
 testcases/network/lib6/runcc.h | 33 ++++++++++-------
 2 files changed, 54 insertions(+), 62 deletions(-)

diff --git a/testcases/network/lib6/runcc.c b/testcases/network/lib6/runcc.c
index 91a0b16..780c261 100644
--- a/testcases/network/lib6/runcc.c
+++ b/testcases/network/lib6/runcc.c
@@ -1,6 +1,6 @@
 /*
- *
  *   Copyright (c) International Business Machines  Corp., 2001
+ *     05/2005 written by David L Stevens
  *
  *   This program is free software;  you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -13,19 +13,12 @@
  *   the GNU General Public License for more details.
  *
  *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
USA
+ *   along with this program;  if not, write to the Free Software Foundation,
+ *   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /*
  * runcc.a - common functions for lib6 testing
- *
- * HISTORY
- *     05/2005 written by David L Stevens
- *
- * RESTRICTIONS:
- *  None.
- *
  */
 
 #include <stdio.h>
@@ -37,17 +30,17 @@
 
 #include "test.h"
 
-char fieldref[1024];
-char program[8192];
+static char fieldref[1024];
+static char program[8192];
 
-char *filetmpl = "/tmp/%.*s_XXXXXX";
+static char *filetmpl = "/tmp/%.*s_XXXXXX";
 
-char cmd[1024];
+static char cmd[1024];
 
 /*
  * like strspn, with ASCII, numbers and underscore only
  */
-int strfpn(char *name)
+static int strfpn(char *name)
 {
        int i;
 
@@ -57,7 +50,7 @@ int strfpn(char *name)
        return i;
 }
 
-int runcc(char *tname, char *filename0, char *program)
+static int runcc(char *tname, char *filename0, char *program)
 {
        static char filename[1024];
        int fd, es, saved_errno;
@@ -133,21 +126,20 @@ int runcc(char *tname, char *filename0, char *program)
        return 0;
 }
 
-char *field_fmt = "\n\texit((offsetof(struct %s, %s) != %s) || "
-    "sizeof(tst.%s) != (%s));\n";
+static char *field_fmt = "\n\texit((offsetof(struct %s, %s) != %s) || "
+                        "sizeof(tst.%s) != (%s));\n";
 /* no offset check */
-char *field_fmt2 = "\n\texit(sizeof(tst.%s) != (%s));\n";
+static char *field_fmt2 = "\n\texit(sizeof(tst.%s) != (%s));\n";
 
-const char *stmpl =
-    "%s\n#ifndef offsetof\n"
-    "#define offsetof(dtype, dfield) ((int)&((dtype *)0)->dfield)\n"
-    "#endif\n\nstruct %s tst;\n\nmain(int argc, char *argv[])\n{\n\t%s\n}\n";
+static const char *stmpl = "%s\n#ifndef offsetof\n"
+                          "#define offsetof(dtype, dfield) "
+                          "((int)&((dtype *)0)->dfield)\n"
+                          "#endif\n\nstruct %s tst;\n\n"
+                          "main(int argc, char *argv[])\n{\n\t%s\n}\n";
 
-int
-structcheck(char *tname, char *incl, char *structure, char *field,
-           char *offset, char *size)
+void structcheck(char *tname, char *incl, char *structure, char *field,
+                char *offset, char *size)
 {
-       int rv;
        static char filename[1024];
 
        if (offset)
@@ -158,52 +150,45 @@ structcheck(char *tname, char *incl, char *structure, 
char *field,
        sprintf(program, stmpl, incl, structure, fieldref);
        snprintf(filename, sizeof(filename), filetmpl, strfpn(structure),
                 structure);
-       rv = runcc(tname, filename, program);
-       return rv;
+       runcc(tname, filename, program);
 }
 
-char *aliasfmt =
-    "exit(&tst.%s != &tst.%s || sizeof(tst.%s) != sizeof(tst.%s));";
+static char *aliasfmt = "exit(&tst.%s != &tst.%s || "
+                       "sizeof(tst.%s) != sizeof(tst.%s));";
 
-int
-aliascheck(char *tname, char *incl, char *structure, char *field, char *dname)
+void aliascheck(char *tname, char *incl, char *structure, char *field,
+               char *dname)
 {
-       int rv;
        static char filename[1024];
 
        sprintf(fieldref, aliasfmt, field, dname, field, dname);
        sprintf(program, stmpl, incl, structure, fieldref);
        snprintf(filename, sizeof(filename), filetmpl, strfpn(structure),
                 structure);
-       rv = runcc(tname, filename, program);
-       return rv;
+       runcc(tname, filename, program);
 }
 
-const char *dtmpl =
-    "%s\n\nmain(int argc, char *argv[])\n{\n\texit((%s) != (%s));\n}\n";
+const char *dtmpl = "%s\n\nmain(int argc, char *argv[])\n"
+                   "{\n\texit((%s) != (%s));\n}\n";
 
-int valuecheck(char *tname, char *incl, char *dname, char *dval)
+void valuecheck(char *tname, char *incl, char *dname, char *dval)
 {
-       int rv;
        static char filename[1024];
 
        sprintf(program, dtmpl, incl, dname, dval);
        snprintf(filename, sizeof(filename), filetmpl, strfpn(dname), dname);
-       rv = runcc(tname, filename, program);
-       return rv;
+       runcc(tname, filename, program);
 }
 
-const char *ftmpl =
-    "%s\n\nmain(int argc, char *argv[])\n{\n#ifdef %s\n\texit(0);\n#else\n"
-    "\tsyntax error;\n#endif\n}\n";
+const char *ftmpl = "%s\n\nmain(int argc, char *argv[])\n"
+                   "{\n#ifdef %s\n\texit(0);\n#else\n"
+                   "\tsyntax error;\n#endif\n}\n";
 
-int funccheck(char *tname, char *incl, char *fname)
+void funccheck(char *tname, char *incl, char *fname)
 {
-       int rv;
        static char filename[1024];
 
        sprintf(program, ftmpl, incl, fname);
        snprintf(filename, sizeof(filename), filetmpl, strfpn(fname), fname);
-       rv = runcc(tname, filename, program);
-       return rv;
+       runcc(tname, filename, program);
 }
diff --git a/testcases/network/lib6/runcc.h b/testcases/network/lib6/runcc.h
index 4e2a0d5..0e9228b 100644
--- a/testcases/network/lib6/runcc.h
+++ b/testcases/network/lib6/runcc.h
@@ -1,5 +1,4 @@
 /*
- *
  *   Copyright (c) International Business Machines  Corp., 2001
  *
  *   This program is free software;  you can redistribute it and/or modify
@@ -13,18 +12,26 @@
  *   the GNU General Public License for more details.
  *
  *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
USA
+ *   along with this program;  if not, write to the Free Software Foundation,
+ *   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-int aliascheck(char *tname, char *incl, char *structure, char *field,
-       char *dname);
-int funccheck(char *tname, char *incl, char *fname);
-int structcheck(char *tname, char *incl, char *structure, char *field,
-       char *offset, char *size);
-int valuecheck(char *tname, char *incl, char *dname, char *dval);
+#ifndef __RUNCC_H__
+#define __RUNCC_H__
+
+void aliascheck(char *tname, char *incl, char *structure, char *field,
+               char *dname);
+
+void funccheck(char *tname, char *incl, char *fname);
+
+void structcheck(char *tname, char *incl, char *structure, char *field,
+                char *offset, char *size);
+
+void valuecheck(char *tname, char *incl, char *dname, char *dval);
+
+#define IP6_H          "#include <netinet/ip6.h>\n"
+#define IN_H           "#include <netinet/in.h>\n"
+#define ICMP6_H                "#include <netinet/icmp6.h>\n"
+#define SOCKET_H       "#include <sys/types.h>\n#include <sys/socket.h>\n"
 
-#define IP6_H "#include <netinet/ip6.h>\n"
-#define IN_H "#include <netinet/in.h>\n"
-#define ICMP6_H "#include <netinet/icmp6.h>\n"
-#define SOCKET_H "#include <sys/types.h>\n#include <sys/socket.h>\n"
+#endif  /* __RUNCC_H__ */
-- 
1.9.3


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to