handle warnings, hopefully w/o introducing real bugs

This commit is contained in:
psyc://loupsycedyglgamf.onion/~lynX 2016-08-10 15:44:52 +00:00
parent 710608d251
commit 27f21a3bf0
13 changed files with 52 additions and 38 deletions

View File

@ -1248,7 +1248,7 @@ int main(void) {
if test $lp_cv_has_gnunet = yes; then if test $lp_cv_has_gnunet = yes; then
AC_DEFINE(HAS_GNUNET, 1, [Does the machine offer GNUnet?]) AC_DEFINE(HAS_GNUNET, 1, [Does the machine offer GNUnet?])
PKGLIBS="$PKGLIBS $LIBS" PKGLIBS="$PKGLIBS $LIBS"
echo ">>> Congrats! GNUnet CADET is available." echo " >>> Congrats! GNUnet CADET is available."
else else
echo "GNUnet CADET not available on this system yet." echo "GNUnet CADET not available on this system yet."
fi fi
@ -1283,7 +1283,7 @@ int main(void) {
if test $lp_cv_has_psyc = yes; then if test $lp_cv_has_psyc = yes; then
AC_DEFINE(HAS_PSYC, 1, [Does the machine offer libpsyc?]) AC_DEFINE(HAS_PSYC, 1, [Does the machine offer libpsyc?])
PKGLIBS="$PKGLIBS $LIBS" PKGLIBS="$PKGLIBS $LIBS"
echo ">>> Congrats! libpsyc is available on this system." echo " >>> Congrats! libpsyc is available on this system."
else else
echo "libpsyc not available on this system yet." echo "libpsyc not available on this system yet."
fi fi
@ -2563,7 +2563,13 @@ EOF
AC_MSG_CHECKING(warning CFLAGS) AC_MSG_CHECKING(warning CFLAGS)
changequote(,)dnl changequote(,)dnl
CFLAGS= CFLAGS=
for TESTFLAG in -Wall -Wparentheses -Wshadow; do
# according to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509
# excess complaints by -Wwarn_unused_result are considered a feature,
# not a bug. i think, casting to (void) must not be ignored. so we
# are forced to turn off that gcc warning. --lynX 2016
#
for TESTFLAG in -Wall -Wno-unused-result -Wparentheses -Wshadow; do
if eval $tcomp; then if eval $tcomp; then
# The option is recognized, but if it generates warnings on the # The option is recognized, but if it generates warnings on the
# above correct program, we still can't use it. So check for that. # above correct program, we still can't use it. So check for that.

View File

@ -3270,7 +3270,6 @@ compile_value (svalue_t *value, int opt_flags)
mp_int start, offset; mp_int start, offset;
int flags, i; int flags, i;
int void_given;
if (block_size < 2 && block_size > 6) if (block_size < 2 && block_size > 6)
lambda_error("Wrong number of arguments to #'catch\n"); lambda_error("Wrong number of arguments to #'catch\n");
@ -3313,7 +3312,7 @@ compile_value (svalue_t *value, int opt_flags)
STORE_UINT8(current.codep, 0); STORE_UINT8(current.codep, 0);
start = current.code_max - current.code_left; start = current.code_max - current.code_left;
void_given = compile_value(++argp, 0); (void) compile_value(++argp, 0);
if (current.code_left < 1) if (current.code_left < 1)
realloc_code(); realloc_code();

View File

@ -571,7 +571,7 @@ v_sha1 (svalue_t *sp, int num_arg)
{ {
SHA1Context context; SHA1Context context;
string_t *s_digest; string_t *s_digest;
unsigned char *digest, d[SHA1HashSize + 1]; unsigned char *digest, d[SHA1HashSize + 2];
int i; int i;
p_int iterations; p_int iterations;
@ -1871,7 +1871,9 @@ e_terminal_colour ( string_t * text, mapping_t * map, svalue_t * cl
int i; int i;
Bool maybe_at_end; /* TRUE if the next text might start a new line */ Bool maybe_at_end; /* TRUE if the next text might start a new line */
Bool no_keys; /* TRUE if no delimiter in the string */ Bool no_keys; /* TRUE if no delimiter in the string */
#if DEBUG
Bool indent_overflows; Bool indent_overflows;
#endif
/* Used to catch this boundary condition: /* Used to catch this boundary condition:
* t_c("\\/ "*32, 0, indent > MAX_STRING_LENGTH - 40, 40) * t_c("\\/ "*32, 0, indent > MAX_STRING_LENGTH - 40, 40)
* In this case, the last indent is followed by no data, which the * In this case, the last indent is followed by no data, which the
@ -2209,7 +2211,9 @@ e_terminal_colour ( string_t * text, mapping_t * map, svalue_t * cl
start = -1; start = -1;
space = 0; space = 0;
maybe_at_end = MY_FALSE; maybe_at_end = MY_FALSE;
#if DEBUG
indent_overflows = MY_FALSE; indent_overflows = MY_FALSE;
#endif
j = 0; /* gathers the total length of the final string */ j = 0; /* gathers the total length of the final string */
j_extra = 0; /* gathers the extra length needed during fmt'ing */ j_extra = 0; /* gathers the extra length needed during fmt'ing */
for (i = 0; i < num; i++) for (i = 0; i < num; i++)
@ -2377,7 +2381,9 @@ e_terminal_colour ( string_t * text, mapping_t * map, svalue_t * cl
/* Reduce this part to fit; all the following /* Reduce this part to fit; all the following
* parts will be reduced to shreds. * parts will be reduced to shreds.
*/ */
#if DEBUG
indent_overflows = MY_TRUE; indent_overflows = MY_TRUE;
#endif
lens[i] -= (j - MAX_STRING_LENGTH); lens[i] -= (j - MAX_STRING_LENGTH);
j = MAX_STRING_LENGTH; j = MAX_STRING_LENGTH;
if (lens[i] < z) if (lens[i] < z)
@ -2393,7 +2399,9 @@ e_terminal_colour ( string_t * text, mapping_t * map, svalue_t * cl
else else
{ {
/* This replacement does not need to be wrapped. */ /* This replacement does not need to be wrapped. */
#if DEBUG
indent_overflows = MY_FALSE; indent_overflows = MY_FALSE;
#endif
j += -lens[i]; j += -lens[i];
if (j > MAX_STRING_LENGTH) if (j > MAX_STRING_LENGTH)
{ {
@ -6453,10 +6461,8 @@ f_deep_copy (svalue_t *sp)
#endif /* USE_STRUCTS */ #endif /* USE_STRUCTS */
case T_MAPPING: case T_MAPPING:
{ {
mapping_t *old;
svalue_t new; svalue_t new;
old = sp->u.map;
ptable = new_pointer_table(); ptable = new_pointer_table();
if (!ptable) if (!ptable)
errorf("(deep_copy) Out of memory for pointer table.\n"); errorf("(deep_copy) Out of memory for pointer table.\n");
@ -8921,10 +8927,8 @@ f_strptime (svalue_t *sp)
char *input = get_txt(sp[-1].u.str); char *input = get_txt(sp[-1].u.str);
struct tm time_struct; struct tm time_struct;
time_t time_res; time_t time_res;
char *res;
res = strptime(input, fmt, &time_struct); (void) strptime(input, fmt, &time_struct);
/* printf("res is %s\n", res);
// FIXME: check return value */ // FIXME: check return value */
time_res = mktime(&time_struct); time_res = mktime(&time_struct);

View File

@ -637,11 +637,9 @@ cleanup_object (object_t * obj)
cleanup_t * context = NULL; cleanup_t * context = NULL;
#ifdef LOG_NEW_CLEANUP #ifdef LOG_NEW_CLEANUP
struct timeval t_begin, t_end; struct timeval t_begin, t_end;
#endif /* LOG_NEW_CLEANUP */
Bool didSwap = MY_FALSE; Bool didSwap = MY_FALSE;
unsigned long numValues = 0; unsigned long numValues = 0;
#ifdef LOG_NEW_CLEANUP
if (gettimeofday(&t_begin, NULL)) if (gettimeofday(&t_begin, NULL))
{ {
t_begin.tv_sec = t_begin.tv_usec = 0; t_begin.tv_sec = t_begin.tv_usec = 0;
@ -651,9 +649,13 @@ cleanup_object (object_t * obj)
context = cleanup_new(MY_FALSE); context = cleanup_new(MY_FALSE);
if (context != NULL) if (context != NULL)
{ {
#ifdef LOG_NEW_CLEANUP
didSwap = cleanup_single_object(obj, context); didSwap = cleanup_single_object(obj, context);
#endif /* LOG_NEW_CLEANUP */
cleanup_compact_mappings(context); cleanup_compact_mappings(context);
#ifdef LOG_NEW_CLEANUP
numValues = context->numValues; numValues = context->numValues;
#endif /* LOG_NEW_CLEANUP */
cleanup_free(context); cleanup_free(context);
} }
obj->time_cleanup = current_time + (9*time_to_data_cleanup)/10 obj->time_cleanup = current_time + (9*time_to_data_cleanup)/10
@ -724,8 +726,8 @@ cleanup_driver_structures (void)
cleanup_t * context = NULL; cleanup_t * context = NULL;
#ifdef LOG_NEW_CLEANUP #ifdef LOG_NEW_CLEANUP
struct timeval t_begin, t_end; struct timeval t_begin, t_end;
#endif /* LOG_NEW_CLEANUP */
unsigned long numValues = 0; unsigned long numValues = 0;
#endif /* LOG_NEW_CLEANUP */
static mp_int time_cleanup = 0; static mp_int time_cleanup = 0;
/* Time of the next regular cleanup. */ /* Time of the next regular cleanup. */
@ -749,7 +751,9 @@ static mp_int time_cleanup = 0;
{ {
cleanup_structures(context); cleanup_structures(context);
cleanup_compact_mappings(context); cleanup_compact_mappings(context);
#ifdef LOG_NEW_CLEANUP
numValues = context->numValues; numValues = context->numValues;
#endif /* LOG_NEW_CLEANUP */
cleanup_free(context); cleanup_free(context);
} }

View File

@ -489,7 +489,7 @@ static void yyerror(const char *) NORETURN;
static int yylex(void); static int yylex(void);
int yyparse(void); int yyparse(void);
int ungetc(int c, FILE *f); int ungetc(int c, FILE *f);
static const char *type_str(int); //atic const char *type_str(int);
static long type2flag (int n); static long type2flag (int n);
static const char *etype(long); static const char *etype(long);
static const char *ctype(int); static const char *ctype(int);
@ -2147,6 +2147,7 @@ ident (char c)
return ID; return ID;
} /* ident() */ } /* ident() */
#if 0
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static const char * static const char *
type_str (int n) type_str (int n)
@ -2188,6 +2189,7 @@ type_str (int n)
} }
return "What?"; return "What?";
} /* type_str() */ } /* type_str() */
#endif
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static void static void
@ -2258,7 +2260,7 @@ yylex1 (void)
int line; int line;
char file[MAXPATHLEN+1]; char file[MAXPATHLEN+1];
fgets(line_buffer, MAKE_FUNC_MAXLINE, fpr); (void) fgets(line_buffer, MAKE_FUNC_MAXLINE, fpr);
if ( sscanf(line_buffer, "%d \"%s\"",&line,file ) == 2 ) if ( sscanf(line_buffer, "%d \"%s\"",&line,file ) == 2 )
{ {
current_line = line+1; current_line = line+1;

View File

@ -147,9 +147,12 @@ struct mvf_info
/* mapping_t *ref_mapping(mapping_t *m) /* mapping_t *ref_mapping(mapping_t *m)
* Add another ref to mapping <m> and return the mapping <m>. * Add another ref to mapping <m> and return the mapping <m>.
* Used to be defined like this, but gcc 2016 doesn't like it:
* #define ref_mapping(m) ((m)->ref++, (m))
*/ */
#define ref_mapping(m) ((m)->ref++, (m)) #define ref_mapping(m) ( ((m)->ref++) ? (m) : 0 )
/* Bool free_mapping(mapping_t *m) /* Bool free_mapping(mapping_t *m)
* Subtract one ref from mapping <m>, and free the mapping fully if * Subtract one ref from mapping <m>, and free the mapping fully if

View File

@ -1073,14 +1073,12 @@ mstring_mstr_rn_str ( const string_t * const pStr, size_t start
{ {
const char * cp; const char * cp;
size_t left;
char first; char first;
if (start > mstrsize(pStr)) if (start > mstrsize(pStr))
return NULL; return NULL;
/* Initialize 'characters remaining' and 'current position' */ /* Initialize 'current position' */
left = mstrsize(pStr) - start;
cp = get_txt((string_t *const)pStr)+start; cp = get_txt((string_t *const)pStr)+start;
/* Special case: strrstr("text", "") */ /* Special case: strrstr("text", "") */

View File

@ -183,7 +183,12 @@ struct replace_ob_s
#ifndef USE_PARANOIA #ifndef USE_PARANOIA
# define ref_object(o,from) ((o)->ref++, (o)) /*
* odd hack to stop gcc from complaining about
* a legitimate use of the comma operator.
* assuming ref cannot be negative. --lynX 2016
*/
# define ref_object(o,from) ( ((o)->ref++) ? (o) : 0 )
#else #else

View File

@ -94,9 +94,10 @@ register int c;
trick the optimizer of the IBM C compiler for OS/2 into generating correct trick the optimizer of the IBM C compiler for OS/2 into generating correct
code. Apparently IBM isn't going to fix the problem, and we would rather not code. Apparently IBM isn't going to fix the problem, and we would rather not
disable optimization (in this module it actually makes a big difference, and disable optimization (in this module it actually makes a big difference, and
the pcre module can use all the optimization it can get). */ the pcre module can use all the optimization it can get).
volatile int dummy; Breaking OS/2 in favor of gcc's paranoia. --lynX 2016
*/
do do
{ {
@ -154,7 +155,6 @@ do
case OP_BRAMINZERO: case OP_BRAMINZERO:
if (!set_start_bits(++tcode, start_bits, caseless, utf8, cd)) if (!set_start_bits(++tcode, start_bits, caseless, utf8, cd))
return FALSE; return FALSE;
dummy = 1;
do tcode += GET(tcode,1); while (*tcode == OP_ALT); do tcode += GET(tcode,1); while (*tcode == OP_ALT);
tcode += 1+LINK_SIZE; tcode += 1+LINK_SIZE;
break; break;

View File

@ -176,7 +176,7 @@ fill_header_from_mapping (svalue_t *key, svalue_t *val, void *extra) {
} }
} }
psyc_list_init(&list, elems, VEC_SIZE(val->u.vec)); psyc_list_init(&list, (PsycElem *) elems, VEC_SIZE(val->u.vec));
valuelen = list.length; valuelen = list.length;
value = pxalloc(valuelen); value = pxalloc(valuelen);
if (!value) { if (!value) {
@ -461,19 +461,19 @@ f_psyc_parse (svalue_t *sp) {
switch (type) { switch (type) {
case PSYC_TYPE_DATE: // number + PSYC_EPOCH case PSYC_TYPE_DATE: // number + PSYC_EPOCH
if (psyc_parse_uint(PSYC_S2ARG(value), &timmy)) if (psyc_parse_uint(PSYC_S2ARG(value), (uint64_t *) &timmy))
put_number(sv, timmy); put_number(sv, timmy);
else else
error = PSYC_PARSE_ERROR_DATE; error = PSYC_PARSE_ERROR_DATE;
break; break;
case PSYC_TYPE_TIME: // number case PSYC_TYPE_TIME: // number
if (psyc_parse_uint(PSYC_S2ARG(value), &timmy)) if (psyc_parse_uint(PSYC_S2ARG(value), (uint64_t *) &timmy))
put_number(sv, timmy); put_number(sv, timmy);
else else
error = PSYC_PARSE_ERROR_TIME; error = PSYC_PARSE_ERROR_TIME;
break; break;
case PSYC_TYPE_AMOUNT: // number case PSYC_TYPE_AMOUNT: // number
if (psyc_parse_uint(PSYC_S2ARG(value), &n)) if (psyc_parse_uint(PSYC_S2ARG(value), (uint64_t *) &n))
put_number(sv, n); put_number(sv, n);
else else
error = PSYC_PARSE_ERROR_AMOUNT; error = PSYC_PARSE_ERROR_AMOUNT;

View File

@ -1344,8 +1344,8 @@ f_tls_check_certificate(svalue_t *sp)
BIO *bio = BIO_new(BIO_s_mem()); BIO *bio = BIO_new(BIO_s_mem());
char *tmp; char *tmp;
long l; long l;
int l2; // int l2;
l2 = PEM_write_bio_X509(bio, peer); // l2 = PEM_write_bio_X509(bio, peer);
l = BIO_get_mem_data(bio, &tmp); l = BIO_get_mem_data(bio, &tmp);
tmp[l] = 0; tmp[l] = 0;
if (l > 0) if (l > 0)

View File

@ -12716,8 +12716,6 @@ function_call:
*/ */
PREPARE_INSERT(4) PREPARE_INSERT(4)
function_t *funp;
f = define_new_function(MY_FALSE, f = define_new_function(MY_FALSE,
$1.real, 0, 0, 0, NAME_UNDEFINED, Type_Unknown $1.real, 0, 0, 0, NAME_UNDEFINED, Type_Unknown
); );
@ -12725,7 +12723,6 @@ function_call:
add_f_code(F_CALL_FUNCTION); add_f_code(F_CALL_FUNCTION);
add_short(f); add_short(f);
CURRENT_PROGRAM_SIZE += 3; CURRENT_PROGRAM_SIZE += 3;
funp = FUNCTION(f);
if (exact_types.typeflags) if (exact_types.typeflags)
{ {
yyerrorf("Undefined function '%.50s'", get_txt($1.real->name)); yyerrorf("Undefined function '%.50s'", get_txt($1.real->name));
@ -14875,7 +14872,6 @@ get_virtual_function_id (program_t *progp, int fx)
{ {
funflag_t flags; funflag_t flags;
funflag_t *last;
flags = progp->functions[fx]; flags = progp->functions[fx];
@ -14886,9 +14882,6 @@ get_virtual_function_id (program_t *progp, int fx)
flags = progp->functions[fx]; flags = progp->functions[fx];
} }
/* This one is inherited virtual. We wont get called otherwise. */
last = &progp->functions[fx];
/* Walk the inherit chain */ /* Walk the inherit chain */
while((flags & (NAME_INHERITED|TYPE_MOD_VIRTUAL)) == (NAME_INHERITED|TYPE_MOD_VIRTUAL)) while((flags & (NAME_INHERITED|TYPE_MOD_VIRTUAL)) == (NAME_INHERITED|TYPE_MOD_VIRTUAL))
{ {

View File

@ -17,7 +17,7 @@ version_longtype="stable"
# A timestamp, to be used by bumpversion and other scripts. # A timestamp, to be used by bumpversion and other scripts.
# It can be used, for example, to 'touch' this file on every build, thus # It can be used, for example, to 'touch' this file on every build, thus
# forcing revision control systems to add it on every checkin automatically. # forcing revision control systems to add it on every checkin automatically.
version_stamp="Fri Aug 12 11:57:13 CEST 2016" version_stamp="Sun Aug 14 19:57:43 CEST 2016"
# Okay, LDMUD is using 3.x.x so to avoid conflicts let's just use 4.x.x # Okay, LDMUD is using 3.x.x so to avoid conflicts let's just use 4.x.x
version_major=4 version_major=4