preparatory patch for -Wwrite-strings #4
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c
index a67803f..e2e75fc 100644
--- a/networking/libiproute/iptunnel.c
+++ b/networking/libiproute/iptunnel.c
@@ -85,7 +85,7 @@
-static int do_get_ioctl(char *basedev, struct ip_tunnel_parm *p)
+static int do_get_ioctl(const char *basedev, struct ip_tunnel_parm *p)
{
struct ifreq ifr;
int fd;
@@ -102,7 +102,7 @@
return err;
}
-static int do_add_ioctl(int cmd, char *basedev, struct ip_tunnel_parm *p)
+static int do_add_ioctl(int cmd, const char *basedev, struct ip_tunnel_parm *p)
{
struct ifreq ifr;
int fd;
@@ -123,7 +123,7 @@
return err;
}
-static int do_del_ioctl(char *basedev, struct ip_tunnel_parm *p)
+static int do_del_ioctl(const char *basedev, struct ip_tunnel_parm *p)
{
struct ifreq ifr;
int fd;
diff --git a/networking/libiproute/rt_names.c b/networking/libiproute/rt_names.c
index 686326f..797c83b 100644
--- a/networking/libiproute/rt_names.c
+++ b/networking/libiproute/rt_names.c
@@ -13,7 +13,7 @@
#include "libbb.h"
#include "rt_names.h"
-static void rtnl_tab_initialize(char *file, const char **tab, int size)
+static void rtnl_tab_initialize(const char *file, const char **tab, int size)
{
char buf[512];
FILE *fp;
@@ -30,10 +30,11 @@
p++;
if (*p == '#' || *p == '\n' || *p == 0)
continue;
- if (sscanf(p, "0x%x %s\n", &id, namebuf) != 2 &&
- sscanf(p, "0x%x %s #", &id, namebuf) != 2 &&
- sscanf(p, "%d %s\n", &id, namebuf) != 2 &&
- sscanf(p, "%d %s #", &id, namebuf) != 2) {
+ if (sscanf(p, "0x%x %s\n", &id, namebuf) != 2
+ && sscanf(p, "0x%x %s #", &id, namebuf) != 2
+ && sscanf(p, "%d %s\n", &id, namebuf) != 2
+ && sscanf(p, "%d %s #", &id, namebuf) != 2
+ ) {
bb_error_msg("database %s is corrupted at %s",
file, p);
return;
diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c
index 5e06656..591c893 100644
--- a/networking/libiproute/utils.c
+++ b/networking/libiproute/utils.c
@@ -178,7 +178,7 @@
slash = strchr(arg, '/');
if (slash)
- *slash = 0;
+ *slash = '\0';
err = get_addr_1(dst, arg, family);
if (err == 0) {
switch (dst->family) {
@@ -237,26 +237,22 @@
void incomplete_command(void)
{
- bb_error_msg("command line is not complete, try option \"help\"");
- exit(-1);
+ bb_error_msg_and_die("command line is not complete, try option \"help\"");
}
-void invarg(const char * const arg, const char * const opt)
+void invarg(const char *arg, const char *opt)
{
- bb_error_msg(bb_msg_invalid_arg, arg, opt);
- exit(-1);
+ bb_error_msg_and_die(bb_msg_invalid_arg, arg, opt);
}
-void duparg(char *key, char *arg)
+void duparg(const char *key, const char *arg)
{
- bb_error_msg("duplicate \"%s\": \"%s\" is the second value", key, arg);
- exit(-1);
+ bb_error_msg_and_die("duplicate \"%s\": \"%s\" is the second value", key, arg);
}
-void duparg2(char *key, char *arg)
+void duparg2(const char *key, const char *arg)
{
- bb_error_msg("either \"%s\" is duplicate, or \"%s\" is garbage", key, arg);
- exit(-1);
+ bb_error_msg_and_die("either \"%s\" is duplicate, or \"%s\" is garbage", key, arg);
}
int matches(const char *cmd, const char *pattern)
diff --git a/networking/libiproute/utils.h b/networking/libiproute/utils.h
index 5af8ba7..ebf2af1 100644
--- a/networking/libiproute/utils.h
+++ b/networking/libiproute/utils.h
@@ -75,9 +75,9 @@
extern const char *format_host(int af, int len, void *addr, char *buf, int buflen);
extern const char *rt_addr_n2a(int af, int len, void *addr, char *buf, int buflen);
-void invarg(const char * const, const char * const) ATTRIBUTE_NORETURN;
-void duparg(char *, char *) ATTRIBUTE_NORETURN;
-void duparg2(char *, char *) ATTRIBUTE_NORETURN;
+void invarg(const char *, const char *) ATTRIBUTE_NORETURN;
+void duparg(const char *, const char *) ATTRIBUTE_NORETURN;
+void duparg2(const char *, const char *) ATTRIBUTE_NORETURN;
int matches(const char *arg, const char *pattern);
extern int inet_addr_match(inet_prefix *a, inet_prefix *b, int bits);