remove *all* nonnull assertions and other workarounds for clang scan-build

this beast evolved in the last 2½ years, and we’ve had trouble with
some of them earlier
This commit is contained in:
tg 2012-12-01 01:36:30 +00:00
parent f6728353bd
commit b868c517b7
5 changed files with 9 additions and 35 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.593 2012/11/30 22:17:32 tg Exp $'
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.594 2012/12/01 01:36:16 tg Exp $'
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012
@ -1294,20 +1294,6 @@ ac_test attribute_format '' 'for __attribute__((__format__))' <<-'EOF'
int main(int ac, char **av) { return (fprintf(stderr, "%s%d", *av, ac)); }
#endif
EOF
ac_test attribute_nonnull '' 'for __attribute__((__nonnull__))' <<-'EOF'
#if defined(__TenDRA__) || (defined(__GNUC__) && (__GNUC__ < 2))
/* force a failure: TenDRA and gcc 1.42 have false positive here */
int main(void) { return (thiswillneverbedefinedIhope()); }
#else
int foo(char *s1, char *s2) __attribute__((__nonnull__));
int bar(char *s1, char *s2) __attribute__((__nonnull__ (1, 2)));
int baz(char *s) __attribute__((__nonnull__ (1)));
int foo(char *s1, char *s2) { return (bar(s2, s1)); }
int bar(char *s1, char *s2) { return (baz(s1) - baz(s2)); }
int baz(char *s) { return (*s); }
int main(int ac, char **av) { return (ac == foo(av[0], av[ac-1])); }
#endif
EOF
ac_test attribute_noreturn '' 'for __attribute__((__noreturn__))' <<-'EOF'
#if defined(__TenDRA__) || (defined(__GNUC__) && (__GNUC__ < 2))
/* force a failure: TenDRA and gcc 1.42 have false positive here */
@ -1495,7 +1481,7 @@ else
#define EXTERN
#define MKSH_INCLUDES_ONLY
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.593 2012/11/30 22:17:32 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.594 2012/12/01 01:36:16 tg Exp $");
int main(void) { printf("Hello, World!\n"); return (0); }
EOF
case $cm in

8
edit.c
View File

@ -28,7 +28,7 @@
#ifndef MKSH_NO_CMDLINE_EDITING
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.256 2012/11/26 22:39:14 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.257 2012/12/01 01:36:19 tg Exp $");
/*
* in later versions we might use libtermcap for this, but since external
@ -990,8 +990,7 @@ static int x_search_dir(int);
static int x_match(char *, char *);
static void x_redraw(int);
static void x_push(int);
static char *x_mapin(const char *, Area *)
MKSH_A_NONNULL((__nonnull__ (1)));
static char *x_mapin(const char *, Area *);
static char *x_mapout(int);
static void x_mapout2(int, char **);
static void x_print(int, int);
@ -2395,9 +2394,6 @@ x_mapin(const char *cp, Area *ap)
{
char *news, *op;
/* for clang's static analyser, the nonnull attribute isn't enough */
mkssert(cp != NULL);
strdupx(news, cp, ap);
op = news;
while (*cp) {

View File

@ -38,7 +38,7 @@
#endif
#endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.230 2012/10/30 20:13:18 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.231 2012/12/01 01:36:23 tg Exp $");
#if HAVE_KILLPG
/*
@ -220,8 +220,7 @@ static const char *ptest_getopnd(Test_env *, Test_op, bool);
static void ptest_error(Test_env *, int, const char *);
static char *kill_fmt_entry(char *, size_t, unsigned int, const void *);
static void p_time(struct shf *, bool, long, int, int,
const char *, const char *)
MKSH_A_NONNULL((__nonnull__ (6, 7)));
const char *, const char *);
int
c_pwd(const char **wp)

10
sh.h
View File

@ -105,11 +105,6 @@
#else
#define MKSH_A_FORMAT(x,y,z) /* nothing */
#endif
#if HAVE_ATTRIBUTE_NONNULL
#define MKSH_A_NONNULL(a) __attribute__(a)
#else
#define MKSH_A_NONNULL(a) /* nothing */
#endif
#if HAVE_ATTRIBUTE_NORETURN
#define MKSH_A_NORETURN __attribute__((__noreturn__))
#else
@ -157,7 +152,7 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.610 2012/11/30 20:49:18 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.611 2012/12/01 01:36:28 tg Exp $");
#endif
#define MKSH_VERSION "R41 2012/11/30"
@ -1966,8 +1961,7 @@ int setstr(struct tbl *, const char *, int);
struct tbl *setint_v(struct tbl *, struct tbl *, bool);
void setint(struct tbl *, mksh_ari_t);
void setint_n(struct tbl *, mksh_ari_t, int);
struct tbl *typeset(const char *, uint32_t, uint32_t, int, int)
MKSH_A_NONNULL((__nonnull__ (1)));
struct tbl *typeset(const char *, uint32_t, uint32_t, int, int);
void unset(struct tbl *, int);
const char *skip_varname(const char *, int);
const char *skip_wdvarname(const char *, bool);

3
var.c
View File

@ -27,7 +27,7 @@
#include <sys/sysctl.h>
#endif
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.161 2012/11/30 19:25:08 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.162 2012/12/01 01:36:30 tg Exp $");
/*-
* Variables
@ -704,7 +704,6 @@ typeset(const char *var, uint32_t set, uint32_t clr, int field, int base)
val = skip_varname(var, false);
if (val == var)
return (NULL);
mkssert(var != NULL);
if (*val == '[') {
if (set_refflag != SRF_NOP)
errorf("%s: %s", var,