Fix warnings from Wall Wextra Wpedantic#258
Conversation
58a4c40 to
b413a90
Compare
650a842 to
d4e6881
Compare
| num_breakpoints_hit = 0; | ||
| hit_counts.clear(); | ||
| memset(indexes, 0, sizeof(indexes)); | ||
| memset(bp_addrs, 0, sizeof(bp_addrs)); |
There was a problem hiding this comment.
If on_breakpoint can be called multiple times, then I assume the memset should be kept?
There was a problem hiding this comment.
std::pair isn't trivially constructible, so using memset is UB. Values in indexes are only used immediately after writing them, so the memset was always unneeded.
indexes[cur_index].first = j;
indexes[cur_index].second = k;
bps[j][k]->setData(indexes+cur_index);The mixture of bracket operator and C-style array-plus-index is...
There was a problem hiding this comment.
What about the memset for bp_addrs?
It is an array of Dyninst::Address.
It is defined before use in executeTest.
But it is also checked in on_breakpoint L:107.
As for the mixture of C-style array-plus-index, it seems like setData is expecting a void *, so that seems valid to me.
Unless it should be something like setData(&indexes[cur_index])?
There was a problem hiding this comment.
What about the memset for bp_addrs? It is an array of Dyninst::Address. It is defined before use in executeTest. But it is also checked in on_breakpoint L:107.
Dyninst::Address is typedef'd to a primitive type, so that one is fine. I think it's also ok to convert T[][] to void*. I'd have to double-check.
As for the mixture of C-style array-plus-index, it seems like setData is expecting a void *, so that seems valid to me. Unless it should be something like setData(&indexes[cur_index])?
It's valid, but there's no need to write assembly in C++. It would be more clearly written &indexes[cur_index], as you pointed out.
d4e6881 to
cb7ab0d
Compare
No description provided.