winedump: Use BOOL type where appropriate
Frédéric Delanoy
frederic.delanoy at gmail.com
Mon Jan 13 14:44:00 CST 2014
Note: symbol_demangle made to return TRUE/FALSE on success/failure respectively, for
consistency with the rest of the codebase
Final BOOL cleanup patch for winedump. Phew!
---
tools/winedump/dump.c | 2 +-
tools/winedump/main.c | 9 +++------
tools/winedump/msmangle.c | 34 +++++++++++++++++-----------------
tools/winedump/winedump.h | 2 +-
4 files changed, 22 insertions(+), 25 deletions(-)
diff --git a/tools/winedump/dump.c b/tools/winedump/dump.c
index f263390..7ca4dc0 100644
--- a/tools/winedump/dump.c
+++ b/tools/winedump/dump.c
@@ -154,7 +154,7 @@ const char* get_symbol_str(const char* symname)
parsed_symbol symbol;
symbol_init(&symbol, symname);
- if (symbol_demangle(&symbol) == -1)
+ if (!symbol_demangle(&symbol))
ret = symname;
else if (symbol.flags & SYM_DATA)
{
diff --git a/tools/winedump/main.c b/tools/winedump/main.c
index ca2047b..dfd15b0 100644
--- a/tools/winedump/main.c
+++ b/tools/winedump/main.c
@@ -444,17 +444,14 @@ int main (int argc, char *argv[])
if (globals.do_code && symbol_searched(count, symbol.symbol))
{
/* Attempt to get information about the symbol */
- int result = symbol_demangle (&symbol);
+ BOOL result = symbol_demangle (&symbol) || symbol_search(&symbol);
- if (result)
- result = !symbol_search (&symbol);
-
- if (!result && symbol.function_name)
+ if (result && symbol.function_name)
/* Clean up the prototype */
symbol_clean_string (symbol.function_name);
if (NORMAL)
- puts (result ? "[Not Found]" : "[OK]");
+ puts (result ? "[OK]" : "[Not Found]");
}
else if (NORMAL)
puts ("[Ignoring]");
diff --git a/tools/winedump/msmangle.c b/tools/winedump/msmangle.c
index a0d9f92..39e4f3a 100644
--- a/tools/winedump/msmangle.c
+++ b/tools/winedump/msmangle.c
@@ -63,7 +63,7 @@ static char *get_pointer_type_string (compound_type *ct,
*
* Demangle a C++ linker symbol into a C prototype
*/
-int symbol_demangle (parsed_symbol *sym)
+BOOL symbol_demangle (parsed_symbol *sym)
{
compound_type ct;
BOOL is_static = FALSE;
@@ -83,7 +83,7 @@ int symbol_demangle (parsed_symbol *sym)
/* MS mangled names always begin with '?' */
name = sym->symbol;
if (*name++ != '?')
- return -1;
+ return FALSE;
if (VERBOSE)
puts ("Attempting to demangle symbol");
@@ -162,12 +162,12 @@ int symbol_demangle (parsed_symbol *sym)
case 'X': function_name = strdup ("placement_new_closure"); break;
case 'Y': function_name = strdup ("placement_delete_closure"); break;
default:
- return -1;
+ return FALSE;
}
break;
default:
/* FIXME: Other operators */
- return -1;
+ return FALSE;
}
name++;
}
@@ -177,7 +177,7 @@ int symbol_demangle (parsed_symbol *sym)
function_name = name;
while (*name && *name++ != '@') ;
if (!*name)
- return -1;
+ return FALSE;
function_name = str_substring (function_name, name - 1);
}
@@ -194,7 +194,7 @@ int symbol_demangle (parsed_symbol *sym)
while (*name && *name++ != '@') ;
if (*name++ != '@') {
free (function_name);
- return -1;
+ return FALSE;
}
class_name = str_substring (class_name, name - 2); /* Allocates a new string */
}
@@ -220,7 +220,7 @@ int symbol_demangle (parsed_symbol *sym)
printf ("/*FIXME: %s: unknown data*/\n", sym->symbol);
free (function_name);
free (class_name);
- return -1;
+ return FALSE;
}
sym->flags |= SYM_DATA;
sym->argc = 1;
@@ -230,7 +230,7 @@ int symbol_demangle (parsed_symbol *sym)
FREE_CT (ct);
free (function_name);
free (class_name);
- return 0;
+ return TRUE;
case '6' : /* compiler generated static */
case '7' : /* compiler generated static */
@@ -246,11 +246,11 @@ int symbol_demangle (parsed_symbol *sym)
puts ("Demangled symbol OK [vtable]");
free (function_name);
free (class_name);
- return 0;
+ return TRUE;
}
free (function_name);
free (class_name);
- return -1;
+ return FALSE;
/* Functions */
@@ -295,7 +295,7 @@ int symbol_demangle (parsed_symbol *sym)
default:
free (function_name);
free (class_name);
- return -1;
+ return FALSE;
}
/* If there is an implicit this pointer, const status follows */
@@ -310,7 +310,7 @@ int symbol_demangle (parsed_symbol *sym)
default:
free (function_name);
free (class_name);
- return -1;
+ return FALSE;
}
}
@@ -342,7 +342,7 @@ int symbol_demangle (parsed_symbol *sym)
default:
free (function_name);
free (class_name);
- return -1;
+ return FALSE;
}
/* Return type, or @ if 'void' */
@@ -358,7 +358,7 @@ int symbol_demangle (parsed_symbol *sym)
if (!demangle_datatype (&name, &ct, sym)) {
free (function_name);
free (class_name);
- return -1;
+ return FALSE;
}
sym->return_text = ct.expression;
sym->return_type = get_type_constant(ct.dest_type, ct.flags);
@@ -376,7 +376,7 @@ int symbol_demangle (parsed_symbol *sym)
if (!demangle_datatype(&name, &ct, sym)) {
free (function_name);
free (class_name);
- return -1;
+ return FALSE;
}
if (strcmp (ct.expression, "void"))
@@ -405,7 +405,7 @@ int symbol_demangle (parsed_symbol *sym)
if (*name != 'Z') {
free (function_name);
free (class_name);
- return -1;
+ return FALSE;
}
/* Note: '()' after 'Z' means 'throws', but we don't care here */
@@ -433,7 +433,7 @@ int symbol_demangle (parsed_symbol *sym)
if (VERBOSE)
puts ("Demangled symbol OK");
- return 0;
+ return TRUE;
}
diff --git a/tools/winedump/winedump.h b/tools/winedump/winedump.h
index 754a7d2..88fa0e7 100644
--- a/tools/winedump/winedump.h
+++ b/tools/winedump/winedump.h
@@ -164,7 +164,7 @@ BOOL dll_next_symbol (parsed_symbol * sym);
/* Symbol functions */
void symbol_init(parsed_symbol* symbol, const char* name);
-int symbol_demangle (parsed_symbol *symbol);
+BOOL symbol_demangle (parsed_symbol *symbol);
BOOL symbol_search (parsed_symbol *symbol);
--
1.8.5.2
More information about the wine-patches
mailing list