From 3a6ce5457f36d6295f94fe283899ec88ec5b6dc7 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sun, 6 Sep 2009 01:42:24 -0700 Subject: [PATCH] Fix bugs identified by clang analyzer. --- src/microcode/bignum.c | 6 +++--- src/microcode/cmpint.c | 2 -- src/microcode/findprim.c | 5 +---- src/microcode/gcloop.c | 4 ++-- src/microcode/transact.c | 2 ++ src/microcode/utils.c | 1 + src/microcode/wind.c | 2 ++ src/microcode/x11base.c | 5 +++-- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/microcode/bignum.c b/src/microcode/bignum.c index ba32c04f8..bb3b8ca1b 100644 --- a/src/microcode/bignum.c +++ b/src/microcode/bignum.c @@ -611,7 +611,7 @@ bignum_to_double (bignum_type bignum) { bignum_length_type length = (BIGNUM_LENGTH (bignum)); bignum_length_type index = length - 1; - bignum_length_type scale_words = length - 1; + bignum_length_type scale_words; bignum_digit_type msd = (BIGNUM_REF (bignum, (index))); #if (FLT_RADIX == 2) int bits_to_get = DBL_MANT_DIG; /* includes implicit 1 */ @@ -1601,8 +1601,8 @@ bignum_digit_divide (bignum_digit_type uh, bignum_digit_type ul, { bignum_digit_type guess; bignum_digit_type comparand; - bignum_digit_type v1 = (HD_HIGH (v)); - bignum_digit_type v2 = (HD_LOW (v)); + bignum_digit_type v1; + bignum_digit_type v2; bignum_digit_type uj; bignum_digit_type uj_uj1; bignum_digit_type q1; diff --git a/src/microcode/cmpint.c b/src/microcode/cmpint.c index 15d82e7f7..52e0c6ee6 100644 --- a/src/microcode/cmpint.c +++ b/src/microcode/cmpint.c @@ -2311,7 +2311,6 @@ make_uuo_link (SCHEME_OBJECT procedure, { SCHEME_OBJECT * cache_address = (MEMORY_LOC (block, offset)); unsigned long frame_size = (read_uuo_frame_size (cache_address)); - SCHEME_OBJECT orig_proc; trampoline_type_t kind; long result; SCHEME_OBJECT trampoline; @@ -2319,7 +2318,6 @@ make_uuo_link (SCHEME_OBJECT procedure, if (REFERENCE_TRAP_P (procedure)) return (make_fake_uuo_link (cache, block, offset)); - orig_proc = procedure; loop: switch (OBJECT_TYPE (procedure)) { diff --git a/src/microcode/findprim.c b/src/microcode/findprim.c index 98da359e3..92469458f 100644 --- a/src/microcode/findprim.c +++ b/src/microcode/findprim.c @@ -417,7 +417,7 @@ scan (void) else { ungetc (c, input); - (*scan_buffer++) = '\0'; + (*scan_buffer) = '\0'; break; } } @@ -519,12 +519,9 @@ print_procedure (FILE * output, void print_primitives (FILE * output, int limit) { - int last; int count; char * table_entry; - last = (limit - 1); - /* Print the procedure table. */ fprintf (output, diff --git a/src/microcode/gcloop.c b/src/microcode/gcloop.c index 10d76bf68..d402fe451 100644 --- a/src/microcode/gcloop.c +++ b/src/microcode/gcloop.c @@ -119,8 +119,8 @@ static SCHEME_OBJECT * weak_chain; static void run_gc_loop (SCHEME_OBJECT * , SCHEME_OBJECT **); static SCHEME_OBJECT gc_transport_weak_pair (SCHEME_OBJECT); -static void tospace_closed (void); -static void tospace_open (void); +static void tospace_closed (void) NORETURN; +static void tospace_open (void) NORETURN; #ifdef ENABLE_GC_DEBUGGING_TOOLS # ifndef GC_SCAN_HISTORY_SIZE diff --git a/src/microcode/transact.c b/src/microcode/transact.c index 824dfa571..558d24d0c 100644 --- a/src/microcode/transact.c +++ b/src/microcode/transact.c @@ -27,6 +27,8 @@ USA. #include "outf.h" #include "dstack.h" +static void error (const char *, const char *) NORETURN; + static void error (const char * procedure_name, const char * message) { diff --git a/src/microcode/utils.c b/src/microcode/utils.c index 340c1bced..a4d9b12e2 100644 --- a/src/microcode/utils.c +++ b/src/microcode/utils.c @@ -39,6 +39,7 @@ SCHEME_OBJECT * history_register; unsigned long prev_restore_history_offset; static SCHEME_OBJECT copy_history (SCHEME_OBJECT); +static void error_death (long, char *) NORETURN; /* Helper procedures for setup_interrupt, which follows. */ diff --git a/src/microcode/wind.c b/src/microcode/wind.c index e2e4e4dda..dfb4da4be 100644 --- a/src/microcode/wind.c +++ b/src/microcode/wind.c @@ -34,6 +34,8 @@ USA. extern void block_signals (void); extern void unblock_signals (void); +static void error (const char *, const char *) NORETURN; + static void error (const char * procedure_name, const char * message) { diff --git a/src/microcode/x11base.c b/src/microcode/x11base.c index 08ab6f417..212602e81 100644 --- a/src/microcode/x11base.c +++ b/src/microcode/x11base.c @@ -1067,8 +1067,7 @@ enum event_type ((arg), (1 << ((unsigned int) event_type_supremum)))) #define EVENT_ENABLED(xw, type) \ - (((xw) == 0) \ - || (((XW_EVENT_MASK (xw)) & (1 << ((unsigned int) (type)))) != 0)) + (((XW_EVENT_MASK (xw)) & (1 << ((unsigned int) (type)))) != 0) #define EVENT_0 2 #define EVENT_1 3 @@ -1213,6 +1212,8 @@ x_event_to_object (XEvent * event) = (x_window_to_xw (((event->xany) . display), ((event->xany) . window))); SCHEME_OBJECT result = SHARP_F; + if (xw == 0) + return result; switch (event->type) { case KeyPress: -- 2.25.1