[ltrace-commits] 37/40: I only explicitly look at sizeof(long) if it differs from sizeof(int)

Petr Machata pmachata-guest at moszumanska.debian.org
Sun May 11 22:38:55 UTC 2014


This is an automated email from the git hooks/post-receive script.

pmachata-guest pushed a commit to branch master
in repository ltrace.

commit 333181f4db7da511215fc873fe80331d697177a4
Author: Dima Kogan <dima at secretsauce.net>
Date:   Sun May 11 12:22:00 2014 -0700

    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
---
 dwarf_prototypes.c | 19 +++++++++++--------
 1 file 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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/ltrace.git



More information about the ltrace-commits mailing list