From 27f21a3bf0d140f0d2680c695e8df229b46a814b Mon Sep 17 00:00:00 2001 From: "psyc://loupsycedyglgamf.onion/~lynX" Date: Wed, 10 Aug 2016 15:44:52 +0000 Subject: [PATCH] handle warnings, hopefully w/o introducing real bugs --- src/autoconf/configure.ac | 12 +++++++++--- src/closure.c | 3 +-- src/efuns.c | 16 ++++++++++------ src/gcollect.c | 10 +++++++--- src/make_func.y | 6 ++++-- src/mapping.h | 5 ++++- src/mstrings.c | 4 +--- src/object.h | 7 ++++++- src/pcre/study.c | 6 +++--- src/pkg-psyc.c | 8 ++++---- src/pkg-tls.c | 4 ++-- src/prolang.y | 7 ------- src/version.sh | 2 +- 13 files changed, 52 insertions(+), 38 deletions(-) diff --git a/src/autoconf/configure.ac b/src/autoconf/configure.ac index 4d7aa10..002c96e 100644 --- a/src/autoconf/configure.ac +++ b/src/autoconf/configure.ac @@ -1248,7 +1248,7 @@ int main(void) { if test $lp_cv_has_gnunet = yes; then AC_DEFINE(HAS_GNUNET, 1, [Does the machine offer GNUnet?]) PKGLIBS="$PKGLIBS $LIBS" - echo ">>> Congrats! GNUnet CADET is available." + echo " >>> Congrats! GNUnet CADET is available." else echo "GNUnet CADET not available on this system yet." fi @@ -1283,7 +1283,7 @@ int main(void) { if test $lp_cv_has_psyc = yes; then AC_DEFINE(HAS_PSYC, 1, [Does the machine offer libpsyc?]) PKGLIBS="$PKGLIBS $LIBS" - echo ">>> Congrats! libpsyc is available on this system." + echo " >>> Congrats! libpsyc is available on this system." else echo "libpsyc not available on this system yet." fi @@ -2563,7 +2563,13 @@ EOF AC_MSG_CHECKING(warning CFLAGS) changequote(,)dnl 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 # The option is recognized, but if it generates warnings on the # above correct program, we still can't use it. So check for that. diff --git a/src/closure.c b/src/closure.c index da48f86..11c8c2b 100644 --- a/src/closure.c +++ b/src/closure.c @@ -3270,7 +3270,6 @@ compile_value (svalue_t *value, int opt_flags) mp_int start, offset; int flags, i; - int void_given; if (block_size < 2 && block_size > 6) 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); start = current.code_max - current.code_left; - void_given = compile_value(++argp, 0); + (void) compile_value(++argp, 0); if (current.code_left < 1) realloc_code(); diff --git a/src/efuns.c b/src/efuns.c index d3f371e..427cd3d 100644 --- a/src/efuns.c +++ b/src/efuns.c @@ -571,7 +571,7 @@ v_sha1 (svalue_t *sp, int num_arg) { SHA1Context context; string_t *s_digest; - unsigned char *digest, d[SHA1HashSize + 1]; + unsigned char *digest, d[SHA1HashSize + 2]; int i; p_int iterations; @@ -1871,7 +1871,9 @@ e_terminal_colour ( string_t * text, mapping_t * map, svalue_t * cl int i; Bool maybe_at_end; /* TRUE if the next text might start a new line */ Bool no_keys; /* TRUE if no delimiter in the string */ +#if DEBUG Bool indent_overflows; +#endif /* Used to catch this boundary condition: * t_c("\\/ "*32, 0, indent > MAX_STRING_LENGTH - 40, 40) * 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; space = 0; maybe_at_end = MY_FALSE; +#if DEBUG indent_overflows = MY_FALSE; +#endif j = 0; /* gathers the total length of the final string */ j_extra = 0; /* gathers the extra length needed during fmt'ing */ 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 * parts will be reduced to shreds. */ +#if DEBUG indent_overflows = MY_TRUE; +#endif lens[i] -= (j - MAX_STRING_LENGTH); j = MAX_STRING_LENGTH; if (lens[i] < z) @@ -2393,7 +2399,9 @@ e_terminal_colour ( string_t * text, mapping_t * map, svalue_t * cl else { /* This replacement does not need to be wrapped. */ +#if DEBUG indent_overflows = MY_FALSE; +#endif j += -lens[i]; if (j > MAX_STRING_LENGTH) { @@ -6453,10 +6461,8 @@ f_deep_copy (svalue_t *sp) #endif /* USE_STRUCTS */ case T_MAPPING: { - mapping_t *old; svalue_t new; - old = sp->u.map; ptable = new_pointer_table(); if (!ptable) 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); struct tm time_struct; time_t time_res; - char *res; - res = strptime(input, fmt, &time_struct); - /* printf("res is %s\n", res); + (void) strptime(input, fmt, &time_struct); // FIXME: check return value */ time_res = mktime(&time_struct); diff --git a/src/gcollect.c b/src/gcollect.c index 4587afc..e4b376b 100644 --- a/src/gcollect.c +++ b/src/gcollect.c @@ -637,11 +637,9 @@ cleanup_object (object_t * obj) cleanup_t * context = NULL; #ifdef LOG_NEW_CLEANUP struct timeval t_begin, t_end; -#endif /* LOG_NEW_CLEANUP */ Bool didSwap = MY_FALSE; unsigned long numValues = 0; -#ifdef LOG_NEW_CLEANUP if (gettimeofday(&t_begin, NULL)) { t_begin.tv_sec = t_begin.tv_usec = 0; @@ -651,9 +649,13 @@ cleanup_object (object_t * obj) context = cleanup_new(MY_FALSE); if (context != NULL) { +#ifdef LOG_NEW_CLEANUP didSwap = cleanup_single_object(obj, context); +#endif /* LOG_NEW_CLEANUP */ cleanup_compact_mappings(context); +#ifdef LOG_NEW_CLEANUP numValues = context->numValues; +#endif /* LOG_NEW_CLEANUP */ cleanup_free(context); } obj->time_cleanup = current_time + (9*time_to_data_cleanup)/10 @@ -724,8 +726,8 @@ cleanup_driver_structures (void) cleanup_t * context = NULL; #ifdef LOG_NEW_CLEANUP struct timeval t_begin, t_end; -#endif /* LOG_NEW_CLEANUP */ unsigned long numValues = 0; +#endif /* LOG_NEW_CLEANUP */ static mp_int time_cleanup = 0; /* Time of the next regular cleanup. */ @@ -749,7 +751,9 @@ static mp_int time_cleanup = 0; { cleanup_structures(context); cleanup_compact_mappings(context); +#ifdef LOG_NEW_CLEANUP numValues = context->numValues; +#endif /* LOG_NEW_CLEANUP */ cleanup_free(context); } diff --git a/src/make_func.y b/src/make_func.y index 3c957d5..f23ad3e 100644 --- a/src/make_func.y +++ b/src/make_func.y @@ -489,7 +489,7 @@ static void yyerror(const char *) NORETURN; static int yylex(void); int yyparse(void); int ungetc(int c, FILE *f); -static const char *type_str(int); +//atic const char *type_str(int); static long type2flag (int n); static const char *etype(long); static const char *ctype(int); @@ -2147,6 +2147,7 @@ ident (char c) return ID; } /* ident() */ +#if 0 /*-------------------------------------------------------------------------*/ static const char * type_str (int n) @@ -2188,6 +2189,7 @@ type_str (int n) } return "What?"; } /* type_str() */ +#endif /*-------------------------------------------------------------------------*/ static void @@ -2258,7 +2260,7 @@ yylex1 (void) int line; 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 ) { current_line = line+1; diff --git a/src/mapping.h b/src/mapping.h index 3019a37..00a2b90 100644 --- a/src/mapping.h +++ b/src/mapping.h @@ -147,9 +147,12 @@ struct mvf_info /* mapping_t *ref_mapping(mapping_t *m) * Add another ref to mapping and return the mapping . + + * 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) * Subtract one ref from mapping , and free the mapping fully if diff --git a/src/mstrings.c b/src/mstrings.c index e27869d..31130e7 100644 --- a/src/mstrings.c +++ b/src/mstrings.c @@ -1073,14 +1073,12 @@ mstring_mstr_rn_str ( const string_t * const pStr, size_t start { const char * cp; - size_t left; char first; if (start > mstrsize(pStr)) return NULL; - /* Initialize 'characters remaining' and 'current position' */ - left = mstrsize(pStr) - start; + /* Initialize 'current position' */ cp = get_txt((string_t *const)pStr)+start; /* Special case: strrstr("text", "") */ diff --git a/src/object.h b/src/object.h index 9d88013..ba333a3 100644 --- a/src/object.h +++ b/src/object.h @@ -183,7 +183,12 @@ struct replace_ob_s #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 diff --git a/src/pcre/study.c b/src/pcre/study.c index a40f721..0aadcb3 100644 --- a/src/pcre/study.c +++ b/src/pcre/study.c @@ -94,9 +94,10 @@ register int c; 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 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 { @@ -154,7 +155,6 @@ do case OP_BRAMINZERO: if (!set_start_bits(++tcode, start_bits, caseless, utf8, cd)) return FALSE; - dummy = 1; do tcode += GET(tcode,1); while (*tcode == OP_ALT); tcode += 1+LINK_SIZE; break; diff --git a/src/pkg-psyc.c b/src/pkg-psyc.c index ad1e05d..dd3618b 100644 --- a/src/pkg-psyc.c +++ b/src/pkg-psyc.c @@ -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; value = pxalloc(valuelen); if (!value) { @@ -461,19 +461,19 @@ f_psyc_parse (svalue_t *sp) { switch (type) { 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); else error = PSYC_PARSE_ERROR_DATE; break; 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); else error = PSYC_PARSE_ERROR_TIME; break; 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); else error = PSYC_PARSE_ERROR_AMOUNT; diff --git a/src/pkg-tls.c b/src/pkg-tls.c index 16e35bc..6fad47e 100644 --- a/src/pkg-tls.c +++ b/src/pkg-tls.c @@ -1344,8 +1344,8 @@ f_tls_check_certificate(svalue_t *sp) BIO *bio = BIO_new(BIO_s_mem()); char *tmp; long l; - int l2; - l2 = PEM_write_bio_X509(bio, peer); +// int l2; +// l2 = PEM_write_bio_X509(bio, peer); l = BIO_get_mem_data(bio, &tmp); tmp[l] = 0; if (l > 0) diff --git a/src/prolang.y b/src/prolang.y index c37faa1..a65c47a 100644 --- a/src/prolang.y +++ b/src/prolang.y @@ -12716,8 +12716,6 @@ function_call: */ PREPARE_INSERT(4) - function_t *funp; - f = define_new_function(MY_FALSE, $1.real, 0, 0, 0, NAME_UNDEFINED, Type_Unknown ); @@ -12725,7 +12723,6 @@ function_call: add_f_code(F_CALL_FUNCTION); add_short(f); CURRENT_PROGRAM_SIZE += 3; - funp = FUNCTION(f); if (exact_types.typeflags) { 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 *last; flags = progp->functions[fx]; @@ -14886,9 +14882,6 @@ get_virtual_function_id (program_t *progp, int fx) flags = progp->functions[fx]; } - /* This one is inherited virtual. We wont get called otherwise. */ - last = &progp->functions[fx]; - /* Walk the inherit chain */ while((flags & (NAME_INHERITED|TYPE_MOD_VIRTUAL)) == (NAME_INHERITED|TYPE_MOD_VIRTUAL)) { diff --git a/src/version.sh b/src/version.sh index 4cf9af6..e37bbdf 100644 --- a/src/version.sh +++ b/src/version.sh @@ -17,7 +17,7 @@ version_longtype="stable" # A timestamp, to be used by bumpversion and other scripts. # 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. -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 version_major=4