From 9e73c4e472a5a372d79e5716735b6557bee3f224 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 21 Nov 2013 09:55:26 +0100 Subject: [PATCH 1/1] Misc cleanups: remove unnecessary casts, use unsigned long for addresses. --- src/mc/mc_checkpoint.c | 20 ++++++++++---------- src/mc/mc_global.c | 8 ++++---- src/mc/mc_private.h | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/mc/mc_checkpoint.c b/src/mc/mc_checkpoint.c index 2b2fe9d033..ff1ad8a9a5 100644 --- a/src/mc/mc_checkpoint.c +++ b/src/mc/mc_checkpoint.c @@ -501,7 +501,7 @@ static xbt_dynar_t MC_get_local_variables_values(void *stack_context){ unw_word_t res; int frame_found = 0, region_type; void *frame_pointer_address = NULL; - long true_ip, value; + unsigned long true_ip, value; int stop = 0; xbt_dynar_t variables = xbt_dynar_new(sizeof(local_variable_t), local_variable_free_voidp); @@ -516,7 +516,7 @@ static xbt_dynar_t MC_get_local_variables_values(void *stack_context){ if(!strcmp(frame_name, "smx_ctx_sysv_wrapper")) /* Stop before context switch with maestro */ stop = 1; - if((long)ip > (long)start_text_libsimgrid) + if((uintptr_t)ip > (uintptr_t)start_text_libsimgrid) frame = xbt_dict_get_or_null(mc_local_variables_libsimgrid, frame_name); else frame = xbt_dict_get_or_null(mc_local_variables_binary, frame_name); @@ -526,7 +526,7 @@ static xbt_dynar_t MC_get_local_variables_values(void *stack_context){ continue; } - true_ip = (long)frame->low_pc + (long)off; + true_ip = (unsigned long)frame->low_pc + (unsigned long)off; frame_pointer_address = NULL; /* Get frame pointer */ @@ -546,11 +546,11 @@ static xbt_dynar_t MC_get_local_variables_values(void *stack_context){ switch(location_entry->type){ case e_dw_register: unw_get_reg(&c, location_entry->location.reg, &res); - frame_pointer_address = (void*)(long)res; + frame_pointer_address = (void*)(uintptr_t)res; break; case e_dw_bregister_op: unw_get_reg(&c, location_entry->location.breg_op.reg, &res); - frame_pointer_address = (void*)((long)res + location_entry->location.breg_op.offset); + frame_pointer_address = (void*)((uintptr_t)res + location_entry->location.breg_op.offset); break; default: frame_pointer_address = NULL; /* FIXME : implement other cases (with optimizations enabled) */ @@ -576,7 +576,7 @@ static xbt_dynar_t MC_get_local_variables_values(void *stack_context){ xbt_dynar_foreach(frame->variables, cursor, current_variable){ - if((long)ip > (long)start_text_libsimgrid) + if((uintptr_t)ip > (uintptr_t)start_text_libsimgrid) region_type = 1; else region_type = 2; @@ -599,15 +599,15 @@ static xbt_dynar_t MC_get_local_variables_values(void *stack_context){ switch(location_entry->type){ case e_dw_register: unw_get_reg(&c, location_entry->location.reg, &res); - value = (long)res; + value = (unsigned long)res; break; case e_dw_bregister_op: unw_get_reg(&c, location_entry->location.breg_op.reg, &res); - value = (long)res + location_entry->location.breg_op.offset; + value = (unsigned long)res + location_entry->location.breg_op.offset; break; case e_dw_fbregister_op: if(frame_pointer_address != NULL) - value = (long)((char *)frame_pointer_address + location_entry->location.fbreg_op); + value = (unsigned long)((char *)frame_pointer_address + location_entry->location.fbreg_op); else value = 0; break; @@ -654,7 +654,7 @@ static void *MC_get_stack_pointer(void *stack_context, void *heap){ unw_get_reg(&c, UNW_REG_SP, &sp); - return ((char *)heap + (size_t)(((char *)((long)sp) - (char*)std_heap))); + return (char *)heap + ((char *)sp - (char*)std_heap); } diff --git a/src/mc/mc_global.c b/src/mc/mc_global.c index 4ae023d8dd..2683d20961 100644 --- a/src/mc/mc_global.c +++ b/src/mc/mc_global.c @@ -184,7 +184,7 @@ static dw_location_t MC_dwarf_get_location(xbt_dict_t location_list, char *expr) if(location_list != NULL){ - char *key = bprintf("%d", (int)strtoul(expr, NULL, 16)); + char *key = bprintf("%lu", strtoul(expr, NULL, 16)); loc->type = e_dw_loclist; loc->location.loclist = (xbt_dynar_t)xbt_dict_get_or_null(location_list, key); if(loc->location.loclist == NULL) @@ -403,7 +403,7 @@ static xbt_dict_t MC_dwarf_get_location_list(const char *elf_file){ } - char *key = bprintf("%d", (int)strtoul((char *)xbt_dynar_get_as(split, 0, char *), NULL, 16)); + char *key = bprintf("%lu", strtoul((char *)xbt_dynar_get_as(split, 0, char *), NULL, 16)); xbt_dict_set(location_list, key, loclist, NULL); xbt_free(key); @@ -742,7 +742,7 @@ static void MC_dwarf_get_variables(const char *elf_file, xbt_dict_t location_lis xbt_dynar_free(&split2); split2 = xbt_str_split(loc_expr, " "); if(strcmp(elf_file, xbt_binary_name) != 0) - var->address.address = (char *)start_text_libsimgrid + (long)((void *)strtoul(xbt_dynar_get_as(split2, xbt_dynar_length(split2) - 1, char*), NULL, 16)); + var->address.address = (char *)start_text_libsimgrid + strtoul(xbt_dynar_get_as(split2, xbt_dynar_length(split2) - 1, char*), NULL, 16); else var->address.address = (void *)strtoul(xbt_dynar_get_as(split2, xbt_dynar_length(split2) - 1, char*), NULL, 16); }else{ @@ -755,7 +755,7 @@ static void MC_dwarf_get_variables(const char *elf_file, xbt_dict_t location_lis global_address = xbt_strdup(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char *)); xbt_str_rtrim(global_address, ")"); if(strcmp(elf_file, xbt_binary_name) != 0) - var->address.address = (char *)start_text_libsimgrid + (long)((void *)strtoul(global_address, NULL, 16)); + var->address.address = (char *)start_text_libsimgrid + strtoul(global_address, NULL, 16); else var->address.address = (void *)strtoul(global_address, NULL, 16); xbt_free(global_address); diff --git a/src/mc/mc_private.h b/src/mc/mc_private.h index 9e1db34965..cc581b9b32 100644 --- a/src/mc/mc_private.h +++ b/src/mc/mc_private.h @@ -397,8 +397,8 @@ typedef struct s_dw_location{ }s_dw_location_t, *dw_location_t; typedef struct s_dw_location_entry{ - long lowpc; - long highpc; + unsigned long lowpc; + unsigned long highpc; dw_location_t location; }s_dw_location_entry_t, *dw_location_entry_t; -- 2.20.1