svn commit: trunk/busybox: include modutils networking networking/l etc...

vda at busybox.net vda at busybox.net
Mon Jan 29 23:43:52 UTC 2007


Author: vda
Date: 2007-01-29 15:43:52 -0800 (Mon, 29 Jan 2007)
New Revision: 17659

Log:
preparatory patch for -Wwrite-strings #6


Modified:
   trunk/busybox/include/libbb.h
   trunk/busybox/modutils/modprobe.c
   trunk/busybox/networking/interface.c
   trunk/busybox/networking/libiproute/ll_proto.c
   trunk/busybox/networking/libiproute/rtm_map.c
   trunk/busybox/networking/libiproute/rtm_map.h
   trunk/busybox/runit/sv.c


Changeset:
Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2007-01-29 23:43:18 UTC (rev 17658)
+++ trunk/busybox/include/libbb.h	2007-01-29 23:43:52 UTC (rev 17659)
@@ -123,8 +123,8 @@
 
 /* This structure defines protocol families and their handlers. */
 struct aftype {
-	char *name;
-	char *title;
+	const char *name;
+	const char *title;
 	int af;
 	int alen;
 	char *(*print) (unsigned char *);
@@ -143,8 +143,8 @@
 
 /* This structure defines hardware protocols and their handlers. */
 struct hwtype {
-	char *name;
-	char *title;
+	const char *name;
+	const char *title;
 	int type;
 	int alen;
 	char *(*print) (unsigned char *);

Modified: trunk/busybox/modutils/modprobe.c
===================================================================
--- trunk/busybox/modutils/modprobe.c	2007-01-29 23:43:18 UTC (rev 17658)
+++ trunk/busybox/modutils/modprobe.c	2007-01-29 23:43:52 UTC (rev 17659)
@@ -37,9 +37,9 @@
 
 struct mod_list_t {	/* two-way list of modules to process */
 	/* a module description */
-	char *  m_name;
-	char *  m_path;
-	struct mod_opt_t *  m_options;
+	const char * m_name;
+	char * m_path;
+	struct mod_opt_t * m_options;
 
 	struct mod_list_t * m_prev;
 	struct mod_list_t * m_next;
@@ -577,7 +577,7 @@
 	return ret;
 }
 
-static int mod_process(struct mod_list_t *list, int do_insert)
+static int mod_process(const struct mod_list_t *list, int do_insert)
 {
 	int rc = 0;
 	char **argv = NULL;
@@ -603,16 +603,16 @@
 		argv = xmalloc(6 * sizeof(char*));
 		if (do_insert) {
 			if (already_loaded(list->m_name) != 1) {
-				argv[argc++] = "insmod";
+				argv[argc++] = (char*)"insmod";
 				if (ENABLE_FEATURE_2_4_MODULES) {
 					if (do_syslog)
-						argv[argc++] = "-s";
+						argv[argc++] = (char*)"-s";
 					if (autoclean)
-						argv[argc++] = "-k";
+						argv[argc++] = (char*)"-k";
 					if (quiet)
-						argv[argc++] = "-q";
+						argv[argc++] = (char*)"-q";
 					else if (verbose) /* verbose and quiet are mutually exclusive */
-						argv[argc++] = "-v";
+						argv[argc++] = (char*)"-v";
 				}
 				argv[argc++] = list->m_path;
 				if (ENABLE_FEATURE_CLEAN_UP)
@@ -629,10 +629,10 @@
 		} else {
 			/* modutils uses short name for removal */
 			if (already_loaded(list->m_name) != 0) {
-				argv[argc++] = "rmmod";
+				argv[argc++] = (char*)"rmmod";
 				if (do_syslog)
-					argv[argc++] = "-s";
-				argv[argc++] = list->m_name;
+					argv[argc++] = (char*)"-s";
+				argv[argc++] = (char*)list->m_name;
 				if (ENABLE_FEATURE_CLEAN_UP)
 					argc_malloc = argc;
 			}
@@ -810,13 +810,14 @@
 
 static int mod_insert(char *mod, int argc, char **argv)
 {
-	struct mod_list_t *tail = 0;
-	struct mod_list_t *head = 0;
+	struct mod_list_t *tail = NULL;
+	struct mod_list_t *head = NULL;
 	int rc;
 
 	// get dep list for module mod
 	check_dep(mod, &head, &tail);
 
+	rc = 1;
 	if (head && tail) {
 		if (argc) {
 			int i;
@@ -826,7 +827,8 @@
 		}
 
 		// process tail ---> head
-		if ((rc = mod_process(tail, 1)) != 0) {
+		rc = mod_process(tail, 1);
+		if (rc) {
 			/*
 			 * In case of using udev, multiple instances of modprobe can be
 			 * spawned to load the same module (think of two same usb devices,
@@ -837,31 +839,26 @@
 				rc = 0;
 		}
 	}
-	else
-		rc = 1;
-
 	return rc;
 }
 
 static int mod_remove(char *mod)
 {
 	int rc;
-	static struct mod_list_t rm_a_dummy = { "-a", NULL, NULL, NULL, NULL };
+	static const struct mod_list_t rm_a_dummy = { "-a", NULL, NULL, NULL, NULL };
 
-	struct mod_list_t *head = 0;
-	struct mod_list_t *tail = 0;
+	struct mod_list_t *head = NULL;
+	struct mod_list_t *tail = NULL;
 
 	if (mod)
 		check_dep(mod, &head, &tail);
 	else  // autoclean
-		head = tail = &rm_a_dummy;
+		head = tail = (struct mod_list_t*) &rm_a_dummy;
 
+	rc = 1;
 	if (head && tail)
 		rc = mod_process(head, 0);  // process head ---> tail
-	else
-		rc = 1;
 	return rc;
-
 }
 
 int modprobe_main(int argc, char** argv)

Modified: trunk/busybox/networking/interface.c
===================================================================
--- trunk/busybox/networking/interface.c	2007-01-29 23:43:18 UTC (rev 17658)
+++ trunk/busybox/networking/interface.c	2007-01-29 23:43:52 UTC (rev 17659)
@@ -31,18 +31,9 @@
  *			(default AF was wrong)
  */
 
-#include "inet_common.h"
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
 #include <net/if.h>
 #include <net/if_arp.h>
+#include "inet_common.h"
 #include "busybox.h"
 
 #ifdef CONFIG_FEATURE_IPV6
@@ -178,8 +169,7 @@
 
 	if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
 		return safe_strncpy(buff, "[NONE SET]", sizeof(buff));
-	if (INET6_rresolve
-		(buff, sizeof(buff), (struct sockaddr_in6 *) sap, numeric) != 0)
+	if (INET6_rresolve(buff, sizeof(buff), (struct sockaddr_in6 *) sap, numeric))
 		return safe_strncpy(buff, "[UNKNOWN]", sizeof(buff));
 	return buff;
 }
@@ -771,7 +761,7 @@
 static int do_if_fetch(struct interface *ife)
 {
 	if (if_fetch(ife) < 0) {
-		char *errmsg;
+		const char *errmsg;
 
 		if (errno == ENODEV) {
 			/* Give better error message for this case. */

Modified: trunk/busybox/networking/libiproute/ll_proto.c
===================================================================
--- trunk/busybox/networking/libiproute/ll_proto.c	2007-01-29 23:43:18 UTC (rev 17658)
+++ trunk/busybox/networking/libiproute/ll_proto.c	2007-01-29 23:43:52 UTC (rev 17659)
@@ -24,7 +24,7 @@
 #define __PF(f,n) { ETH_P_##f, #n },
 static struct {
 	int id;
-	char *name;
+	const char *name;
 } llproto_names[] = {
 __PF(LOOP,loop)
 __PF(PUP,pup)

Modified: trunk/busybox/networking/libiproute/rtm_map.c
===================================================================
--- trunk/busybox/networking/libiproute/rtm_map.c	2007-01-29 23:43:18 UTC (rev 17658)
+++ trunk/busybox/networking/libiproute/rtm_map.c	2007-01-29 23:43:52 UTC (rev 17659)
@@ -13,11 +13,10 @@
 
 #include <stdlib.h>
 #include <string.h>
-
 #include "rt_names.h"
 #include "utils.h"
 
-char *rtnl_rtntype_n2a(int id, char *buf, int len)
+const char *rtnl_rtntype_n2a(int id, char *buf, int len)
 {
 	switch (id) {
 	case RTN_UNSPEC:

Modified: trunk/busybox/networking/libiproute/rtm_map.h
===================================================================
--- trunk/busybox/networking/libiproute/rtm_map.h	2007-01-29 23:43:18 UTC (rev 17658)
+++ trunk/busybox/networking/libiproute/rtm_map.h	2007-01-29 23:43:52 UTC (rev 17659)
@@ -2,7 +2,7 @@
 #ifndef __RTM_MAP_H__
 #define __RTM_MAP_H__ 1
 
-char *rtnl_rtntype_n2a(int id, char *buf, int len);
+const char *rtnl_rtntype_n2a(int id, char *buf, int len);
 int rtnl_rtntype_a2n(int *id, char *arg);
 
 int get_rt_realms(uint32_t *realms, char *arg);

Modified: trunk/busybox/runit/sv.c
===================================================================
--- trunk/busybox/runit/sv.c	2007-01-29 23:43:18 UTC (rev 17658)
+++ trunk/busybox/runit/sv.c	2007-01-29 23:43:52 UTC (rev 17659)
@@ -7,33 +7,33 @@
 #include "runit_lib.h"
 
 static char *action;
-static char *acts;
-static char *varservice = "/var/service/";
+static const char *acts;
+static const char *varservice = "/var/service/";
 static char **service;
 static char **servicex;
 static unsigned services;
-static unsigned rc = 0;
-static unsigned verbose = 0;
+static unsigned rc;
+static unsigned verbose;
 static unsigned long waitsec = 7;
-static unsigned kll = 0;
+static unsigned kll;
 static struct taia tstart, tnow, tdiff;
 static struct tai tstatus;
 
-static int (*act)(char*) = 0;
-static int (*cbk)(char*) = 0;
+static int (*act)(const char*);
+static int (*cbk)(const char*);
 
 static int curdir, fd, r;
 static char svstatus[20];
 
 #define usage() bb_show_usage()
 
-static void fatal_cannot(char *m1)
+static void fatal_cannot(const char *m1)
 {
 	bb_perror_msg("fatal: cannot %s", m1);
 	_exit(151);
 }
 
-static void out(char *p, char *m1)
+static void out(const char *p, const char *m1)
 {
 	printf("%s%s: %s", p, *service, m1);
 	if (errno) {
@@ -51,15 +51,16 @@
 #define TIMEOUT "timeout: "
 #define KILL    "kill: "
 
-static void fail(char *m1) { ++rc; out(FAIL, m1); }
-static void failx(char *m1) { errno = 0; fail(m1); }
-static void warn_cannot(char *m1) { ++rc; out("warning: cannot ", m1); }
-static void warnx_cannot(char *m1) { errno = 0; warn_cannot(m1); }
-static void ok(char *m1) { errno = 0; out(OK, m1); }
+static void fail(const char *m1) { ++rc; out(FAIL, m1); }
+static void failx(const char *m1) { errno = 0; fail(m1); }
+static void warn_cannot(const char *m1) { ++rc; out("warning: cannot ", m1); }
+static void warnx_cannot(const char *m1) { errno = 0; warn_cannot(m1); }
+static void ok(const char *m1) { errno = 0; out(OK, m1); }
 
 static int svstatus_get(void)
 {
-	if ((fd = open_write("supervise/ok")) == -1) {
+	fd = open_write("supervise/ok");
+	if (fd == -1) {
 		if (errno == ENODEV) {
 			*acts == 'x' ? ok("runsv not running")
 			             : failx("runsv not running");
@@ -69,7 +70,8 @@
 		return -1;
 	}
 	close(fd);
-	if ((fd = open_read("supervise/status")) == -1) {
+	fd = open_read("supervise/status");
+	if (fd == -1) {
 		warn_cannot("open supervise/status");
 		return -1;
 	}
@@ -83,7 +85,7 @@
 	return 1;
 }
 
-static unsigned svstatus_print(char *m)
+static unsigned svstatus_print(const char *m)
 {
 	int pid;
 	int normallyup = 0;
@@ -121,7 +123,7 @@
 	return pid ? 1 : 2;
 }
 
-static int status(char *unused)
+static int status(const char *unused)
 {
 	r = svstatus_get();
 	switch (r) { case -1: case 0: return 0; }
@@ -156,8 +158,8 @@
 		return 0;
 	}
 	if (!pid) {
-		prog[0] = "./check";
-		prog[1] = 0;
+		prog[0] = (char*)"./check";
+		prog[1] = NULL;
 		close(1);
 		execve("check", prog, environ);
 		bb_perror_msg(WARN"cannot run %s/check", *service);
@@ -171,7 +173,7 @@
 	return !wait_exitcode(w);
 }
 
-static int check(char *a)
+static int check(const char *a)
 {
 	unsigned pid;
 
@@ -200,15 +202,18 @@
 		if ((!pid && tstart.sec.x > tstatus.x) || (pid && svstatus[17] != 'd'))
 			return 0;
 	}
-	printf(OK); svstatus_print(*service); puts(""); /* will also flush the output */
+	printf(OK);
+	svstatus_print(*service);
+	puts(""); /* will also flush the output */
 	return 1;
 }
 
-static int control(char *a)
+static int control(const char *a)
 {
 	if (svstatus_get() <= 0) return -1;
 	if (svstatus[17] == *a) return 0;
-	if ((fd = open_write("supervise/control")) == -1) {
+	fd = open_write("supervise/control");
+	if (fd == -1) {
 		if (errno != ENODEV)
 			warn_cannot("open supervise/control");
 		else
@@ -245,15 +250,20 @@
 	if (opt & 4) usage();
 	if (!(action = *argv++)) usage();
 	--argc;
-	service = argv; services = argc;
+	service = argv;
+	services = argc;
 	if (!*service) usage();
 
-	taia_now(&tnow); tstart = tnow;
-	if ((curdir = open_read(".")) == -1)
+	taia_now(&tnow);
+	tstart = tnow;
+	curdir = open_read(".");
+	if (curdir == -1)
 		fatal_cannot("open current directory");
 
-	act = &control; acts = "s";
-	if (verbose) cbk = &check;
+	act = &control;
+	acts = "s";
+	if (verbose)
+		cbk = &check;
 	switch (*action) {
 	case 'x': case 'e':
 		acts = "x"; break;
@@ -289,7 +299,9 @@
 			cbk = &check;
 			break;
 		}
-		act = &status; cbk = 0; break;
+		act = &status;
+		cbk = NULL;
+		break;
 	case 'r':
 		if (!str_diff(action, "restart")) {
 			acts = "tcu";




More information about the busybox-cvs mailing list