sh: Fix more compiler warnings.

This commit is contained in:
Jilles Tjoelker 2015-03-01 22:32:23 +00:00
parent 2c8f60acb3
commit 22afca9b67
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=279508
6 changed files with 20 additions and 13 deletions

View File

@ -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;

View File

@ -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 *);

View File

@ -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

View File

@ -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;

View File

@ -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 @@ getopts(char *optstr, char *optvar, char **optfirst, char ***optnext,
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 @@ getopts(char *optstr, char *optvar, char **optfirst, char ***optnext,
if (optstr[0] == ':') {
s[0] = c;
s[1] = '\0';
optarg = s;
newoptarg = s;
c = ':';
}
else {
@ -519,7 +519,7 @@ getopts(char *optstr, char *optvar, char **optfirst, char ***optnext,
if (p == **optnext)
(*optnext)++;
optarg = p;
newoptarg = p;
p = NULL;
}
@ -527,8 +527,8 @@ getopts(char *optstr, char *optvar, char **optfirst, char ***optnext,
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");

View File

@ -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.