From: Steve Youngs Date: Sun, 6 Dec 2015 23:26:44 +0000 (+1000) Subject: Compiler & warning related updates/fixes from Nelson X-Git-Tag: v22.1.16~14 X-Git-Url: http://cgit.sxemacs.org/?p=sxemacs;a=commitdiff_plain;h=fd2c93018b11b5bcb0aea8fa783f3c58046989bf;hp=6ea51f307b0121b67ba06111ddedbfb16189ea44 Compiler & warning related updates/fixes from Nelson * merges: Typo fix, 'max_align_t' -> 'sxe_max_align_t' Silence warnings about usage of deprecated function when existing alternative is not available. Use proper assert in lwlib Fix typo on include guard for term.h Use proper max in lwlib Add some prototype to silence silly warnings. Turn off warning about deprecated usage of __free_hook. Use min/max from sxe-utils Properly handle return from getcwd. Shut set but unused warnings. Rename our max_align_t to sxe_max_align_t Mark variables set but unused. Fixup assert definitions. Add SXE_SET_UNUSED to shut unused warnings. Cleanup utilities. Introduce sxe-memory.h Address static inline warning in ase. Prevent movemail from proceeding when setuid fails --- diff --git a/configure.ac b/configure.ac index 51f6041..de6d160 100644 --- a/configure.ac +++ b/configure.ac @@ -1740,10 +1740,30 @@ fi after_morecore_hook_exists=yes AC_CHECK_FUNC(malloc_set_state, ,doug_lea_malloc=no) AC_MSG_CHECKING(whether __after_morecore_hook exists) -AC_LINK_IFELSE([AC_LANG_SOURCE([[extern void (* __after_morecore_hook)();],[__after_morecore_hook = 0]])], +AC_LINK_IFELSE([AC_LANG_SOURCE([ + [extern void (* __after_morecore_hook)();] + [main() {__after_morecore_hook = 0;}] + ])], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) after_morecore_hook_exists=no]) +if test "$after_morecore_hook_exists" = "yes" ; then + AC_DEFINE([HAVE_MORECORE_HOOK], [1], [Define if __after_morecore_hook is available]) +fi +AC_SUBST(HAVE_MORECORE_HOOK) +free_hook_exists=yes +AC_MSG_CHECKING(whether __free_hook exists) +AC_LINK_IFELSE([AC_LANG_SOURCE([ + [extern void (* __free_hook)();] + [main() {__free_hook = 0;}] + ])], + [AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) + free_hook_exists=no]) +if test "$free_hook_exists" = "yes" ; then + AC_DEFINE([HAVE_FREE_HOOK], [1], [Define if __free_hook is available]) +fi +AC_SUBST(HAVE_FREE_HOOK) if test "$system_malloc" = "yes" ; then GNU_MALLOC=no GNU_MALLOC_reason=" diff --git a/lib-src/movemail.c b/lib-src/movemail.c index 9d75782..f6aa06d 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c @@ -344,14 +344,18 @@ int main(int argc, char *argv[]) int retcode = popmail(inname + 3, outname, poppass); exit(retcode); } - setuid(getuid()); + if (0 != setuid(getuid())) { + exit(1); + } #endif /* MAIL_USE_POP */ #ifndef DISABLE_DIRECT_ACCESS if (fork() == 0) { - setuid(getuid()); + if (0 != setuid(getuid())) { + exit(1); + } VERBOSE(("opening input file\n")); diff --git a/modules/ase/ase-neighbourhood.c b/modules/ase/ase-neighbourhood.c index 638b2f3..0e9b590 100644 --- a/modules/ase/ase-neighbourhood.c +++ b/modules/ase/ase-neighbourhood.c @@ -238,66 +238,6 @@ ase_make_neighbourhood(Lisp_Object pt, Lisp_Object rad, Lisp_Object metric) return result; } -/* accessors */ -inline Lisp_Object -ase_neighbourhood_point(ase_neighbourhood_t n) -{ - return n->point; -} - -inline Lisp_Object -ase_neighbourhood_radius(ase_neighbourhood_t n) -{ - return n->radius; -} - -/* Measures */ -static inline void -_ase_neighbourhood_update_lebesgue(ase_neighbourhood_t n) -{ - if (n && NILP(n->lebesgue_measure)) { - Lisp_Object i = n->ldata; - n->lebesgue_measure = Fase_interval_lebesgue_measure(i); - } - return; -} - -static inline Lisp_Object -_ase_neighbourhood_lebesgue(ase_neighbourhood_t n) -{ - return n->lebesgue_measure; -} - -inline Lisp_Object -ase_neighbourhood_lebesgue_measure(ase_neighbourhood_t n) -{ - _ase_neighbourhood_update_lebesgue(n); - return _ase_neighbourhood_lebesgue(n); -} - -static inline void -_ase_neighbourhood_update_rational(ase_neighbourhood_t n) -{ - if (n && NILP(n->rational_measure)) { - Lisp_Object i = n->ldata; - n->rational_measure = Fase_interval_rational_measure(i); - } - return; -} - -static inline Lisp_Object -_ase_neighbourhood_rational(ase_neighbourhood_t n) -{ - return n->rational_measure; -} - -inline Lisp_Object -ase_neighbourhood_rational_measure(ase_neighbourhood_t n) -{ - _ase_neighbourhood_update_rational(n); - return _ase_neighbourhood_rational(n); -} - /* lisp level */ DEFUN("ase-neighbourhoodp", Fase_neighbourhoodp, 1, 1, 0, /* diff --git a/modules/ase/ase-neighbourhood.h b/modules/ase/ase-neighbourhood.h index 52b26c9..e4f365a 100644 --- a/modules/ase/ase-neighbourhood.h +++ b/modules/ase/ase-neighbourhood.h @@ -131,34 +131,95 @@ extern Lisp_Object ase_neighbourhood_closure(Lisp_Object nbh); extern Lisp_Object ase_neighbourhood_interior(Lisp_Object nbh); /* predicates */ -static inline bool +extern_inline bool ase_neighbourhood_contains_obj_p(ase_neighbourhood_t, Lisp_Object); -static inline bool +extern_inline bool ase_neighbourhood_contains_nbh_p(ase_neighbourhood_t, ase_neighbourhood_t); -static inline bool ase_neighbourhood_open_p(ase_neighbourhood_t); -static inline bool ase_neighbourhood_closed_p(ase_neighbourhood_t); -static inline bool +extern_inline bool ase_neighbourhood_open_p(ase_neighbourhood_t); +extern_inline bool ase_neighbourhood_closed_p(ase_neighbourhood_t); +extern_inline bool ase_neighbourhood_less_obj_p(ase_neighbourhood_t, Lisp_Object); -static inline bool +extern_inline bool ase_neighbourhood_less_nbh_p(ase_neighbourhood_t, ase_neighbourhood_t); -static inline bool +extern_inline bool ase_neighbourhood_greater_obj_p(ase_neighbourhood_t, Lisp_Object); -static inline bool +extern_inline bool ase_neighbourhood_greater_nbh_p(ase_neighbourhood_t, ase_neighbourhood_t); -static inline Lisp_Object +extern_inline Lisp_Object ase_neighbourhood_point(ase_neighbourhood_t); -static inline Lisp_Object +extern_inline Lisp_Object ase_neighbourhood_radius(ase_neighbourhood_t); /* measures */ -static inline Lisp_Object +extern_inline Lisp_Object ase_neighbourhood_lebesgue_measure(ase_neighbourhood_t); -static inline Lisp_Object +extern_inline Lisp_Object ase_neighbourhood_rational_measure(ase_neighbourhood_t); /* inlines */ -static inline bool +extern_inline Lisp_Object +ase_neighbourhood_point(ase_neighbourhood_t n) +{ + return n->point; +} + +extern_inline Lisp_Object +ase_neighbourhood_radius(ase_neighbourhood_t n) +{ + return n->radius; +} + +/* Measures */ +extern_inline void +_ase_neighbourhood_update_rational(ase_neighbourhood_t n) +{ + if (n && NILP(n->rational_measure)) { + Lisp_Object i = n->ldata; + n->rational_measure = Fase_interval_rational_measure(i); + } + return; +} + +extern_inline Lisp_Object +_ase_neighbourhood_rational(ase_neighbourhood_t n) +{ + return n->rational_measure; +} + +extern_inline Lisp_Object +ase_neighbourhood_rational_measure(ase_neighbourhood_t n) +{ + _ase_neighbourhood_update_rational(n); + return _ase_neighbourhood_rational(n); +} + +extern_inline void +_ase_neighbourhood_update_lebesgue(ase_neighbourhood_t n) +{ + if (n && NILP(n->lebesgue_measure)) { + Lisp_Object i = n->ldata; + n->lebesgue_measure = Fase_interval_lebesgue_measure(i); + } + return; +} + +extern_inline Lisp_Object +_ase_neighbourhood_lebesgue(ase_neighbourhood_t n) +{ + return n->lebesgue_measure; +} + +extern_inline Lisp_Object +ase_neighbourhood_lebesgue_measure(ase_neighbourhood_t n) +{ + _ase_neighbourhood_update_lebesgue(n); + return _ase_neighbourhood_lebesgue(n); +} + + + +extern_inline bool ase_neighbourhood_contains_obj_p(ase_neighbourhood_t n, Lisp_Object obj) { /* we _know_ atm that n->ldata points to an ase_interval_t */ @@ -166,7 +227,7 @@ ase_neighbourhood_contains_obj_p(ase_neighbourhood_t n, Lisp_Object obj) return !NILP(Fase_interval_contains_p(intv, obj)); } -static inline bool +extern_inline bool ase_neighbourhood_contains_nbh_p(ase_neighbourhood_t n1, ase_neighbourhood_t n2) { /* we _know_ atm that {n1,n2}->data points to an ase_interval_t */ @@ -175,19 +236,19 @@ ase_neighbourhood_contains_nbh_p(ase_neighbourhood_t n1, ase_neighbourhood_t n2) return !NILP(Fase_interval_contains_p(i1, i2)); } -static inline bool +extern_inline bool ase_neighbourhood_open_p(ase_neighbourhood_t n) { return n->open_p; } -static inline bool +extern_inline bool ase_neighbourhood_closed_p(ase_neighbourhood_t n) { return !n->open_p; } -static inline bool +extern_inline bool ase_neighbourhood_less_obj_p(ase_neighbourhood_t n, Lisp_Object obj) { /* we _know_ atm that {n1,n2}->data points to an ase_interval_t */ @@ -196,7 +257,7 @@ ase_neighbourhood_less_obj_p(ase_neighbourhood_t n, Lisp_Object obj) return (_ase_less_p(a->upper, obj) || _ase_equal_p(a->upper, obj)); } -static inline bool +extern_inline bool ase_neighbourhood_less_nbh_p(ase_neighbourhood_t n1, ase_neighbourhood_t n2) { /* we _know_ atm that {n1,n2}->data points to an ase_interval_t */ @@ -206,7 +267,7 @@ ase_neighbourhood_less_nbh_p(ase_neighbourhood_t n1, ase_neighbourhood_t n2) _ase_equal_p(a1->upper, a2->lower)); } -static inline bool +extern_inline bool ase_neighbourhood_greater_obj_p(ase_neighbourhood_t n, Lisp_Object obj) { /* we _know_ atm that {n1,n2}->data points to an ase_interval_t */ @@ -214,7 +275,7 @@ ase_neighbourhood_greater_obj_p(ase_neighbourhood_t n, Lisp_Object obj) return (_ase_less_p(obj, a->lower) || _ase_equal_p(obj, a->lower)); } -static inline bool +extern_inline bool ase_neighbourhood_greater_nbh_p(ase_neighbourhood_t n1, ase_neighbourhood_t n2) { /* we _know_ atm that {n1,n2}->data points to an ase_interval_t */ diff --git a/src/bytecode.c b/src/bytecode.c index 8157c82..8eb8186 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -1049,6 +1049,8 @@ execute_optimized_program(const Opbyte *program, Lisp_Object args; orig_fun = fun = XCAR(op); + SXE_SET_UNUSED(orig_fun); + args = XCDR(op); if (SYMBOLP (fun) && !EQ(fun, Qunbound) && (fun = XSYMBOL(fun)->function, SYMBOLP(fun))) diff --git a/src/dumper.c b/src/dumper.c index 8e72ea4..e894834 100644 --- a/src/dumper.c +++ b/src/dumper.c @@ -336,7 +336,7 @@ pdump_get_entry_list(const struct struct_description *sdesc) } pdump_struct_table.list[pdump_struct_table.count].list.first = 0; pdump_struct_table.list[pdump_struct_table.count].list.align = - ALIGNOF(max_align_t); + ALIGNOF(sxe_max_align_t); pdump_struct_table.list[pdump_struct_table.count].list.count = 0; pdump_struct_table.list[pdump_struct_table.count].sdesc = sdesc; @@ -831,7 +831,7 @@ pdump_scan_by_alignment(void (*f) (pdump_entry_list_elt *, { int align; - for (align = ALIGNOF(max_align_t); align; align >>= 1) { + for (align = ALIGNOF(sxe_max_align_t); align; align >>= 1) { size_t i; pdump_entry_list_elt *elt; @@ -994,11 +994,11 @@ pdump(const char *dumpfile) pdump_object_table = xnew_array(pdump_entry_list, lrecord_type_count); pdump_alert_undump_object = xnew_array(int, lrecord_type_count); - assert(ALIGNOF(max_align_t) <= pdump_align_table[0]); + assert(ALIGNOF(sxe_max_align_t) <= pdump_align_table[0]); for (i = 0; i < countof(pdump_align_table); i++) - if (pdump_align_table[i] > ALIGNOF(max_align_t)) - pdump_align_table[i] = ALIGNOF(max_align_t); + if (pdump_align_table[i] > ALIGNOF(sxe_max_align_t)) + pdump_align_table[i] = ALIGNOF(sxe_max_align_t); flush_all_buffer_local_cache(); @@ -1020,7 +1020,7 @@ pdump(const char *dumpfile) for (i = 0; i < lrecord_type_count; i++) { pdump_object_table[i].first = 0; - pdump_object_table[i].align = ALIGNOF(max_align_t); + pdump_object_table[i].align = ALIGNOF(sxe_max_align_t); pdump_object_table[i].count = 0; pdump_alert_undump_object[i] = 0; } @@ -1028,7 +1028,7 @@ pdump(const char *dumpfile) pdump_struct_table.size = -1; pdump_opaque_data_list.first = 0; - pdump_opaque_data_list.align = ALIGNOF(max_align_t); + pdump_opaque_data_list.align = ALIGNOF(sxe_max_align_t); pdump_opaque_data_list.count = 0; depth = 0; @@ -1062,11 +1062,11 @@ pdump(const char *dumpfile) header.nb_root_struct_ptrs = Dynarr_length(pdump_root_struct_ptrs); header.nb_opaques = Dynarr_length(pdump_opaques); - cur_offset = ALIGN_SIZE(sizeof(header), ALIGNOF(max_align_t)); + cur_offset = ALIGN_SIZE(sizeof(header), ALIGNOF(sxe_max_align_t)); max_size = 0; pdump_scan_by_alignment(pdump_allocate_offset); - cur_offset = ALIGN_SIZE(cur_offset, ALIGNOF(max_align_t)); + cur_offset = ALIGN_SIZE(cur_offset, ALIGNOF(sxe_max_align_t)); header.stab_offset = cur_offset; pdump_buf = xmalloc_atomic(max_size); @@ -1086,7 +1086,7 @@ pdump(const char *dumpfile) } else { fwrite(&header, sizeof(header), 1, pdump_out); - PDUMP_ALIGN_OUTPUT(max_align_t); + PDUMP_ALIGN_OUTPUT(sxe_max_align_t); pdump_scan_by_alignment(pdump_dump_data); diff --git a/src/effi.c b/src/effi.c index 6baf2e6..06bf61b 100644 --- a/src/effi.c +++ b/src/effi.c @@ -1666,6 +1666,8 @@ Return DEVICE display as FFI object. /* Callbacks */ #define FFI_CC_CDECL 0 +void* ffi_make_callback_x86(Lisp_Object data, int cc_type); + #if defined __i386__ static void ffi_callback_call_x86(Lisp_Object cbk_info, char *arg_buffer) diff --git a/src/emacs.c b/src/emacs.c index 8feec5d..49fa20d 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2778,8 +2778,15 @@ main(int argc, char **argv, char **envp) /* various system shared libraries have been built and linked with */ /* GCC >= 2.8. -slb */ #if defined(GNU_MALLOC) +#if defined(HAVE_MORECORE_HOOK) static void voodoo_free_hook(void *mem) { + /* If it no longer works, we'll know about it. For now there is really no + good alternatic. Shut the warning off + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + /* Disable all calls to free() when SXEmacs is exiting and it doesn't */ /* matter. */ __free_hook = @@ -2788,7 +2795,9 @@ static void voodoo_free_hook(void *mem) (__typeof__(__free_hook)) #endif voodoo_free_hook; +#pragma GCC diagnostic pop } +#endif #endif /* GNU_MALLOC */ DEFUN("kill-emacs", Fkill_emacs, 0, 1, "P", /* @@ -2843,12 +2852,17 @@ all of which are called before SXEmacs is actually killed. shut_down_emacs(0, STRINGP(arg) ? arg : Qnil, 0); #if defined(GNU_MALLOC) +#if defined(HAVE_MORECORE_HOOK) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" __free_hook = #if defined __GNUC__ || defined __INTEL_COMPILER /* prototype of __free_hook varies with glibc version */ (__typeof__(__free_hook)) #endif voodoo_free_hook; +#pragma GCC diagnostic pop +#endif #endif exit(INTP(arg) ? XINT(arg) : 0); @@ -3064,6 +3078,7 @@ and announce itself normally when it is run. garbage_collect_1(); #ifdef PDUMP + SXE_SET_UNUSED(symfile_ext); pdump(filename_ext); #else @@ -3213,6 +3228,8 @@ static int assertions_dont_abort = 0; #define enter_debugger() +void debug_backtrace(); + void assert_failed(const char *file, int line, const char *expr) { diff --git a/src/lisp.h b/src/lisp.h index 43f7536..ed698a8 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -31,6 +31,7 @@ along with this program. If not, see . */ /* the old SXEmacs general includes and utility macros moved here: */ #include "sxe-utils.h" +#include "sxe-memory.h" /* ------------------------ dynamic arrays ------------------- */ @@ -644,8 +645,7 @@ PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len, tail, \ (CONSP (hare) ? ((elt = XCAR (hare)), 1) : \ (NILP (hare) ? 0 : \ (signal_malformed_list_error (list), 0))); \ - \ - (hare = XCDR (hare)), \ + (hare = XCDR (hare)), SXE_SET_UNUSED(elt), \ (void)((++len > suspicion_length) && \ ((void)(((len & 1) != 0)&& \ ((tortoise = XCDR (tortoise)), 0)), \ @@ -785,6 +785,7 @@ PRIVATE_EXTERNAL_ALIST_LOOP_8 (elt, elt_car, elt_cdr, list, \ #define PRIVATE_EXTERNAL_ALIST_LOOP_8(elt, elt_car, elt_cdr, list, len, \ hare, tortoise, suspicion_length) \ +SXE_SET_UNUSED(elt_car),SXE_SET_UNUSED(elt_cdr); \ PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len, hare, tortoise, \ suspicion_length) \ if (CONSP (elt) ? (elt_car = XCAR (elt), elt_cdr = XCDR (elt), 0) :1) \ diff --git a/src/lstream.c b/src/lstream.c index 21214e0..fb1e00c 100644 --- a/src/lstream.c +++ b/src/lstream.c @@ -186,7 +186,7 @@ aligned_sizeof_lstream(size_t lstream_type_specific_size) { return ALIGN_SIZE(offsetof(struct lstream_s, data) + lstream_type_specific_size, - ALIGNOF(max_align_t)); + ALIGNOF(sxe_max_align_t)); } static inline size_t diff --git a/src/lstream.h b/src/lstream.h index a34e12b..3a9ed80 100644 --- a/src/lstream.h +++ b/src/lstream.h @@ -203,7 +203,7 @@ struct lstream_s { Lstream_data_count byte_count; int flags; - max_align_t data[1]; + sxe_max_align_t data[1]; }; #define LSTREAM_TYPE_P(lstr, type) \ diff --git a/src/media/media-internal.c b/src/media/media-internal.c index e59193c..7ee8deb 100644 --- a/src/media/media-internal.c +++ b/src/media/media-internal.c @@ -947,6 +947,8 @@ void media_internal_analyse_stream(Lisp_Media_Stream *ms) mkfp = media_stream_kind_properties(ms).fprops; TO_EXTERNAL_FORMAT(LISP_STRING, mkfp->filename, ALLOCA, (file, file_len), Qnil); + SXE_SET_UNUSED(file_len); + if (file == NULL || (fd = open(file, O_RDONLY, 0)) < 0) { xfree(data); return; diff --git a/src/media/media-mad.c b/src/media/media-mad.c index ba2101c..58ff625 100644 --- a/src/media/media-mad.c +++ b/src/media/media-mad.c @@ -299,6 +299,7 @@ media_mad_read(media_substream *mss, void *outbuf, size_t length) /* fetch framesize */ framesize = mtap->framesize; + SXE_SET_UNUSED(framesize); /* prepare mad */ mads = madd->stream; diff --git a/src/media/media-sndfile.c b/src/media/media-sndfile.c index e819126..05dc2e0 100644 --- a/src/media/media-sndfile.c +++ b/src/media/media-sndfile.c @@ -105,6 +105,8 @@ media_sndfile_open(Lisp_Media_Stream *ms) mkfp = media_stream_kind_properties(ms).fprops; TO_EXTERNAL_FORMAT(LISP_STRING, mkfp->filename, ALLOCA, (file, file_len), Qnil); + SXE_SET_UNUSED(file_len); + if ( file != NULL ) { sf = sf_open(file, SFM_READ, sfinfo); } diff --git a/src/media/sound-alsa.c b/src/media/sound-alsa.c index c887ef0..1428f1e 100644 --- a/src/media/sound-alsa.c +++ b/src/media/sound-alsa.c @@ -275,6 +275,8 @@ sound_alsa_handle_aj_events(audio_job_t aj) SXE_MUTEX_LOCK(&aj->mtx); sasd = audio_job_device_data(aj); + SXE_SET_UNUSED(sasd); + if ((ev = eq_noseeum_dequeue(audio_job_queue(aj))) == NULL) { SXE_MUTEX_UNLOCK(&aj->mtx); return; diff --git a/src/media/sound-ao.c b/src/media/sound-ao.c index eb6ad12..1a4e2cd 100644 --- a/src/media/sound-ao.c +++ b/src/media/sound-ao.c @@ -253,6 +253,8 @@ sound_ao_handle_aj_events(audio_job_t aj) SXE_MUTEX_LOCK(&aj->mtx); sasd = audio_job_device_data(aj); + SXE_SET_UNUSED(sasd); + if ((ev = eq_noseeum_dequeue(audio_job_queue(aj))) == NULL) { SXE_MUTEX_UNLOCK(&aj->mtx); return; diff --git a/src/media/sound-jack.c b/src/media/sound-jack.c index 9fd116a..353b077 100644 --- a/src/media/sound-jack.c +++ b/src/media/sound-jack.c @@ -335,6 +335,9 @@ finish: /* pull one channel out of a multi-channel stream */ static size_t +demux_internal(float *dst, char *src, + size_t n, int chan, sound_jack_aj_data_t *f); +static size_t demux_internal(float *dst, char *src, size_t n, int chan, sound_jack_aj_data_t *f) { @@ -446,6 +449,8 @@ sound_jack_handle_aj_events(audio_job_t aj) SXE_MUTEX_LOCK(&aj->mtx); sasd = audio_job_device_data(aj); + SXE_SET_UNUSED(sasd); + if ((ev = eq_noseeum_dequeue(audio_job_queue(aj))) == NULL) { SXE_MUTEX_UNLOCK(&aj->mtx); return; @@ -495,8 +500,11 @@ sound_jack_process(jack_nframes_t nframes, void *userdata) aj = userdata; SXE_MUTEX_LOCK(&aj->mtx); mss = aj->substream; + SXE_SET_UNUSED(mss); + sjsd = audio_job_device_data(aj); buffer = aj->buffer; + SXE_SET_UNUSED(buffer); #ifdef EF_USE_ASYNEQ /* stuff on the event queue? */ diff --git a/src/media/sound-oss.c b/src/media/sound-oss.c index 253a391..42014ba 100644 --- a/src/media/sound-oss.c +++ b/src/media/sound-oss.c @@ -363,6 +363,8 @@ sound_oss_handle_aj_events(audio_job_t aj) SXE_MUTEX_LOCK(&aj->mtx); sasd = audio_job_device_data(aj); + SXE_SET_UNUSED(sasd); + if ((ev = eq_noseeum_dequeue(audio_job_queue(aj))) == NULL) { SXE_MUTEX_UNLOCK(&aj->mtx); return; diff --git a/src/mule/file-coding.c b/src/mule/file-coding.c index 90b7dc7..b2dcd9a 100644 --- a/src/mule/file-coding.c +++ b/src/mule/file-coding.c @@ -1228,6 +1228,7 @@ and `coding-system-canonical-name-p'. /* Checks that aliasee names a coding-system */ real_coding_system = Fget_coding_system(aliasee); + SXE_SET_UNUSED(real_coding_system); /* Check for coding system alias loops */ if (EQ(alias, aliasee)) @@ -1851,7 +1852,11 @@ static Lisp_Object coding_system_from_mask(int mask) void autodetect_real_coding_system(lstream_t stream, Lisp_Object * codesys_in_out, - eol_type_t * eol_type_in_out) + eol_type_t * eol_type_in_out); + +void +autodetect_real_coding_system(lstream_t stream, Lisp_Object * codesys_in_out, + eol_type_t * eol_type_in_out) { static const char mime_name_valid_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" diff --git a/src/mule/mule-ccl.c b/src/mule/mule-ccl.c index a158776..068883e 100644 --- a/src/mule/mule-ccl.c +++ b/src/mule/mule-ccl.c @@ -809,6 +809,7 @@ static int stack_idx_of_map_multiple; } \ } \ } \ + SXE_SET_UNUSED(bytes); \ } while (0) /* Read one byte from the current input buffer into Rth register. */ diff --git a/src/opaque.c b/src/opaque.c index 70459a5..cfe5132 100644 --- a/src/opaque.c +++ b/src/opaque.c @@ -59,7 +59,7 @@ static inline size_t aligned_sizeof_opaque(size_t opaque_size) { return ALIGN_SIZE(offsetof(Lisp_Opaque, data) + opaque_size, - ALIGNOF(max_align_t)); + ALIGNOF(sxe_max_align_t)); } static size_t sizeof_opaque(const void *header) diff --git a/src/opaque.h b/src/opaque.h index 4f4aa91..a3edcf9 100644 --- a/src/opaque.h +++ b/src/opaque.h @@ -28,7 +28,7 @@ along with this program. If not, see . */ typedef struct Lisp_Opaque { struct lcrecord_header header; size_t size; - max_align_t data[1]; + sxe_max_align_t data[1]; } Lisp_Opaque; DECLARE_LRECORD(opaque, Lisp_Opaque); diff --git a/src/print.c b/src/print.c index 47c5f48..d1d3c2a 100644 --- a/src/print.c +++ b/src/print.c @@ -912,6 +912,8 @@ Display ERROR-OBJECT on STREAM in a user-friendly way. Lisp_Object Vfloat_output_format; +void float_to_string(char *buf, fpfloat data, int maxlen); + /* * This buffer should be at least as large as the max string size of the * largest float, printed in the biggest notation. This is undoubtedly diff --git a/src/realpath.c b/src/realpath.c index 1ccfd70..a8c7a3c 100644 --- a/src/realpath.c +++ b/src/realpath.c @@ -80,10 +80,14 @@ char *xrealpath(const char *path, char *restrict resolved_path) /* If it's a relative pathname use getcwd for starters. */ if (abslen == 0) { - getcwd(new_path, PATH_MAX - 1); - new_path += strlen(new_path); - if (!IS_DIRECTORY_SEP(new_path[-1])) - *new_path++ = DIRECTORY_SEP; + void *ok = getcwd(new_path, PATH_MAX - 1); + if (ok) { + new_path += strlen(new_path); + if (!IS_DIRECTORY_SEP(new_path[-1])) + *new_path++ = DIRECTORY_SEP; + } else { + return NULL; + } } else { /* Copy first directory sep. */ strncpy(new_path, path, abslen); diff --git a/src/regex.c b/src/regex.c index 6f9fb9c..2f7f8be 100644 --- a/src/regex.c +++ b/src/regex.c @@ -83,6 +83,8 @@ along with this program. If not, see . */ # undef REL_ALLOC #endif +#include "sxe-utils.h" + /* The `emacs' switch turns on certain matching commands that make sense only in Emacs. */ #ifdef emacs @@ -5855,6 +5857,7 @@ re_match_2_internal(struct re_pattern_buffer *bufp, re_char * string1, dummy_low_reg, dummy_high_reg, reg_dummy, reg_dummy, reg_info_dummy); + SXE_SET_UNUSED(pdummy), SXE_SET_UNUSED(sdummy); } /* Note fall through. */ diff --git a/src/specifier.h b/src/specifier.h index 3969a72..a299a2c 100644 --- a/src/specifier.h +++ b/src/specifier.h @@ -230,7 +230,7 @@ struct Lisp_Specifier { Lisp_Object fallback; /* type-specific extra data attached to a specifier */ - max_align_t data[1]; + sxe_max_align_t data[1]; }; typedef struct Lisp_Specifier Lisp_Specifier; diff --git a/src/sxe-memory.h b/src/sxe-memory.h new file mode 100644 index 0000000..41840e4 --- /dev/null +++ b/src/sxe-memory.h @@ -0,0 +1,181 @@ +/* Utility definitions for C code of SXEmacs for handling memory + + Copyright (C) 1985-1987, 1992-1995 Free Software Foundation, Inc. + Copyright (C) 1993-1996 Richard Mlynarik. + Copyright (C) 1995, 1996, 2000 Ben Wing. + Copyright (C) 2004 Steve Youngs. + Copyright (C) 2011 Nelson Ferreira. + +This file is part of SXEmacs + +SXEmacs is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +SXEmacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + +/* NOT synched with FSF */ +#ifndef INCLUDED_sxe_memory_h_ +#define INCLUDED_sxe_memory_h_ + + +/* generally useful */ +#define xnew(type) ((type *) xmalloc (sizeof (type))) +#define xnew_atomic(type) ((type *) xmalloc_atomic (sizeof (type))) +#define xnew_array(type, len) ((type *) xmalloc ((len) * sizeof (type))) +#define xnew_atomic_array(type, len) \ + ((type*)xmalloc_atomic((len) * sizeof(type))) +#define xnew_and_zero(type) ((type *) xmalloc_and_zero (sizeof (type))) +#define xzero(lvalue) ((void) memset (&(lvalue), '\0', sizeof (lvalue))) +#define xnew_array_and_zero(type, len) \ + ((type*)xmalloc_and_zero ((len) * sizeof (type))) +#define xrealloc_array(ptr, type, len) \ + ((void) (ptr = (type *) xrealloc (ptr, (len) * sizeof (type)))) +#define XREALLOC_ARRAY xrealloc_array +#define alloca_array(type, len) ((type *) alloca ((len) * sizeof (type))) + +/************************************************************************/ +/* Memory */ +/************************************************************************/ + +#ifdef ALL_DEBUG_FLAGS +#undef GC_DEBUG_FLAG +#define GC_DEBUG_FLAG +#endif + +#if !defined GC_DEBUG_FLAG +# define SXE_DEBUG_GC(args...) +#else +# define SXE_DEBUG_GC(args...) __SXE_DEBUG__("[gc] " args) +#endif +#define SXE_DEBUG_GC_PT(args...) SXE_DEBUG_GC("[pthread]: " args) +#define SXE_CRITICAL_GC(args...) __SXE_DEBUG__("[gc] CRITICAL: " args) + +void malloc_warning(const char *); + +#if defined HAVE_BDWGC && defined EF_USE_BDWGC +# if defined HAVE_THREADS +# if !defined GC_PTHREADS +# define GC_PTHREADS 1 +# endif /* !GC_PTHREADS */ +# if !defined GC_THREADS +# define GC_THREADS 1 +# endif /* !GC_THREADS */ +# endif /* HAVE_THREADS */ + +# undef GC_DEBUG +# if defined GC_DEBUG_FLAG +# define GC_DEBUG 1 +# endif /* GC_DEBUG_FLAG */ +# if defined HAVE_GC_GC_H +# include +# elif defined HAVE_GC_H +# include +# else +# error "Take less of those pills!" +# endif + +# if defined GC_DEBUG_FLAG +# define zmalloc GC_MALLOC_IGNORE_OFF_PAGE +# define zcalloc(n, m) GC_MALLOC((n)*(m)) +# define zmalloc_atomic GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE +# define zmalloc_and_zero GC_MALLOC +# define zrealloc GC_REALLOC +# define zstrdup GC_STRDUP +# undef zfree +# define zfree(x) GC_FREE(x) +# else /* !GC_DEBUG_FLAG */ +# define zmalloc GC_malloc_ignore_off_page +# define zcalloc(n, m) GC_malloc((n)*(m)) +# define zmalloc_atomic GC_malloc_atomic_ignore_off_page +# define zmalloc_and_zero GC_malloc +# define zrealloc GC_realloc +# define zstrdup GC_strdup +# undef zfree +# define zfree(x) +# endif /* GC_DEBUG_FLAG */ + +#else /* !BDWGC */ +#define zmalloc F&^! +#define zcalloc F&^! +#define zmalloc_atomic F&^! +#define zmalloc_and_zero F&^! +#define zrealloc F&^! +#define zstrdrup F&^! +#endif /* BDWGC */ + +/* also define libc mem funs */ +#define ymalloc malloc +#define ycalloc(n, m) calloc(n, m) +#define ymalloc_atomic(n) ycalloc(1, n) +#define ymalloc_and_zero(x) ycalloc(1, x) +#define yrealloc realloc +#define ystrdup strdup +#define yfree(x) free(x) +/* and their convenience companions */ +#define ynew(type) ((type*)ymalloc(sizeof(type))) +#define ynew_array(type, len) ((type*)ymalloc((len) * sizeof(type))) +#define ynew_and_zero(type) ((type*)ymalloc_and_zero(sizeof(type))) +#define ynew_array_and_zero(type, len) \ + ((type*)ymalloc_and_zero((len) * sizeof(type))) +#define YREALLOC_ARRAY(ptr, type, len) \ + ((void)(ptr = (type *)yrealloc(ptr, (len) * sizeof (type)))) + +#if defined HAVE_BDWGC && defined EF_USE_BDWGC +/* and now the x* series */ +# define xmalloc zmalloc +# define xcalloc zcalloc +# define xmalloc_atomic zmalloc_atomic +# define xmalloc_and_zero zmalloc_and_zero +# define xrealloc zrealloc +# define xstrdup zstrdup +# if defined ERROR_CHECK_MALLOC +# define xfree(args...) zfree(args) +# else /* !ERROR_CHECK_MALLOC */ +# define xfree(args...) +# endif /* ERROR_CHECK_MALLOC */ + +#else /* !BDWGC */ +void *xmalloc(size_t size); +void *xmalloc_atomic(size_t size); +void *xmalloc_and_zero(size_t size); +void *xrealloc(void *, size_t size); +char *xstrdup(const char *); +# if defined ERROR_CHECK_MALLOC +# if SIZEOF_VOID_P == 4 +# define xfree(lvalue) \ + do { \ + void *volatile *xfree_ptr = \ + (void *volatile*) \ + ((volatile void*)&(lvalue)); \ + assert(*xfree_ptr != (void*)0xB00BB4BE); \ + yfree(*xfree_ptr); \ + *xfree_ptr = (void*)0xB00BB4BE; \ + } while (0) +# elif SIZEOF_VOID_P == 8 +# define xfree(lvalue) \ + do { \ + void *volatile *xfree_ptr = \ + (void *volatile*) \ + ((volatile void*)&(lvalue)); \ + assert(*xfree_ptr != (void*)0xCAFEBABEDEADBEEF); \ + yfree(*xfree_ptr); \ + *xfree_ptr = (void*)0xCAFEBABEDEADBEEF; \ + } while (0) +# else /* huh? */ +# error "Strange-arse system detected. Watch a movie, it\'s more fun!" +# endif +# else /* !ERROR_CHECK_MALLOC */ +# define xfree(args...) yfree(args) +# endif /* ERROR_CHECK_MALLOC */ +#endif /* BDWGC */ + + +#endif diff --git a/src/sxe-utils.h b/src/sxe-utils.h index 8bc985f..cdc2fd8 100644 --- a/src/sxe-utils.h +++ b/src/sxe-utils.h @@ -54,11 +54,17 @@ along with this program. If not, see . */ #else # define SXE_UNUSED(x) x #endif + #ifdef UNUSED #undef UNUSED #define UNUSED(x) SXE_UNUSED(x) #endif +#ifdef SXE_SET_UNUSED +#else +# define SXE_SET_UNUSED(x) ((void)(x)) +#endif + #ifdef WEAK_EXTERN #elif defined(__GNUC__) # define WEAK_EXTERN extern __attribute__((weak)) @@ -78,6 +84,7 @@ along with this program. If not, see . */ #else #define LIKELY(_x) __builtin_expect(!!(_x), 1) #endif + #ifdef UNLIKELY #else #define UNLIKELY(_x) __builtin_expect(!!(_x), 0) @@ -101,13 +108,12 @@ along with this program. If not, see . */ #define SXE_CRITICAL(args...) __SXE_DEBUG__("CRITICAL: " args) - /* We define assert iff USE_ASSERTIONS or DEBUG_SXEMACS is defined. Otherwise we define it to be empty. Quantify has shown that the time the assert checks take is measurable so let's not include them in production binaries. */ -#ifdef USE_ASSERTIONS +#if defined(USE_ASSERTIONS) && defined(emacs) /* Highly dubious kludge */ /* (thanks, Jamie, I feel better now -- ben) */ void assert_failed(const char *, int, const char *); @@ -117,7 +123,7 @@ void assert_failed(const char *, int, const char *); # ifdef DEBUG_SXEMACS # define assert(x) ((x) ? (void) 0 : (void) abort ()) # else -# define assert(x) +# define assert(x) ((void)0) # endif #endif @@ -143,21 +149,7 @@ void assert_failed(const char *, int, const char *); #endif -/* generally useful */ #define countof(x) ((int) (sizeof(x)/sizeof((x)[0]))) -#define xnew(type) ((type *) xmalloc (sizeof (type))) -#define xnew_atomic(type) ((type *) xmalloc_atomic (sizeof (type))) -#define xnew_array(type, len) ((type *) xmalloc ((len) * sizeof (type))) -#define xnew_atomic_array(type, len) \ - ((type*)xmalloc_atomic((len) * sizeof(type))) -#define xnew_and_zero(type) ((type *) xmalloc_and_zero (sizeof (type))) -#define xzero(lvalue) ((void) memset (&(lvalue), '\0', sizeof (lvalue))) -#define xnew_array_and_zero(type, len) \ - ((type*)xmalloc_and_zero ((len) * sizeof (type))) -#define xrealloc_array(ptr, type, len) \ - ((void) (ptr = (type *) xrealloc (ptr, (len) * sizeof (type)))) -#define XREALLOC_ARRAY xrealloc_array -#define alloca_array(type, len) ((type *) alloca ((len) * sizeof (type))) #if !defined HAVE_DECL_STRDUP extern char *strdup(const char *s); @@ -199,7 +191,7 @@ extern char *strdup(const char *s); #endif -/* No type has a greater alignment requirement than max_align_t. +/* No type has a greater alignment requirement than sxe_max_align_t. (except perhaps for types we don't use, like long double) */ typedef union { struct { @@ -214,7 +206,7 @@ typedef union { struct { double d; } d; -} max_align_t; +} sxe_max_align_t; #ifndef ALIGNOF # if defined (__GNUC__) && (__GNUC__ >= 2) @@ -254,143 +246,6 @@ template < typename T > struct alignment_trick { #define DECLARE_NOTHING struct nosuchstruct #endif - -/************************************************************************/ -/* Memory */ -/************************************************************************/ - -#ifdef ALL_DEBUG_FLAGS -#undef GC_DEBUG_FLAG -#define GC_DEBUG_FLAG -#endif - -#if !defined GC_DEBUG_FLAG -# define SXE_DEBUG_GC(args...) -#else -# define SXE_DEBUG_GC(args...) __SXE_DEBUG__("[gc] " args) -#endif -#define SXE_DEBUG_GC_PT(args...) SXE_DEBUG_GC("[pthread]: " args) -#define SXE_CRITICAL_GC(args...) __SXE_DEBUG__("[gc] CRITICAL: " args) - -void malloc_warning(const char *); - -#if defined HAVE_BDWGC && defined EF_USE_BDWGC -# if defined HAVE_THREADS -# if !defined GC_PTHREADS -# define GC_PTHREADS 1 -# endif /* !GC_PTHREADS */ -# if !defined GC_THREADS -# define GC_THREADS 1 -# endif /* !GC_THREADS */ -# endif /* HAVE_THREADS */ - -# undef GC_DEBUG -# if defined GC_DEBUG_FLAG -# define GC_DEBUG 1 -# endif /* GC_DEBUG_FLAG */ -# if defined HAVE_GC_GC_H -# include -# elif defined HAVE_GC_H -# include -# else -# error "Take less of those pills!" -# endif - -# if defined GC_DEBUG_FLAG -# define zmalloc GC_MALLOC_IGNORE_OFF_PAGE -# define zcalloc(n, m) GC_MALLOC((n)*(m)) -# define zmalloc_atomic GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE -# define zmalloc_and_zero GC_MALLOC -# define zrealloc GC_REALLOC -# define zstrdup GC_STRDUP -# undef zfree -# define zfree(x) GC_FREE(x) -# else /* !GC_DEBUG_FLAG */ -# define zmalloc GC_malloc_ignore_off_page -# define zcalloc(n, m) GC_malloc((n)*(m)) -# define zmalloc_atomic GC_malloc_atomic_ignore_off_page -# define zmalloc_and_zero GC_malloc -# define zrealloc GC_realloc -# define zstrdup GC_strdup -# undef zfree -# define zfree(x) -# endif /* GC_DEBUG_FLAG */ - -#else /* !BDWGC */ -#define zmalloc F&^! -#define zcalloc F&^! -#define zmalloc_atomic F&^! -#define zmalloc_and_zero F&^! -#define zrealloc F&^! -#define zstrdrup F&^! -#endif /* BDWGC */ - -/* also define libc mem funs */ -#define ymalloc malloc -#define ycalloc(n, m) calloc(n, m) -#define ymalloc_atomic(n) ycalloc(1, n) -#define ymalloc_and_zero(x) ycalloc(1, x) -#define yrealloc realloc -#define ystrdup strdup -#define yfree(x) free(x) -/* and their convenience companions */ -#define ynew(type) ((type*)ymalloc(sizeof(type))) -#define ynew_array(type, len) ((type*)ymalloc((len) * sizeof(type))) -#define ynew_and_zero(type) ((type*)ymalloc_and_zero(sizeof(type))) -#define ynew_array_and_zero(type, len) \ - ((type*)ymalloc_and_zero((len) * sizeof(type))) -#define YREALLOC_ARRAY(ptr, type, len) \ - ((void)(ptr = (type *)yrealloc(ptr, (len) * sizeof (type)))) - -#if defined HAVE_BDWGC && defined EF_USE_BDWGC -/* and now the x* series */ -# define xmalloc zmalloc -# define xcalloc zcalloc -# define xmalloc_atomic zmalloc_atomic -# define xmalloc_and_zero zmalloc_and_zero -# define xrealloc zrealloc -# define xstrdup zstrdup -# if defined ERROR_CHECK_MALLOC -# define xfree(args...) zfree(args) -# else /* !ERROR_CHECK_MALLOC */ -# define xfree(args...) -# endif /* ERROR_CHECK_MALLOC */ - -#else /* !BDWGC */ -void *xmalloc(size_t size); -void *xmalloc_atomic(size_t size); -void *xmalloc_and_zero(size_t size); -void *xrealloc(void *, size_t size); -char *xstrdup(const char *); -# if defined ERROR_CHECK_MALLOC -# if SIZEOF_VOID_P == 4 -# define xfree(lvalue) \ - do { \ - void *volatile *xfree_ptr = \ - (void *volatile*) \ - ((volatile void*)&(lvalue)); \ - assert(*xfree_ptr != (void*)0xB00BB4BE); \ - yfree(*xfree_ptr); \ - *xfree_ptr = (void*)0xB00BB4BE; \ - } while (0) -# elif SIZEOF_VOID_P == 8 -# define xfree(lvalue) \ - do { \ - void *volatile *xfree_ptr = \ - (void *volatile*) \ - ((volatile void*)&(lvalue)); \ - assert(*xfree_ptr != (void*)0xCAFEBABEDEADBEEF); \ - yfree(*xfree_ptr); \ - *xfree_ptr = (void*)0xCAFEBABEDEADBEEF; \ - } while (0) -# else /* huh? */ -# error "Strange-arse system detected. Watch a movie, it\'s more fun!" -# endif -# else /* !ERROR_CHECK_MALLOC */ -# define xfree(args...) yfree(args) -# endif /* ERROR_CHECK_MALLOC */ -#endif /* BDWGC */ - /* str funs */ #define xstrlen strlen diff --git a/src/sxemacs.h b/src/sxemacs.h index 9cec2e3..f551f27 100644 --- a/src/sxemacs.h +++ b/src/sxemacs.h @@ -81,7 +81,7 @@ #if defined USE_SXEMACS_CONFIG_H # include "config.h" #endif -#include "sxe-utils.h" + #include "lisp.h" #include "sysfile.h" diff --git a/src/sysdep.c b/src/sysdep.c index 7ffad2f..0828973 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -1371,6 +1371,7 @@ static void tty_init_sys_modes_on_device(struct device *d) input_fd = CONSOLE_TTY_DATA(con)->infd; output_fd = CONSOLE_TTY_DATA(con)->outfd; + SXE_SET_UNUSED(output_fd); emacs_get_tty(input_fd, &CONSOLE_TTY_DATA(con)->old_tty); tty = CONSOLE_TTY_DATA(con)->old_tty; @@ -1725,6 +1726,7 @@ static void tty_reset_sys_modes_on_device(struct device *d) input_fd = CONSOLE_TTY_DATA(con)->infd; output_fd = CONSOLE_TTY_DATA(con)->outfd; + SXE_SET_UNUSED(output_fd); #if defined (IBMR2AIX) && defined (AIXHFT) { diff --git a/src/ui/TTY/terminfo.c b/src/ui/TTY/terminfo.c index 111f5d7..ae5a8b8 100644 --- a/src/ui/TTY/terminfo.c +++ b/src/ui/TTY/terminfo.c @@ -64,7 +64,7 @@ along with this program. If not, see . */ is equally lame in that it supplies "fixed" headers for curses.h but not term.h.) However, it seems to work to just not include term.h under Solaris, so we try that. KLUDGE! */ -#ifdef TERN_H_FILE +#ifdef TERM_H_FILE #if !(defined (__GNUC__) && defined (SOLARIS2)) #include TERM_H_FILE #endif diff --git a/src/ui/X11/dialog-x.c b/src/ui/X11/dialog-x.c index dfcfa84..74267d0 100644 --- a/src/ui/X11/dialog-x.c +++ b/src/ui/X11/dialog-x.c @@ -146,6 +146,8 @@ static widget_value *dbox_descriptor_to_widget_value(Lisp_Object keys) } } + SXE_SET_UNUSED(title); + if (NILP(question)) syntax_error("Dialog descriptor provides no question", keys); diff --git a/src/ui/X11/event-Xt.c b/src/ui/X11/event-Xt.c index ae10350..486046e 100644 --- a/src/ui/X11/event-Xt.c +++ b/src/ui/X11/event-Xt.c @@ -600,13 +600,18 @@ whatever(Display *dspl, struct x_device *xd, struct mod_clo_s *clo) [modifier_index * mkpm + modifier_key]; for (int column = 0; column < 4; column += 2) { - KeySym sym = code #ifdef HAVE_XKBKEYCODETOKEYSYM - ? XkbKeycodeToKeysym(dspl, code, 0, column) + KeySym sym = code + ? XkbKeycodeToKeysym(dspl, code, 0, column) + : 0; #else - ? XKeycodeToKeysym(dspl, code, column) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + KeySym sym = code + ? XKeycodeToKeysym(dspl, code, column) + : 0; +#pragma GCC diagnostic pop #endif - : 0; if (LIKELY(sym == last_sym)) { continue; diff --git a/src/ui/X11/glyphs-x.c b/src/ui/X11/glyphs-x.c index 1b30874..0bcf79e 100644 --- a/src/ui/X11/glyphs-x.c +++ b/src/ui/X11/glyphs-x.c @@ -2364,7 +2364,7 @@ x_widget_instantiate(Lisp_Object image_instance, Lisp_Object instantiator, struct device *d = XDEVICE(device); Lisp_Object frame = DOMAIN_FRAME(domain); struct frame *f = XFRAME(frame); - char *nm = 0; + char *nm = 0; // unused Widget wid; Arg al[32]; int ac = 0; @@ -2384,6 +2384,8 @@ x_widget_instantiate(Lisp_Object image_instance, Lisp_Object instantiator, LISP_STRING_TO_EXTERNAL(IMAGE_INSTANCE_WIDGET_TEXT(ii), nm, Qnative); + SXE_SET_UNUSED(nm); + ii->data = xnew_and_zero(struct x_subwindow_data); /* Create a clip window to contain the subwidget. Incredibly the diff --git a/src/ui/X11/gui-x.c b/src/ui/X11/gui-x.c index 33d1217..4e6db7f 100644 --- a/src/ui/X11/gui-x.c +++ b/src/ui/X11/gui-x.c @@ -499,12 +499,16 @@ button_item_to_widget_value(Lisp_Object gui_object_instance, if (NILP(pgui->style)) { Bufbyte *intname = NULL; Bytecount intlen; + /* If the callback is nil, treat this item like unselectable text. This way, dashes will show up as a separator. */ if (!wv->enabled) wv->type = BUTTON_TYPE; TO_INTERNAL_FORMAT(C_STRING, wv->name, ALLOCA, (intname, intlen), Qlwlib_encoding); + + SXE_SET_UNUSED(intlen); + if (intname != NULL && separator_string_p(intname)) { wv->type = SEPARATOR_TYPE; wv->value = diff --git a/src/ui/X11/objects-x.c b/src/ui/X11/objects-x.c index 2f17329..8348f19 100644 --- a/src/ui/X11/objects-x.c +++ b/src/ui/X11/objects-x.c @@ -804,6 +804,8 @@ static Lisp_Object x_font_instance_properties(Lisp_Font_Instance * f) ALLOCA, (name_str, name_len), Qx_atom_name_encoding); + SXE_SET_UNUSED(name_len); + name = (name_str ? intern((char *)name_str) : Qnil); if (name_str && (atom == XA_FONT || diff --git a/src/ui/lwlib/lwlib-Xlw.c b/src/ui/lwlib/lwlib-Xlw.c index 9b98877..3174d55 100644 --- a/src/ui/lwlib/lwlib-Xlw.c +++ b/src/ui/lwlib/lwlib-Xlw.c @@ -568,6 +568,9 @@ xlw_update_one_widget(widget_instance * instance, Widget widget, composite.children[0]; else mw = (XlwMenuWidget) widget; + + SXE_SET_UNUSED(mw); + XtSetArg(al[0], XtNmenu, val); XtSetValues(widget, al, 1); /* #### mw unused! */ } diff --git a/src/ui/lwlib/lwlib-internal.h b/src/ui/lwlib/lwlib-internal.h index 2817026..49cb179 100644 --- a/src/ui/lwlib/lwlib-internal.h +++ b/src/ui/lwlib/lwlib-internal.h @@ -2,20 +2,7 @@ #define INCLUDED_lwlib_internal_h_ #include "lwlib.h" - -#ifdef USE_ASSERTIONS -/* Highly dubious kludge */ -/* (thanks, Jamie, I feel better now -- ben) */ -void assert_failed(const char *, int, const char *); -# define abort() (assert_failed (__FILE__, __LINE__, "abort()")) -# define assert(x) ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, #x)) -#else -# ifdef DEBUG_XEMACS -# define assert(x) ((x) ? (void) 0 : (void) abort ()) -# else -# define assert(x) -# endif -#endif +#include "sxe-utils.h" /* This represents a single widget within a widget tree. All the widgets in a widget tree are chained through the `next' field. diff --git a/src/ui/lwlib/lwlib.c b/src/ui/lwlib/lwlib.c index 7748709..b23e76d 100644 --- a/src/ui/lwlib/lwlib.c +++ b/src/ui/lwlib/lwlib.c @@ -500,6 +500,12 @@ static Boolean safe_strcmp(const char *s1, const char *s2) return (s1 && s2) ? strcmp(s1, s2) : s1 ? False : !!s2; } + +/* We only expect to use the following max function */ +#ifdef max +#undef max +#endif + static change_type max(change_type i1, change_type i2) { return (int)i1 > (int)i2 ? i1 : i2; diff --git a/src/ui/lwlib/xlwcheckbox.c b/src/ui/lwlib/xlwcheckbox.c index 758799a..56b5b75 100644 --- a/src/ui/lwlib/xlwcheckbox.c +++ b/src/ui/lwlib/xlwcheckbox.c @@ -39,6 +39,8 @@ along with this program. If not, see . */ #include "ui/X11/xmu.h" #include "xlwcheckboxP.h" +#include "sxe-utils.h" + /* by using the same size for the checkbox as for the diamond box, * we can let the Radio widget do the vast majority of the work. */ @@ -392,6 +394,7 @@ static void DrawCheck(Widget w) pts[5].y = -s; XFillPolygon(dpy, win, bot, pts, 6, Nonconvex, CoordModePrevious); #else + SXE_SET_UNUSED(bw); XDrawRectangle(dpy, win, gc, bx + s, by + s, bsz, bsz); #endif diff --git a/src/ui/lwlib/xlwgauge.c b/src/ui/lwlib/xlwgauge.c index 07dbebc..4e1e5ec 100644 --- a/src/ui/lwlib/xlwgauge.c +++ b/src/ui/lwlib/xlwgauge.c @@ -380,6 +380,8 @@ static void GaugeExpose(Widget w, XEvent * event, Region region) hgt = gw->core.width; } + SXE_SET_UNUSED(hgt); + /* if the gauge is selected, signify by drawing the background * in a contrasting color. */ diff --git a/src/ui/lwlib/xlwmenu.c b/src/ui/lwlib/xlwmenu.c index dae3ca5..8e61905 100644 --- a/src/ui/lwlib/xlwmenu.c +++ b/src/ui/lwlib/xlwmenu.c @@ -47,17 +47,12 @@ along with this program. If not, see . */ #include "lwlib-internal.h" #include +#include #ifdef USE_DEBUG_MALLOC #include #endif - -/* simple, naive integer maximum */ -#ifndef max -#define max(a,b) ((a)>(b)?(a):(b)) -#endif - static char xlwMenuTranslations[] = ": start()\n\ : drag()\n\ diff --git a/src/ui/lwlib/xlwtabs.c b/src/ui/lwlib/xlwtabs.c index bcafe58..ce5d2b1 100644 --- a/src/ui/lwlib/xlwtabs.c +++ b/src/ui/lwlib/xlwtabs.c @@ -572,6 +572,7 @@ static void TabsResize(Widget w) tab = (TabsConstraints) (*childP)->core. constraints; + SXE_SET_UNUSED(tab); bw = (*childP)->core.border_width; /* Don't do anything if we can't see any of the child. */ if (ch >= bw * 2 && ch > 0 && cw >= bw * 2 diff --git a/src/ui/specifier.c b/src/ui/specifier.c index 1d0205f..a9770c4 100644 --- a/src/ui/specifier.c +++ b/src/ui/specifier.c @@ -336,7 +336,7 @@ inline static size_t aligned_sizeof_specifier(size_t specifier_type_specific_size) { return ALIGN_SIZE(offsetof(Lisp_Specifier, data) - + specifier_type_specific_size, ALIGNOF(max_align_t)); + + specifier_type_specific_size, ALIGNOF(sxe_max_align_t)); } static size_t sizeof_specifier(const void *header)