Fix -DNEDUG builds

- assert() is macro which is defined as empty, while panic is always
   present. I added an explicit abort() after the macro to make sure the
   function never returns in case of wrong flags.

 - Fixed gcc build with -NDEBUG, -Os for ARM.
   * A few 'may be used uninitialized' messages
   * A few new missing support library functions where added in libminc.

Change-Id: I69fcda2cd3888390b7ddeff4c0cd849105ce86ff
This commit is contained in:
Lionel Sambuc 2014-09-02 15:22:15 +02:00
parent da9af514b5
commit 20a91f7755
6 changed files with 27 additions and 3 deletions

View File

@ -715,6 +715,11 @@ int scanopt (svoid, arg, optindex)
struct _aux *auxp;
int is_short;
int opt_offset = -1;
#if defined(__minix)
/* triggers a 'may be used uninitialized', when compiled with gcc,
* asserts off, and -Os. */
is_short = 0;
#endif /* defined(__minix) */
s = (struct _scanopt_t *) svoid;

View File

@ -4,6 +4,7 @@
#include <limits.h>
#include <dirent.h>
#include <assert.h>
#include <stdlib.h> /* for abort() */
#include <sys/types.h>
#include <minix/const.h>
#include <minix/type.h> /* for unshort :-( */
@ -56,5 +57,8 @@ uint8_t fs_mode_to_type(mode_t mode)
else if(S_ISSOCK(mode)) return DT_SOCK;
assert(0 && "unknown type");
/* assert()s are removed on NDEBUG builds. */
abort();
}

View File

@ -127,7 +127,8 @@ CPPFLAGS.sha2.c+= -D_STANDALONE
CPPFLAGS.sha2.c+= -I${NETBSDSRCDIR}/sys
.for f in \
divdi3.o moddi3.o udivdi3.o umoddi3.o qdivrem.o
ashrdi3.o divdi3.o lshldi3.o lshrdi3.o moddi3.o \
udivdi3.o umoddi3.o qdivrem.o
${f} ${f:C/\.o/.bc/}: ${LIBCOMMONCDIR}/quad/${f:C/\.o/.c/}
OBJS+= ${f}
CLEANFILES+= ${f}

View File

@ -338,6 +338,11 @@ Targ_FindNode(const char *name, int flags)
Boolean isNew; /* Set TRUE if Hash_CreateEntry had to create */
/* an entry for the node */
#if defined(__minix)
/* triggers a 'may be used uninitialized', when compiled with gcc,
* asserts off, and -Os. */
he = NULL;
#endif /* defined(__minix) */
if (!(flags & (TARG_CREATE | TARG_NOHASH))) {
he = Hash_FindEntry(&targets, name);
if (he == NULL)

View File

@ -230,9 +230,13 @@ main(int argc, char **argv)
const char *prefix = NULL;
const char *suffixes = NULL, *s;
suff_list_t *suff_list = NULL, *sl;
#ifdef __minix
#if defined(__minix)
size_t nr;
#endif
/* triggers a 'may be used uninitialized', when compiled with gcc,
* asserts off, and -Os. */
slen = 0;
#endif /* defined(__minix) */
suf = NULL; /* XXXGCC -Wuninitialized [sun2] */
sl = NULL; /* XXXGCC -Wuninitialized [sun2] */

View File

@ -166,6 +166,11 @@ process(FILE *fp)
char buff[4 * MB_LEN_MAX + 1]; /* max encoding length for one char */
int mbilen, cerr = 0, raerr = 0;
#if defined(__minix)
/* triggers a 'may be used uninitialized', when compiled with gcc,
* asserts off, and -Os. */
rachar = 0;
#endif /* defined(__minix) */
/*
* The input stream is considered to be multibyte characters.
* The input loop will read this data inputing one character,