gcc 6.2 warnings (stupid uninitialised that wasn't, plus FALLTHROUGH fixes)

This commit is contained in:
tg 2016-11-11 23:48:30 +00:00
parent 7b4bee7e58
commit 0ba220d2c4
3 changed files with 20 additions and 17 deletions

10
edit.c
View File

@ -28,7 +28,7 @@
#ifndef MKSH_NO_CMDLINE_EDITING #ifndef MKSH_NO_CMDLINE_EDITING
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.311 2016/11/11 23:31:33 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.312 2016/11/11 23:48:28 tg Exp $");
/* /*
* in later versions we might use libtermcap for this, but since external * in later versions we might use libtermcap for this, but since external
@ -4165,6 +4165,8 @@ vi_cmd(int argcnt, const char *cmd)
case 'Y': case 'Y':
cmd = "y$"; cmd = "y$";
/* ahhhhhh... */ /* ahhhhhh... */
/* FALLTHROUGH */
case 'c': case 'c':
case 'd': case 'd':
case 'y': case 'y':
@ -4401,6 +4403,8 @@ vi_cmd(int argcnt, const char *cmd)
if (hnum == hlast) if (hnum == hlast)
hnum = -1; hnum = -1;
/* ahhh */ /* ahhh */
/* FALLTHROUGH */
case '/': case '/':
c3 = 1; c3 = 1;
srchlen = 0; srchlen = 0;
@ -4539,6 +4543,7 @@ vi_cmd(int argcnt, const char *cmd)
case CTRL('['): case CTRL('['):
if (!Flag(FVIESCCOMPLETE)) if (!Flag(FVIESCCOMPLETE))
return (-1); return (-1);
/* FALLTHROUGH */
/* AT&T ksh */ /* AT&T ksh */
case '\\': case '\\':
/* Nonstandard vi/ksh */ /* Nonstandard vi/ksh */
@ -4611,8 +4616,7 @@ domove(int argcnt, const char *cmd, int sub)
case 'T': case 'T':
fsavecmd = *cmd; fsavecmd = *cmd;
fsavech = cmd[1]; fsavech = cmd[1];
/* drop through */ /* FALLTHROUGH */
case ',': case ',':
case ';': case ';':
if (fsavecmd == ' ') if (fsavecmd == ' ')

23
funcs.c
View File

@ -38,7 +38,7 @@
#endif #endif
#endif #endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.318 2016/11/11 22:17:08 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.319 2016/11/11 23:48:29 tg Exp $");
#if HAVE_KILLPG #if HAVE_KILLPG
/* /*
@ -284,8 +284,9 @@ c_print(const char **wp)
const char *s; const char *s;
char *xp; char *xp;
XString xs; XString xs;
XPtrV words;
struct { struct {
/* storage for columnisation */
XPtrV words;
/* temporary storage for a wide character */ /* temporary storage for a wide character */
mksh_ari_t wc; mksh_ari_t wc;
/* output file descriptor (if any) */ /* output file descriptor (if any) */
@ -313,14 +314,12 @@ c_print(const char **wp)
bool copipe; bool copipe;
} po; } po;
memset(&po, 0, sizeof(po));
po.fd = 1; po.fd = 1;
po.ws = ' '; po.ws = ' ';
po.ls = '\n'; po.ls = '\n';
po.nl = true; po.nl = true;
po.exp = true; po.exp = true;
po.col = false;
po.hist = false;
po.chars = false;
if (wp[0][0] == 'e') { if (wp[0][0] == 'e') {
/* "echo" builtin */ /* "echo" builtin */
@ -455,7 +454,7 @@ c_print(const char **wp)
if (*wp == NULL) if (*wp == NULL)
return (0); return (0);
XPinit(words, 16); XPinit(po.words, 16);
} }
Xinit(xs, xp, 128, ATEMP); Xinit(xs, xp, 128, ATEMP);
@ -517,7 +516,7 @@ c_print(const char **wp)
} }
if (po.col) { if (po.col) {
Xput(xs, xp, '\0'); Xput(xs, xp, '\0');
XPput(words, Xclose(xs, xp)); XPput(po.words, Xclose(xs, xp));
Xinit(xs, xp, 128, ATEMP); Xinit(xs, xp, 128, ATEMP);
} }
if (*wp != NULL) { if (*wp != NULL) {
@ -526,17 +525,17 @@ c_print(const char **wp)
goto print_read_arg; goto print_read_arg;
} }
if (po.col) { if (po.col) {
size_t w = XPsize(words); size_t w = XPsize(po.words);
struct columnise_opts co; struct columnise_opts co;
XPput(words, NULL); XPput(po.words, NULL);
co.shf = shf_sopen(NULL, 128, SHF_WR | SHF_DYNAMIC, NULL); co.shf = shf_sopen(NULL, 128, SHF_WR | SHF_DYNAMIC, NULL);
co.linesep = po.ls; co.linesep = po.ls;
co.prefcol = co.do_last = false; co.prefcol = co.do_last = false;
pr_list(&co, (char **)XPptrv(words)); pr_list(&co, (char **)XPptrv(po.words));
while (w--) while (w--)
afree(XPptrv(words)[w], ATEMP); afree(XPptrv(po.words)[w], ATEMP);
XPfree(words); XPfree(po.words);
w = co.shf->wp - co.shf->buf; w = co.shf->wp - co.shf->buf;
XcheckN(xs, xp, w); XcheckN(xs, xp, w);
memcpy(xp, co.shf->buf, w); memcpy(xp, co.shf->buf, w);

4
main.c
View File

@ -34,7 +34,7 @@
#include <locale.h> #include <locale.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.321 2016/11/11 23:31:35 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/main.c,v 1.322 2016/11/11 23:48:30 tg Exp $");
extern char **environ; extern char **environ;
@ -566,8 +566,8 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
#endif #endif
if (!isuc(ccp)) if (!isuc(ccp))
ccp = null; ccp = null;
/* FALLTHROUGH */
#endif #endif
/* FALLTHROUGH */
/* auto-detect from environment */ /* auto-detect from environment */
case 3: case 3: