I only explicitly look at sizeof(long) if it differs from sizeof(int)
authorDima Kogan <dima@secretsauce.net>
Sun, 11 May 2014 19:22:00 +0000 (12:22 -0700)
committerChanho Park <chanho61.park@samsung.com>
Fri, 22 Aug 2014 11:38:26 +0000 (20:38 +0900)
If they're the same, checking for both in a switch() is a compile error

dwarf_prototypes.c

index 9ae22ca..96df5b0 100644 (file)
@@ -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