Add assertions and shuffle code around for LLVM+Clang scan-build.
This commit is contained in:
parent
68c4dae6ef
commit
cf807eb83a
6
check.t
6
check.t
@ -1,4 +1,4 @@
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.569 2012/11/30 19:25:01 tg Exp $
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.570 2012/12/04 01:18:24 tg Exp $
|
||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
||||
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
||||
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||
@ -29,7 +29,7 @@
|
||||
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
|
||||
|
||||
expected-stdout:
|
||||
@(#)MIRBSD KSH R41 2012/11/30
|
||||
@(#)MIRBSD KSH R41 2012/12/03
|
||||
description:
|
||||
Check version of shell.
|
||||
stdin:
|
||||
@ -38,7 +38,7 @@ name: KSH_VERSION
|
||||
category: shell:legacy-no
|
||||
---
|
||||
expected-stdout:
|
||||
@(#)LEGACY KSH R41 2012/11/30
|
||||
@(#)LEGACY KSH R41 2012/12/03
|
||||
description:
|
||||
Check version of legacy shell.
|
||||
stdin:
|
||||
|
3
edit.c
3
edit.c
@ -28,7 +28,7 @@
|
||||
|
||||
#ifndef MKSH_NO_CMDLINE_EDITING
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.257 2012/12/01 01:36:19 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.258 2012/12/04 01:18:26 tg Exp $");
|
||||
|
||||
/*
|
||||
* in later versions we might use libtermcap for this, but since external
|
||||
@ -2273,6 +2273,7 @@ x_push(int nchars)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
mkssert(xcp != NULL);
|
||||
strndupx(cp, xcp, nchars, AEDIT);
|
||||
if (killstack[killsp])
|
||||
afree(killstack[killsp], AEDIT);
|
||||
|
18
exec.c
18
exec.c
@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.107 2012/11/30 20:19:11 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.108 2012/12/04 01:18:27 tg Exp $");
|
||||
|
||||
#ifndef MKSH_DEFAULT_EXECSHELL
|
||||
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
|
||||
@ -32,7 +32,7 @@ __RCSID("$MirOS: src/bin/mksh/exec.c,v 1.107 2012/11/30 20:19:11 tg Exp $");
|
||||
static int comexec(struct op *, struct tbl * volatile, const char **,
|
||||
int volatile, volatile int *);
|
||||
static void scriptexec(struct op *, const char **) MKSH_A_NORETURN;
|
||||
static int call_builtin(struct tbl *, const char **);
|
||||
static int call_builtin(struct tbl *, const char **, const char *);
|
||||
static int iosetup(struct ioword *, struct tbl *);
|
||||
static int herein(const char *, int, char **);
|
||||
static const char *do_selectargs(const char **, bool);
|
||||
@ -672,7 +672,7 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
|
||||
|
||||
/* shell built-in */
|
||||
case CSHELL:
|
||||
rv = call_builtin(tp, (const char **)ap);
|
||||
rv = call_builtin(tp, (const char **)ap, null);
|
||||
break;
|
||||
|
||||
/* function call */
|
||||
@ -933,9 +933,7 @@ shcomexec(const char **wp)
|
||||
struct tbl *tp;
|
||||
|
||||
tp = ktsearch(&builtins, *wp, hash(*wp));
|
||||
if (tp == NULL)
|
||||
internal_errorf("%s: %s", "shcomexec", *wp);
|
||||
return (call_builtin(tp, wp));
|
||||
return (call_builtin(tp, wp, "shcomexec"));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -984,6 +982,8 @@ define(const char *name, struct op *t)
|
||||
|
||||
while (/* CONSTCOND */ 1) {
|
||||
tp = findfunc(name, nhash, true);
|
||||
/* because findfunc:create=true */
|
||||
mkssert(tp != NULL);
|
||||
|
||||
if (tp->flag & ISSET)
|
||||
was_set = true;
|
||||
@ -1250,10 +1250,12 @@ search_path(const char *name, const char *lpath,
|
||||
}
|
||||
|
||||
static int
|
||||
call_builtin(struct tbl *tp, const char **wp)
|
||||
call_builtin(struct tbl *tp, const char **wp, const char *where)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if (!tp)
|
||||
internal_errorf("%s: %s", where, wp[0]);
|
||||
builtin_argv0 = wp[0];
|
||||
builtin_flag = tp->flag;
|
||||
shf_reopen(1, SHF_WR, shl_stdout);
|
||||
@ -1534,7 +1536,7 @@ do_selectargs(const char **ap, bool print_menu)
|
||||
if (print_menu || !*str_val(global("REPLY")))
|
||||
pr_menu(ap);
|
||||
shellf("%s", str_val(global("PS3")));
|
||||
if (call_builtin(findcom("read", FC_BI), read_args))
|
||||
if (call_builtin(findcom("read", FC_BI), read_args, Tselect))
|
||||
return (NULL);
|
||||
s = str_val(global("REPLY"));
|
||||
if (*s) {
|
||||
|
9
funcs.c
9
funcs.c
@ -38,7 +38,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.231 2012/12/01 01:36:23 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.232 2012/12/04 01:18:28 tg Exp $");
|
||||
|
||||
#if HAVE_KILLPG
|
||||
/*
|
||||
@ -852,8 +852,6 @@ c_typeset(const char **wp)
|
||||
} else if (wp[builtin_opt.optind]) {
|
||||
for (i = builtin_opt.optind; wp[i]; i++) {
|
||||
varsearch(e->loc, &vp, wp[i], hash(wp[i]));
|
||||
if (!vp)
|
||||
continue;
|
||||
c_typeset_vardump(vp, flag, thing, pflag, istset);
|
||||
}
|
||||
} else
|
||||
@ -883,6 +881,9 @@ c_typeset_vardump(struct tbl *vp, uint32_t flag, int thing, bool pflag,
|
||||
int any_set = 0;
|
||||
char *s;
|
||||
|
||||
if (!vp)
|
||||
return;
|
||||
|
||||
/*
|
||||
* See if the parameter is set (for arrays, if any
|
||||
* element is set).
|
||||
@ -2765,6 +2766,8 @@ c_test(const char **wp)
|
||||
|
||||
for (argc = 0; wp[argc]; argc++)
|
||||
;
|
||||
mkssert(argc > 0);
|
||||
mkssert(wp[0] != NULL);
|
||||
|
||||
if (strcmp(wp[0], "[") == 0) {
|
||||
if (strcmp(wp[--argc], "]") != 0) {
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <sys/file.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.128 2012/11/30 19:02:07 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.129 2012/12/04 01:18:30 tg Exp $");
|
||||
|
||||
Trap sigtraps[NSIG + 1];
|
||||
static struct sigaction Sigact_ign;
|
||||
@ -634,6 +634,7 @@ histsave(int *lnp, const char *cmd, bool dowrite MKSH_A_UNUSED, bool ignoredups)
|
||||
char **hp;
|
||||
char *c, *cp;
|
||||
|
||||
mkssert(cmd != NULL);
|
||||
strdupx(c, cmd, APERM);
|
||||
if ((cp = strchr(c, '\n')) != NULL)
|
||||
*cp = '\0';
|
||||
|
18
jobs.c
18
jobs.c
@ -22,7 +22,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.91 2012/11/30 19:25:03 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.92 2012/12/04 01:18:31 tg Exp $");
|
||||
|
||||
#if HAVE_KILLPG
|
||||
#define mksh_killpg killpg
|
||||
@ -1722,10 +1722,13 @@ remove_job(Job *j, const char *where)
|
||||
Proc *p, *tmp;
|
||||
Job **prev, *curr;
|
||||
|
||||
mkssert(j != NULL);
|
||||
prev = &job_list;
|
||||
curr = *prev;
|
||||
for (; curr != NULL && curr != j; prev = &curr->next, curr = *prev)
|
||||
;
|
||||
curr = job_list;
|
||||
while (curr && curr != j) {
|
||||
prev = &curr->next;
|
||||
curr = *prev;
|
||||
}
|
||||
if (curr != j) {
|
||||
internal_warningf("remove_job: job %s (%s)", "not found", where);
|
||||
return;
|
||||
@ -1762,11 +1765,14 @@ put_job(Job *j, int where)
|
||||
{
|
||||
Job **prev, *curr;
|
||||
|
||||
mkssert(j != NULL);
|
||||
/* Remove job from list (if there) */
|
||||
prev = &job_list;
|
||||
curr = job_list;
|
||||
for (; curr && curr != j; prev = &curr->next, curr = *prev)
|
||||
;
|
||||
while (curr && curr != j) {
|
||||
prev = &curr->next;
|
||||
curr = *prev;
|
||||
}
|
||||
if (curr == j)
|
||||
*prev = curr->next;
|
||||
|
||||
|
3
misc.c
3
misc.c
@ -30,7 +30,7 @@
|
||||
#include <grp.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.202 2012/12/04 01:12:11 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.203 2012/12/04 01:18:31 tg Exp $");
|
||||
|
||||
#define KSH_CHVT_FLAG
|
||||
#ifdef MKSH_SMALL
|
||||
@ -445,6 +445,7 @@ parse_args(const char **argv,
|
||||
if (arrayset) {
|
||||
const char *ccp = NULL;
|
||||
|
||||
mkssert(array != NULL);
|
||||
if (*array)
|
||||
ccp = skip_varname(array, false);
|
||||
if (!ccp || !(!ccp[0] || (ccp[0] == '+' && !ccp[1]))) {
|
||||
|
10
sh.h
10
sh.h
@ -152,9 +152,9 @@
|
||||
#endif
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.611 2012/12/01 01:36:28 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.612 2012/12/04 01:18:32 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R41 2012/11/30"
|
||||
#define MKSH_VERSION "R41 2012/12/03"
|
||||
|
||||
/* arithmetic types: C implementation */
|
||||
#if !HAVE_CAN_INTTYPES
|
||||
@ -472,12 +472,16 @@ char *ucstrstr(char *, const char *);
|
||||
})
|
||||
#define vstrchr(s,c) (cstrchr((s), (c)) != NULL)
|
||||
#define vstrstr(b,l) (cstrstr((b), (l)) != NULL)
|
||||
#define mkssert(e) ((e) ? (void)0 : exit(255))
|
||||
#else /* !DEBUG, !gcc */
|
||||
#define cstrchr(s,c) ((const char *)strchr((s), (c)))
|
||||
#define cstrstr(s,c) ((const char *)strstr((s), (c)))
|
||||
#define vstrchr(s,c) (strchr((s), (c)) != NULL)
|
||||
#define vstrstr(b,l) (strstr((b), (l)) != NULL)
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG) || defined(__COVERITY__)
|
||||
#define mkssert(e) ((e) ? (void)0 : exit(255))
|
||||
#else
|
||||
#define mkssert(e) ((void)0)
|
||||
#endif
|
||||
|
||||
|
3
var.c
3
var.c
@ -27,7 +27,7 @@
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.163 2012/12/04 01:11:17 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.164 2012/12/04 01:18:34 tg Exp $");
|
||||
|
||||
/*-
|
||||
* Variables
|
||||
@ -299,6 +299,7 @@ local(const char *n, bool copy)
|
||||
|
||||
/* check to see if this is an array */
|
||||
n = array_index_calc(n, &array, &val);
|
||||
mkssert(n != NULL);
|
||||
h = hash(n);
|
||||
if (!ksh_isalphx(*n)) {
|
||||
vp = &vtemp;
|
||||
|
Loading…
x
Reference in New Issue
Block a user