From b312a4929d4ed7bc900a54f506905801f860ce7c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 7 Jul 2011 15:45:25 -0700 Subject: [PATCH] * emacs.c: Integer overflow minor fix. (heap_bss_diff): Now uprintmax_t, not unsigned long. All used changed. Define only if GNU_LINUX. (main, Fdump_emacs): Set and use heap_bss_diff only if GNU_LINUX. --- src/ChangeLog | 5 +++++ src/emacs.c | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index e2cf24fc173..0265828c60e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2011-07-07 Paul Eggert + * emacs.c: Integer overflow minor fix. + (heap_bss_diff): Now uprintmax_t, not unsigned long. All used changed. + Define only if GNU_LINUX. + (main, Fdump_emacs): Set and use heap_bss_diff only if GNU_LINUX. + * dispnew.c: Integer signedness and overflow fixes. Remove unnecessary forward decls, that were a maintenance hassle. (history_tick): Now uprintmax_t, so it's more likely to avoid overflow. diff --git a/src/emacs.c b/src/emacs.c index e4b3a68a6c1..6f6d1babd03 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -166,8 +166,10 @@ char *stack_bottom; /* The address where the heap starts (from the first sbrk (0) call). */ static void *my_heap_start; +#ifdef GNU_LINUX /* The gap between BSS end and heap start as far as we can tell. */ -static unsigned long heap_bss_diff; +static uprintmax_t heap_bss_diff; +#endif /* Nonzero means running Emacs without interactive terminal. */ int noninteractive; @@ -713,6 +715,7 @@ main (int argc, char **argv) setenv ("G_SLICE", "always-malloc", 1); #endif +#ifdef GNU_LINUX if (!initialized) { extern char my_endbss[]; @@ -723,6 +726,7 @@ main (int argc, char **argv) heap_bss_diff = (char *)my_heap_start - max (my_endbss, my_endbss_static); } +#endif #ifdef RUN_TIME_REMAP if (initialized) @@ -2131,7 +2135,7 @@ You must run Emacs in batch mode in order to dump it. */) { fprintf (stderr, "**************************************************\n"); fprintf (stderr, "Warning: Your system has a gap between BSS and the\n"); - fprintf (stderr, "heap (%lu bytes). This usually means that exec-shield\n", + fprintf (stderr, "heap (%"pMu" bytes). This usually means that exec-shield\n", heap_bss_diff); fprintf (stderr, "or something similar is in effect. The dump may\n"); fprintf (stderr, "fail because of this. See the section about\n"); -- 2.39.2