From 566f882d83877c88ad2aad43fa7d57b2f83cd833 Mon Sep 17 00:00:00 2001 From: tg Date: Thu, 28 Jan 2010 20:26:52 +0000 Subject: [PATCH] =?UTF-8?q?Add=20some=20assertions=20=E2=80=93=20mkssert()?= =?UTF-8?q?=20=E2=80=93=20for=20things=20clang=E2=80=99s=20scan-build=20ca?= =?UTF-8?q?n=E2=80=99t=20see?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sh.h | 5 +++-- var.c | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sh.h b/sh.h index 4c95582..daceb90 100644 --- a/sh.h +++ b/sh.h @@ -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); diff --git a/var.c b/var.c index 1724e18..3a8052a 100644 --- a/var.c +++ b/var.c @@ -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",