From 7c5d24856794b213573f5e67bf138db144dac2eb Mon Sep 17 00:00:00 2001 From: cherierm Date: Mon, 22 Oct 2007 08:37:06 +0000 Subject: [PATCH] This, modify the declaration of type of function pointer. It also clear the warnings throws by the compiler Visual C++ when occurs a comparison between an unsigned with and a signed integer. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4837 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- include/xbt/dynar.h | 6 +++--- include/xbt/matrix.h | 6 +++--- src/amok/PeerManagement/peermanagement.c | 2 +- src/gras/DataDesc/ddt_create.c | 6 +++--- src/gras/Virtu/process.c | 2 +- src/gras/Virtu/sg_emul.c | 2 +- src/gras/gras.c | 2 +- src/surf/surf.c | 2 +- src/xbt/config.c | 4 ++-- src/xbt/cunit.c | 2 +- src/xbt/dict_multi.c | 6 +++--- src/xbt/dynar.c | 26 ++++++++++++------------ src/xbt/graph.c | 10 ++++----- src/xbt/heap.c | 2 +- src/xbt/mallocator.c | 8 ++++---- src/xbt/xbt_matrix.c | 14 ++++++------- src/xbt/xbt_str.c | 5 +++-- 17 files changed, 53 insertions(+), 52 deletions(-) diff --git a/include/xbt/dynar.h b/include/xbt/dynar.h index 5bb68dcc1b..74aed4e217 100644 --- a/include/xbt/dynar.h +++ b/include/xbt/dynar.h @@ -83,10 +83,10 @@ SG_BEGIN_DECL() * @{ */ - XBT_PUBLIC(void) xbt_dynar_get_cpy(const xbt_dynar_t dynar, const int idx, void * const dst); + XBT_PUBLIC(void) xbt_dynar_get_cpy(const xbt_dynar_t dynar, const unsigned long idx, void * const dst); XBT_PUBLIC(void) xbt_dynar_set(xbt_dynar_t dynar, const int idx, const void *src); - XBT_PUBLIC(void) xbt_dynar_replace(xbt_dynar_t dynar, const int idx, const void *object); + XBT_PUBLIC(void) xbt_dynar_replace(xbt_dynar_t dynar, const unsigned long idx, const void *object); XBT_PUBLIC(void) xbt_dynar_insert_at(xbt_dynar_t const dynar, const int idx, const void *src); XBT_PUBLIC(void) xbt_dynar_remove_at(xbt_dynar_t const dynar, const int idx, void * const dst); @@ -115,7 +115,7 @@ SG_BEGIN_DECL() * @{ */ - XBT_PUBLIC(void*) xbt_dynar_get_ptr(const xbt_dynar_t dynar, const int idx); + XBT_PUBLIC(void*) xbt_dynar_get_ptr(const xbt_dynar_t dynar, const unsigned long idx); XBT_PUBLIC(void*) xbt_dynar_insert_at_ptr(xbt_dynar_t const dynar, const int idx); XBT_PUBLIC(void*) xbt_dynar_push_ptr(xbt_dynar_t const dynar); XBT_PUBLIC(void*) xbt_dynar_pop_ptr(xbt_dynar_t const dynar); diff --git a/include/xbt/matrix.h b/include/xbt/matrix.h index 9a4742ab50..a224fa13e1 100644 --- a/include/xbt/matrix.h +++ b/include/xbt/matrix.h @@ -45,9 +45,9 @@ XBT_PUBLIC(void) xbt_matrix_free(xbt_matrix_t matrix); XBT_PUBLIC(void) xbt_matrix_free_voidp(void *d); XBT_PUBLIC(void) xbt_matrix_copy_values(xbt_matrix_t dest, xbt_matrix_t src, - int lsize, int rsize, - int lpos_dst,int rpos_dst, - int lpos_src,int rpos_src, + unsigned int lsize, unsigned int rsize, + unsigned int lpos_dst,unsigned int rpos_dst, + unsigned int lpos_src,unsigned int rpos_src, pvoid_f_pvoid_t const cpy_f); XBT_PUBLIC(void) xbt_matrix_dump(xbt_matrix_t matrix, const char *name, int coords, diff --git a/src/amok/PeerManagement/peermanagement.c b/src/amok/PeerManagement/peermanagement.c index f0ed25e27d..3eb016412c 100644 --- a/src/amok/PeerManagement/peermanagement.c +++ b/src/amok/PeerManagement/peermanagement.c @@ -265,7 +265,7 @@ static void _amok_pm_leave(void *p) { void amok_pm_modulecreate() { gras_module_add("amok_pm", sizeof(s_amok_pm_moddata_t), &amok_pm_moddata_id, - &_amok_pm_init,&_amok_pm_exit,&_amok_pm_join,&_amok_pm_leave); + _amok_pm_init,_amok_pm_exit,_amok_pm_join,_amok_pm_leave); } diff --git a/src/gras/DataDesc/ddt_create.c b/src/gras/DataDesc/ddt_create.c index 446a3a9487..0495574eb8 100644 --- a/src/gras/DataDesc/ddt_create.c +++ b/src/gras/DataDesc/ddt_create.c @@ -43,7 +43,7 @@ static gras_datadesc_type_t gras_ddt_new(const char *name) { res->cycle = 0; xbt_set_add(gras_datadesc_set_local, - (xbt_set_elm_t)res,&gras_ddt_freev); + (xbt_set_elm_t)res,gras_ddt_freev); XBT_OUT; return res; } @@ -177,7 +177,7 @@ gras_datadesc_type_t res->category_code = e_gras_datadesc_type_cat_struct; res->category.struct_data.fields = xbt_dynar_new(sizeof(gras_dd_cat_field_t), - &gras_dd_cat_field_free); + gras_dd_cat_field_free); XBT_OUT; return res; @@ -320,7 +320,7 @@ gras_datadesc_type_t res->category_code = e_gras_datadesc_type_cat_union; res->category.union_data.fields = xbt_dynar_new(sizeof(gras_dd_cat_field_t*), - &gras_dd_cat_field_free); + gras_dd_cat_field_free); res->category.union_data.selector = selector; return res; diff --git a/src/gras/Virtu/process.c b/src/gras/Virtu/process.c index b87a118e42..0e1050d0cd 100644 --- a/src/gras/Virtu/process.c +++ b/src/gras/Virtu/process.c @@ -144,7 +144,7 @@ gras_procdata_init() { THROW1(unknown_error,0,"MayDay: two modules use '%s' as libdata name", fab.name); /* Add the data in place, after some more sanity checking */ - elem = (*fab.constructor)(); + elem = (*(fab.constructor))(); if (elem->name_len && elem->name_len != strlen(elem->name)) { elem->name_len = strlen(elem->name); WARN1("Module '%s' constructor is borken: it does not set elem->name_len", diff --git a/src/gras/Virtu/sg_emul.c b/src/gras/Virtu/sg_emul.c index e44614f640..1f4305ecf4 100644 --- a/src/gras/Virtu/sg_emul.c +++ b/src/gras/Virtu/sg_emul.c @@ -26,7 +26,7 @@ static double reference = .00000000523066250047108838; /* FIXME: we should bench static double duration = 0.0; static char* locbuf = NULL; -static int locbufsize; +static unsigned int locbufsize; void gras_emul_init(void) { diff --git a/src/gras/gras.c b/src/gras/gras.c index 9314a25ef5..63f1d6cf9d 100644 --- a/src/gras/gras.c +++ b/src/gras/gras.c @@ -52,7 +52,7 @@ void gras_init(int *argc,char **argv) { gras_msg_procdata_t msg_pd; VERB0("Initialize GRAS"); - xbt_getpid = &gras_os_getpid; + xbt_getpid = gras_os_getpid; /* First initialize the XBT */ xbt_init(argc,argv); diff --git a/src/surf/surf.c b/src/surf/surf.c index 88800695c5..92c0864912 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -357,7 +357,7 @@ FILE *surf_fopen(const char *name, const char *mode) int i; char *path = NULL; FILE *file = NULL; - int path_name_len = 0; /* don't count '\0' */ + unsigned int path_name_len = 0; /* don't count '\0' */ xbt_assert0(name, "Need a non-NULL file name"); diff --git a/src/xbt/config.c b/src/xbt/config.c index a640310dfa..6411ad50d7 100644 --- a/src/xbt/config.c +++ b/src/xbt/config.c @@ -239,11 +239,11 @@ xbt_cfg_register(xbt_cfg_t cfg, break; case xbt_cfgelm_string: - res->content = xbt_dynar_new(sizeof(char*),&xbt_cfg_str_free); + res->content = xbt_dynar_new(sizeof(char*),xbt_cfg_str_free); break; case xbt_cfgelm_peer: - res->content = xbt_dynar_new(sizeof(xbt_peer_t),&xbt_peer_free_voidp); + res->content = xbt_dynar_new(sizeof(xbt_peer_t),xbt_peer_free_voidp); break; default: diff --git a/src/xbt/cunit.c b/src/xbt/cunit.c index e507d22e57..182217c036 100644 --- a/src/xbt/cunit.c +++ b/src/xbt/cunit.c @@ -141,7 +141,7 @@ xbt_test_suite_t xbt_test_suite_new(const char *name, const char *fmt, ...) { va_list ap; if (!_xbt_test_suites) - _xbt_test_suites = xbt_dynar_new(sizeof(xbt_test_suite_t),&xbt_test_suite_free); + _xbt_test_suites = xbt_dynar_new(sizeof(xbt_test_suite_t),xbt_test_suite_free); va_start(ap, fmt); vasprintf(&suite->title,fmt, ap); diff --git a/src/xbt/dict_multi.c b/src/xbt/dict_multi.c index a80a226ec8..d7863ed8da 100644 --- a/src/xbt/dict_multi.c +++ b/src/xbt/dict_multi.c @@ -87,7 +87,7 @@ xbt_multidict_set(xbt_dict_t mdict, xbt_dynar_t keys, void *data, void_f_pvoid_t free_ctn) { xbt_dynar_t lens = xbt_dynar_new(sizeof(unsigned long int),NULL); - int i; + unsigned long i; xbt_ex_t e; for (i = 0; i < xbt_dynar_length(keys); i++) { @@ -154,7 +154,7 @@ xbt_multidict_get_ext(xbt_dict_t mdict, void * xbt_multidict_get(xbt_dict_t mdict, xbt_dynar_t keys) { xbt_dynar_t lens = xbt_dynar_new(sizeof(unsigned long int),NULL); - int i; + unsigned long i; void *res; for (i = 0; i < xbt_dynar_length(keys); i++) { @@ -225,7 +225,7 @@ xbt_multidict_remove(xbt_dict_t mdict, xbt_dynar_t keys) { xbt_ex_t e; xbt_dynar_t lens = xbt_dynar_new(sizeof(unsigned long int),NULL); - int i; + unsigned long i; for (i = 0; i < xbt_dynar_length(keys); i++) { char *thiskey = xbt_dynar_get_as(keys, i, char*); diff --git a/src/xbt/dynar.c b/src/xbt/dynar.c index 6abfd76d23..d55871017f 100644 --- a/src/xbt/dynar.c +++ b/src/xbt/dynar.c @@ -65,7 +65,7 @@ void _xbt_clear_mem(void * const ptr, static XBT_INLINE void _xbt_dynar_expand(xbt_dynar_t const dynar, - const int nb) { + const unsigned long nb) { const unsigned long old_size = dynar->size; if (nb > old_size) { @@ -130,7 +130,7 @@ _xbt_dynar_put_elm(const xbt_dynar_t dynar, static XBT_INLINE void _xbt_dynar_remove_at(xbt_dynar_t const dynar, - const int idx, + const unsigned long idx, void * const object) { unsigned long nb_shift; @@ -278,7 +278,7 @@ xbt_dynar_reset(xbt_dynar_t const dynar) { * array is not expanded and nothing is done. */ void xbt_dynar_shrink(xbt_dynar_t dynar, int empty_slots_wanted) { - int size_wanted; + unsigned long size_wanted; _dynar_lock(dynar); @@ -326,7 +326,7 @@ xbt_dynar_length(const xbt_dynar_t dynar) { */ void xbt_dynar_get_cpy(const xbt_dynar_t dynar, - const int idx, + const unsigned long idx, void * const dst) { _dynar_lock(dynar); _sanity_check_dynar(dynar); @@ -347,7 +347,7 @@ xbt_dynar_get_cpy(const xbt_dynar_t dynar, * Make a copy before fooling with it. */ void* -xbt_dynar_get_ptr(const xbt_dynar_t dynar, const int idx) { +xbt_dynar_get_ptr(const xbt_dynar_t dynar, const unsigned long idx) { void *res; _dynar_lock(dynar); @@ -363,7 +363,7 @@ xbt_dynar_get_ptr(const xbt_dynar_t dynar, const int idx) { static void XBT_INLINE /* not synchronized */ _xbt_dynar_set(xbt_dynar_t dynar, - const int idx, + const unsigned long idx, const void * const src) { _sanity_check_dynar(dynar); @@ -408,7 +408,7 @@ xbt_dynar_set(xbt_dynar_t dynar, */ void xbt_dynar_replace(xbt_dynar_t dynar, - const int idx, + const unsigned long idx, const void * const object) { _dynar_lock(dynar); _sanity_check_dynar(dynar); @@ -417,7 +417,7 @@ xbt_dynar_replace(xbt_dynar_t dynar, if (idx < dynar->used && dynar->free_f) { void * const old_object = _xbt_dynar_elm(dynar, idx); - dynar->free_f(old_object); + (*(dynar->free_f))(old_object); } _xbt_dynar_set(dynar, idx, object); @@ -426,7 +426,7 @@ xbt_dynar_replace(xbt_dynar_t dynar, static XBT_INLINE void * _xbt_dynar_insert_at_ptr(xbt_dynar_t const dynar, - const int idx) { + const unsigned long idx) { void *res; unsigned long old_used; unsigned long new_used; @@ -514,7 +514,7 @@ xbt_dynar_remove_at(xbt_dynar_t const dynar, int xbt_dynar_search(xbt_dynar_t const dynar, void *const elem) { - int it; + unsigned long it; _dynar_lock(dynar); for (it=0; it< dynar->used; it++) @@ -624,7 +624,7 @@ static void _dynar_map(const xbt_dynar_t dynar, for (i = 0; i < used; i++) { _xbt_dynar_get_elm(elm, dynar, i); - op(elm); + (*op)(elm); } } @@ -639,7 +639,7 @@ static void _dynar_map(const xbt_dynar_t dynar, */ void xbt_dynar_map(const xbt_dynar_t dynar, - void_f_pvoid_t const op) { + void_f_pvoid_t const op) { _dynar_lock(dynar); _sanity_check_dynar(dynar); @@ -688,7 +688,7 @@ _xbt_dynar_cursor_get(const xbt_dynar_t dynar, _sanity_check_dynar(dynar); { - const int idx = *cursor; + const unsigned long idx = *cursor; if (idx >= dynar->used) { DEBUG1("Cursor on %p already on last elem",(void*)dynar); diff --git a/src/xbt/graph.c b/src/xbt/graph.c index 1237288d7c..27910e50a9 100644 --- a/src/xbt/graph.c +++ b/src/xbt/graph.c @@ -169,7 +169,7 @@ void xbt_graph_free_node(xbt_graph_t g, xbt_node_t n, void_f_pvoid_t edge_free_function) { unsigned long nbr; - int i; + unsigned long i; int cursor = 0; xbt_node_t node = NULL; xbt_edge_t edge = NULL; @@ -292,7 +292,7 @@ double *xbt_graph_get_length_matrix(xbt_graph_t g) { int cursor = 0; int in_cursor = 0; - int idx, i; + unsigned long idx, i; unsigned long n; xbt_edge_t edge = NULL; xbt_node_t node = NULL; @@ -340,7 +340,7 @@ double *xbt_graph_get_length_matrix(xbt_graph_t g) void xbt_floyd_algorithm(xbt_graph_t g, double *adj, double *d, xbt_node_t * p) { - int i, j, k; + unsigned long i, j, k; unsigned long n; n = xbt_dynar_length(g->nodes); @@ -384,7 +384,7 @@ xbt_node_t *xbt_graph_shortest_paths(xbt_graph_t g) { xbt_node_t *p; xbt_node_t *r; - int i, j, k; + unsigned long i, j, k; unsigned long n; double *adj = NULL; @@ -620,7 +620,7 @@ xbt_graph_t xbt_graph_read(const char *filename, ETag_graphxml_edge_fun = __parse_edge; xbt_graph_parse_open(filename); - xbt_assert1((!xbt_graph_parse()), "Parse error in %s", filename); + xbt_assert1((!(*xbt_graph_parse)()), "Parse error in %s", filename); xbt_graph_parse_close(); graph = parsed_graph; diff --git a/src/xbt/heap.c b/src/xbt/heap.c index 747b2e3521..243e9c3212 100644 --- a/src/xbt/heap.c +++ b/src/xbt/heap.c @@ -45,7 +45,7 @@ void xbt_heap_free(xbt_heap_t H) int i; if (H->free) for (i = 0; i < H->count; i++) - (*H->free)(H->items[i].content); + (*(H->free))(H->items[i].content); free(H->items); free(H); return; diff --git a/src/xbt/mallocator.c b/src/xbt/mallocator.c index b6784661e1..fcf4bc2d4e 100644 --- a/src/xbt/mallocator.c +++ b/src/xbt/mallocator.c @@ -65,7 +65,7 @@ void xbt_mallocator_free(xbt_mallocator_t m) { for (i = 0; i < m->current_size; i++) { - m->free_f(m->objects[i]); + (*(m->free_f))(m->objects[i]); } xbt_free(m->objects); xbt_free(m); @@ -98,9 +98,9 @@ void *xbt_mallocator_get(xbt_mallocator_t m) { } else { /* otherwise we must allocate a new object */ - object = m->new_f(); + object = (*(m->new_f))(); } - m->reset_f(object); + (*(m->reset_f))(object); return object; } @@ -126,6 +126,6 @@ void xbt_mallocator_release(xbt_mallocator_t m, void *object) { } else { /* otherwise we don't have a choice, we must free the object */ - m->free_f(object); + (*(m->free_f))(object); } } diff --git a/src/xbt/xbt_matrix.c b/src/xbt/xbt_matrix.c index b644d3be27..53ac04041c 100644 --- a/src/xbt/xbt_matrix.c +++ b/src/xbt/xbt_matrix.c @@ -41,7 +41,7 @@ xbt_matrix_t xbt_matrix_new_sub(xbt_matrix_t from, /** \brief destructor */ void xbt_matrix_free(xbt_matrix_t mat) { - int i; + unsigned int i; if (mat) { if (mat->free_f) { for (i=0; i < (mat->lines * mat->rows) ; i++) { @@ -63,7 +63,7 @@ void xbt_matrix_free_voidp(void *d) { * \param coords: boolean indicating whether we should add the coords of each cell to the output*/ void xbt_matrix_dump(xbt_matrix_t matrix, const char*name, int coords, void_f_pvoid_t display_fun) { - int i,j; + unsigned int i,j; fprintf(stderr,">>> Matrix %s dump (%d x %d)\n",name,matrix->lines,matrix->rows); for (i=0; ilines; i++) { @@ -94,11 +94,11 @@ void xbt_matrix_dump_display_double(void*d) { * \param rpos_src: row offset on destination matrix */ void xbt_matrix_copy_values(xbt_matrix_t dst, xbt_matrix_t src, - int lsize, int rsize, - int lpos_dst,int rpos_dst, - int lpos_src,int rpos_src, + unsigned int lsize, unsigned int rsize, + unsigned int lpos_dst,unsigned int rpos_dst, + unsigned int lpos_src,unsigned int rpos_src, pvoid_f_pvoid_t const cpy_f) { - int i,j; + unsigned int i,j; DEBUG10("Copy a %dx%d submatrix from %dx%d(of %dx%d) to %dx%d (of %dx%d)", lsize,rsize, @@ -179,7 +179,7 @@ xbt_matrix_t xbt_matrix_double_new_mult(xbt_matrix_t A,xbt_matrix_t B) { /** \brief add to C the result of A*B */ void xbt_matrix_double_addmult(xbt_matrix_t A,xbt_matrix_t B, /*OUT*/ xbt_matrix_t C) { - int i,j,k; + unsigned int i,j,k; xbt_assert2(A->lines == C->lines, "A->lines != C->lines (%d vs %d)",A->lines,C->lines); diff --git a/src/xbt/xbt_str.c b/src/xbt/xbt_str.c index 2ca23ab4ad..02ee5ab6b4 100644 --- a/src/xbt/xbt_str.c +++ b/src/xbt/xbt_str.c @@ -412,7 +412,8 @@ char *xbt_str_join(xbt_dynar_t dyn, const char*sep) { */ long getline(char **buf, size_t *n, FILE *stream) { - int i, ch; + size_t i; + int ch; if (!*buf) { *buf = xbt_malloc(512); @@ -452,7 +453,7 @@ long getline(char **buf, size_t *n, FILE *stream) { static xbt_matrix_t diff_build_LCS(xbt_dynar_t da, xbt_dynar_t db) { xbt_matrix_t C = xbt_matrix_new(xbt_dynar_length(da),xbt_dynar_length(db), sizeof(int),NULL); - int i,j; + unsigned long i,j; /* Compute the LCS */ /* -- 2.20.1