Add some assertions – mkssert() – for things clang’s scan-build can’t see

This commit is contained in:
tg 2010-01-28 20:26:52 +00:00
parent 9ed7b897a9
commit 566f882d83
2 changed files with 6 additions and 3 deletions

5
sh.h
View File

@ -150,7 +150,7 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.377 2010/01/28 15:13:25 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.378 2010/01/28 20:26:51 tg Exp $");
#endif
#define MKSH_VERSION "R39 2010/01/08"
@ -1624,7 +1624,8 @@ char *str_val(struct tbl *);
int setstr(struct tbl *, const char *, int);
struct tbl *setint_v(struct tbl *, struct tbl *, bool);
void setint(struct tbl *, mksh_ari_t);
struct tbl *typeset(const char *, Tflag, Tflag, int, int);
struct tbl *typeset(const char *, Tflag, Tflag, int, int)
MKSH_A_NONNULL((nonnull (1)));
void unset(struct tbl *, int);
const char *skip_varname(const char *, int);
const char *skip_wdvarname(const char *, int);

4
var.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.103 2010/01/25 14:38:04 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.104 2010/01/28 20:26:52 tg Exp $");
/*
* Variables
@ -680,6 +680,8 @@ typeset(const char *var, Tflag set, Tflag clr, int field, int base)
val = skip_varname(var, false);
if (val == var)
return (NULL);
mkssert(var != NULL);
mkssert(*var != 0);
if (*val == '[') {
if (set_refflag)
errorf("%s: reference variable cannot be an array",