From: Dima Kogan Date: Sun, 11 May 2014 19:22:00 +0000 (-0700) Subject: I only explicitly look at sizeof(long) if it differs from sizeof(int) X-Git-Tag: accepted/tizen/common/20140822.152031~49 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2fbde7a83cd8c5a5fcb792112797d5063b719797;p=platform%2Fupstream%2Fltrace.git I only explicitly look at sizeof(long) if it differs from sizeof(int) If they're the same, checking for both in a switch() is a compile error --- diff --git a/dwarf_prototypes.c b/dwarf_prototypes.c index 9ae22ca..96df5b0 100644 --- a/dwarf_prototypes.c +++ b/dwarf_prototypes.c @@ -171,26 +171,29 @@ static bool get_die_numeric(uint64_t *result, static bool get_integer_base_type(enum arg_type *type, int byte_size, bool is_signed) { - switch (byte_size) { - case sizeof(char): + // not using a switch() here because sizeof(int) == sizeof(long) on some + // architectures, and removing that case for those arches is a pain + if (byte_size == sizeof(char)) { *type = ARGTYPE_CHAR; return true; + } - case sizeof(short): + if (byte_size == sizeof(short)) { *type = is_signed ? ARGTYPE_SHORT : ARGTYPE_USHORT; return true; + } - case sizeof(int): + if (byte_size == sizeof(int)) { *type = is_signed ? ARGTYPE_INT : ARGTYPE_UINT; return true; + } - case sizeof(long): + if (byte_size == sizeof(long)) { *type = is_signed ? ARGTYPE_LONG : ARGTYPE_ULONG; return true; - - default: - return false; } + + return false; } // returns an ltrace ARGTYPE_XXX base type from the given die. If we dont