summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2015-03-01 22:32:23 +0000
committerjilles <jilles@FreeBSD.org>2015-03-01 22:32:23 +0000
commitc2c73916400917344cd96df888f35b4002e6697c (patch)
tree8d52c70a9487144dae3e07fc3a64ce8c03ad918d
parent23119781865a66c0e31db74d9d6780bbaf99d12a (diff)
downloadFreeBSD-src-c2c73916400917344cd96df888f35b4002e6697c.zip
FreeBSD-src-c2c73916400917344cd96df888f35b4002e6697c.tar.gz
sh: Fix more compiler warnings.
-rw-r--r--bin/sh/eval.c2
-rw-r--r--bin/sh/eval.h2
-rw-r--r--bin/sh/histedit.c6
-rw-r--r--bin/sh/jobs.c2
-rw-r--r--bin/sh/options.c12
-rw-r--r--bin/sh/var.c9
6 files changed, 20 insertions, 13 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index 347824a..51206d9 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -149,7 +149,7 @@ evalcmd(int argc, char **argv)
*/
void
-evalstring(char *s, int flags)
+evalstring(const char *s, int flags)
{
union node *n;
struct stackmark smark;
diff --git a/bin/sh/eval.h b/bin/sh/eval.h
index 4129757..d4092be 100644
--- a/bin/sh/eval.h
+++ b/bin/sh/eval.h
@@ -53,7 +53,7 @@ void reseteval(void);
#define EV_TESTED 02 /* exit status is checked; ignore -e flag */
#define EV_BACKCMD 04 /* command executing within back quotes */
-void evalstring(char *, int);
+void evalstring(const char *, int);
union node; /* BLETCH for ansi C */
void evaltree(union node *, int);
void evalbackcmd(union node *, struct backcmd *);
diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c
index c65d1c7..7295c3f 100644
--- a/bin/sh/histedit.c
+++ b/bin/sh/histedit.c
@@ -338,8 +338,8 @@ histcmd(int argc, char **argv __unused)
out1fmt("%5d ", he.num);
out1str(he.str);
} else {
- char *s = pat ?
- fc_replace(he.str, pat, repl) : (char *)he.str;
+ const char *s = pat ?
+ fc_replace(he.str, pat, repl) : he.str;
if (sflg) {
if (displayhist) {
@@ -477,7 +477,7 @@ bindcmd(int argc, char **argv)
if (el == NULL)
error("line editing is disabled");
- return (el_parse(el, argc, (const char **)argv));
+ return (el_parse(el, argc, __DECONST(const char **, argv)));
}
#else
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c
index b1bfa09..753cf7b 100644
--- a/bin/sh/jobs.c
+++ b/bin/sh/jobs.c
@@ -232,7 +232,7 @@ fgcmd(int argc __unused, char **argv __unused)
int
-bgcmd(int argc, char **argv)
+bgcmd(int argc __unused, char **argv __unused)
{
struct job *jp;
diff --git a/bin/sh/options.c b/bin/sh/options.c
index 860cf6c..2d0ddce 100644
--- a/bin/sh/options.c
+++ b/bin/sh/options.c
@@ -465,7 +465,7 @@ getopts(char *optstr, char *optvar, char **optfirst, char ***optnext,
int ind = 0;
int err = 0;
char s[10];
- const char *optarg = NULL;
+ const char *newoptarg = NULL;
if ((p = *optptr) == NULL || *p == '\0') {
/* Current word is done, advance */
@@ -491,7 +491,7 @@ atend:
if (optstr[0] == ':') {
s[0] = c;
s[1] = '\0';
- optarg = s;
+ newoptarg = s;
}
else
out2fmt_flush("Illegal option -%c\n", c);
@@ -507,7 +507,7 @@ atend:
if (optstr[0] == ':') {
s[0] = c;
s[1] = '\0';
- optarg = s;
+ newoptarg = s;
c = ':';
}
else {
@@ -519,7 +519,7 @@ atend:
if (p == **optnext)
(*optnext)++;
- optarg = p;
+ newoptarg = p;
p = NULL;
}
@@ -527,8 +527,8 @@ out:
if (*optnext != NULL)
ind = *optnext - optfirst + 1;
*optptr = p;
- if (optarg != NULL)
- err |= setvarsafe("OPTARG", optarg, 0);
+ if (newoptarg != NULL)
+ err |= setvarsafe("OPTARG", newoptarg, 0);
else {
INTOFF;
err |= unsetvar("OPTARG");
diff --git a/bin/sh/var.c b/bin/sh/var.c
index def1e0c..87d7b80 100644
--- a/bin/sh/var.c
+++ b/bin/sh/var.c
@@ -141,6 +141,7 @@ static const int locale_categories[7] = {
static int varequal(const char *, const char *);
static struct var *find_var(const char *, struct var ***, int *);
static int localevar(const char *);
+static void setvareq_const(const char *s, int flags);
extern char **environ;
@@ -183,7 +184,7 @@ initvar(void)
setvareq(*envp, VEXPORT|VTEXTFIXED);
}
}
- setvareq("OPTIND=1", VTEXTFIXED);
+ setvareq_const("OPTIND=1", 0);
}
/*
@@ -389,6 +390,12 @@ setvareq(char *s, int flags)
}
+static void
+setvareq_const(const char *s, int flags)
+{
+ setvareq(__DECONST(char *, s), flags | VTEXTFIXED);
+}
+
/*
* Process a linked list of variable assignments.
OpenPOWER on IntegriCloud