From d37695654af494c87f28017306376b8c229aaec0 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 4 Apr 2019 11:32:19 +0200 Subject: [PATCH] [sonar] Remove useless commented lines of code. --- examples/s4u/app-bittorrent/s4u-peer.hpp | 1 - include/simgrid/simix/blocking_simcall.hpp | 4 ++-- include/xbt/dynar.h | 5 +---- include/xbt/graph.h | 3 --- src/smpi/include/smpi_keyvals.hpp | 2 +- src/xbt/automaton/automatonparse_promela.c | 1 - src/xbt/mmalloc/mfree.c | 10 ++++------ src/xbt/mmalloc/mm_module.c | 2 +- src/xbt/mmalloc/mmalloc.c | 3 --- src/xbt/mmalloc/mrealloc.c | 7 ------- 10 files changed, 9 insertions(+), 29 deletions(-) diff --git a/examples/s4u/app-bittorrent/s4u-peer.hpp b/examples/s4u/app-bittorrent/s4u-peer.hpp index 2d9eb6ad6c..2737649d71 100644 --- a/examples/s4u/app-bittorrent/s4u-peer.hpp +++ b/examples/s4u/app-bittorrent/s4u-peer.hpp @@ -15,7 +15,6 @@ public: int id; // Peer id simgrid::s4u::Mailbox* mailbox_; unsigned int bitfield = 0U; // Fields - // int messages_count; double peer_speed = 0; double last_unchoke = 0; int current_piece = -1; diff --git a/include/simgrid/simix/blocking_simcall.hpp b/include/simgrid/simix/blocking_simcall.hpp index 0a927ce6eb..43565d3e62 100644 --- a/include/simgrid/simix/blocking_simcall.hpp +++ b/include/simgrid/simix/blocking_simcall.hpp @@ -71,8 +71,8 @@ template auto kernel_sync(F code) -> decltype(code().get()) } /** A blocking (`wait()`-based) future for SIMIX processes */ -// TODO, .wait_for() -// TODO, .wait_until() +// TODO, .wait_for +// TODO, .wait_until // TODO, SharedFuture // TODO, simgrid::simix::when_all - wait for all future to be ready (this one is simple!) // TODO, simgrid::simix::when_any - wait for any future to be ready diff --git a/include/xbt/dynar.h b/include/xbt/dynar.h index 5384cfbfec..63d2b18068 100644 --- a/include/xbt/dynar.h +++ b/include/xbt/dynar.h @@ -210,11 +210,8 @@ static inline int _xbt_dynar_cursor_get(const xbt_dynar_t dynar, unsigned int id if (!dynar) /* iterating over a NULL dynar is a no-op */ return 0; - if (idx >= dynar->used) { - //XBT_DEBUG("Cursor on %p already on last elem", (void *) dynar); + if (idx >= dynar->used) return 0; - } - // XBT_DEBUG("Cash out cursor on %p at %u", (void *) dynar, *idx); memcpy(dst, ((char *) dynar->data) + idx * dynar->elmsize, dynar->elmsize); diff --git a/include/xbt/graph.h b/include/xbt/graph.h index 50eeb68a05..98e7661831 100644 --- a/include/xbt/graph.h +++ b/include/xbt/graph.h @@ -23,7 +23,6 @@ typedef struct xbt_graph *xbt_graph_t; /* Node structure */ /* Be careful of what you do with this structure */ -/* typedef struct xbt_node *xbt_node_t; */ typedef struct xbt_node { xbt_dynar_t out; xbt_dynar_t in; /* not used when the graph is directed */ @@ -34,7 +33,6 @@ typedef struct xbt_node { /* edge structure */ /* Be careful of what you do with this structure */ -/* typedef struct xbt_edge *xbt_edge_t; */ typedef struct xbt_edge { xbt_node_t src; xbt_node_t dst; @@ -43,7 +41,6 @@ typedef struct xbt_edge { /* Graph structure */ /* Be careful of what you do with this structure */ -/* typedef struct xbt_graph *xbt_graph_t; */ typedef struct xbt_graph { xbt_dynar_t nodes; xbt_dynar_t edges; diff --git a/src/smpi/include/smpi_keyvals.hpp b/src/smpi/include/smpi_keyvals.hpp index dc7dd35160..a23be10fa3 100644 --- a/src/smpi/include/smpi_keyvals.hpp +++ b/src/smpi/include/smpi_keyvals.hpp @@ -158,7 +158,7 @@ template void Keyval::cleanup_attr(){ call_deleter((T*)this, elem, it.first,it.second,&flag); } } else { - //already deleted, not a problem; + // already deleted, not a problem flag=0; } } diff --git a/src/xbt/automaton/automatonparse_promela.c b/src/xbt/automaton/automatonparse_promela.c index e43df858ed..104630c791 100644 --- a/src/xbt/automaton/automatonparse_promela.c +++ b/src/xbt/automaton/automatonparse_promela.c @@ -56,7 +56,6 @@ static void new_transition(char* id, xbt_automaton_exp_label_t label) xbt_automaton_state_t state_dst = xbt_automaton_state_exists(parsed_automaton, id); xbt_automaton_state_t state_src = xbt_automaton_state_exists(parsed_automaton, state_id_src); - //xbt_transition_t trans = NULL; xbt_automaton_transition_new(parsed_automaton, state_src, state_dst, label); } diff --git a/src/xbt/mmalloc/mfree.c b/src/xbt/mmalloc/mfree.c index 6a95aa3988..e08aba34f4 100644 --- a/src/xbt/mmalloc/mfree.c +++ b/src/xbt/mmalloc/mfree.c @@ -24,8 +24,6 @@ void mfree(struct mdesc *mdp, void *ptr) size_t i; int it; -// fprintf(stderr,"free(%p)\n",ptr); - if (ptr == NULL) return; @@ -93,7 +91,6 @@ void mfree(struct mdesc *mdp, void *ptr) block = i; } else { - //fprintf(stderr,"Free block %d to %d (as a new chunck)\n",block,block+mdp->heapinfo[block].busy_block.size); /* Really link this block back into the free list. */ mdp->heapinfo[block].free_block.size = mdp->heapinfo[block].busy_block.size; mdp->heapinfo[block].free_block.next = mdp->heapinfo[i].free_block.next; @@ -126,7 +123,8 @@ void mfree(struct mdesc *mdp, void *ptr) } /* Now see if we can return stuff to the system. */ - /* blocks = mdp -> heapinfo[block].free.size; +#if 0 + blocks = mdp -> heapinfo[block].free.size; if (blocks >= FINAL_FREE_BLOCKS && block + blocks == mdp -> heaplimit && mdp -> morecore (mdp, 0) == ADDRESS (block + blocks)) { @@ -140,7 +138,8 @@ void mfree(struct mdesc *mdp, void *ptr) block = mdp -> heapinfo[block].free.prev; mdp -> heapstats.chunks_free--; mdp -> heapstats.bytes_free -= bytes; - } */ + } +#endif /* Set the next search to begin at this block. This is probably important to the trick where realloc returns the block to @@ -174,7 +173,6 @@ void mfree(struct mdesc *mdp, void *ptr) mdp->heapinfo[block].busy_frag.frag_size[frag_nb] = -1; mdp->heapinfo[block].busy_frag.ignore[frag_nb] = 0; -// fprintf(stderr,"nfree:%zu capa:%d\n", mdp->heapinfo[block].busy_frag.nfree,(BLOCKSIZE >> type)); if (mdp->heapinfo[block].busy_frag.nfree == (BLOCKSIZE >> type) - 1) { /* If all fragments of this block are free, remove this block from its swag and free the whole block. */ diff --git a/src/xbt/mmalloc/mm_module.c b/src/xbt/mmalloc/mm_module.c index 32aaddac6a..825d992de7 100644 --- a/src/xbt/mmalloc/mm_module.c +++ b/src/xbt/mmalloc/mm_module.c @@ -332,7 +332,7 @@ void mmalloc_postexit(void) { /* Do not destroy the default mdp or ldl won't be able to free the memory it * allocated since we're in memory */ - // xbt_mheap_destroy_no_free(__mmalloc_default_mdp); + // xbt_mheap_destroy_no_free(__mmalloc_default_mdp) } // This is the underlying implementation of mmalloc_get_bytes_used_remote. diff --git a/src/xbt/mmalloc/mmalloc.c b/src/xbt/mmalloc/mmalloc.c index 46da29a4da..5294d699f8 100644 --- a/src/xbt/mmalloc/mmalloc.c +++ b/src/xbt/mmalloc/mmalloc.c @@ -197,8 +197,6 @@ void *mmalloc_no_memset(xbt_mheap_t mdp, size_t size) if (size < SMALLEST_POSSIBLE_MALLOC) size = SMALLEST_POSSIBLE_MALLOC; - // printf("(%s) Mallocing %d bytes on %p (default: %p)...",xbt_thread_self_name(),size,mdp,__mmalloc_default_mdp);fflush(stdout); - if (!(mdp->flags & MMALLOC_INITIALIZED)) initialize(mdp); @@ -345,7 +343,6 @@ void *mmalloc_no_memset(xbt_mheap_t mdp, size_t size) mdp -> heapstats.bytes_free -= blocks * BLOCKSIZE; } - //printf("(%s) Done mallocing. Result is %p\n",xbt_thread_self_name(),result);fflush(stdout); return (result); } diff --git a/src/xbt/mmalloc/mrealloc.c b/src/xbt/mmalloc/mrealloc.c index 89360df661..2d3c1ce4b2 100644 --- a/src/xbt/mmalloc/mrealloc.c +++ b/src/xbt/mmalloc/mrealloc.c @@ -35,8 +35,6 @@ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t size) return mmalloc(mdp, size); } - //printf("(%s)realloc %p to %d...",xbt_thread_self_name(),ptr,(int)size); - if ((char *) ptr < (char *) mdp->heapbase || BLOCK(ptr) > mdp->heapsize) { printf("FIXME. Ouch, this pointer is not mine, refusing to proceed (another solution would be to malloc " "it instead of reallocing it, see source code)\n"); @@ -83,7 +81,6 @@ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t size) if (blocks < mdp->heapinfo[block].busy_block.size) { int it; /* The new size is smaller; return excess memory to the free list. */ - //printf("(%s) return excess memory...",xbt_thread_self_name()); for (it= block+blocks; it< mdp->heapinfo[block].busy_block.size ; it++){ mdp->heapinfo[it].type = MMALLOC_TYPE_UNFRAGMENTED; // FIXME that should be useless, type should already be 0 here mdp->heapinfo[it].busy_block.ignore = 0; @@ -119,7 +116,6 @@ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t size) mdp->heaplimit = oldlimit; result = mmalloc_no_memset(mdp, requested_size); - //fprintf(stderr,"remalloc(%zu)~>%p\n",requested_size,result); if (ptr != result) memmove(result, ptr, blocks * BLOCKSIZE); @@ -136,7 +132,6 @@ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t size) if (size > (size_t) (1 << (type - 1)) && size <= (size_t) (1 << type)) { /* The new size is the same kind of fragment. */ - //printf("(%s) new size is same kind of fragment...",xbt_thread_self_name()); result = ptr; int frag_nb = RESIDUAL(result, BLOCKSIZE) >> type; @@ -146,7 +141,6 @@ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t size) } else { /* fragment -> Either other fragment, or block */ /* The new size is different; allocate a new space, and copy the lesser of the new size and the old. */ - //printf("(%s) new size is different...",xbt_thread_self_name()); result = mmalloc(mdp, requested_size); @@ -155,6 +149,5 @@ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t size) } break; } - //printf("(%s) Done reallocing: %p\n",xbt_thread_self_name(),result);fflush(stdout); return (result); } -- 2.20.1