diff options
author | Dima Kogan <dima@secretsauce.net> | 2014-05-11 12:22:00 -0700 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-08-22 20:38:26 +0900 |
commit | 2fbde7a83cd8c5a5fcb792112797d5063b719797 (patch) | |
tree | 43b87d36fd01220f11379501f2d233393d7e9eab | |
parent | 95e0b60f775501a88a22bfede44a024b641e00ee (diff) | |
download | ltrace-2fbde7a83cd8c5a5fcb792112797d5063b719797.tar.gz ltrace-2fbde7a83cd8c5a5fcb792112797d5063b719797.tar.bz2 ltrace-2fbde7a83cd8c5a5fcb792112797d5063b719797.zip |
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
-rw-r--r-- | dwarf_prototypes.c | 19 |
1 files changed, 11 insertions, 8 deletions
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 |