Skip to content

Commit

Permalink
heaptrace: Resolve some warnings found by clang-tidy
Browse files Browse the repository at this point in the history
This patch fixes the following clang-tidy warnings.

  src/heaptrace.cc:117:8: warning: Value stored to 'old_libpath' during
    its initialization is never read
  src/libheaptrace.cc:71:8: warning: Value stored to 'tfs' during its
    initialization is never read
  src/libheaptrace.cc:171:24: warning: function previously declared with
    an explicit exception specification red eclared with an implicit
    exception specification
  src/libheaptrace.cc:189:24: warning: function previously declared with
    an explicit exception specification red eclared with an implicit
    exception specification
  src/stacktrace.cc:310:10: warning: Value stored to 'count' during its
    initialization is never read
  src/utils.cc:24:2: warning: Value stored to 'ret' is never read

Signed-off-by: Honggyu Kim <[email protected]>
  • Loading branch information
honggyukim committed Apr 18, 2023
1 parent 864936f commit 877f601
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/heaptrace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ static void setup_child_environ(struct opts *opts, int argc, char *argv[])
std::stringstream ss;
char buf[4096];
char *old_preload = getenv("LD_PRELOAD");
char *old_libpath = getenv("LD_LIBRARY_PATH");

if (!access("libheaptrace.so", X_OK))
ss << "./";
Expand Down
5 changes: 2 additions & 3 deletions src/libheaptrace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ FILE *outfp;

__constructor static void heaptrace_init()
{
auto *tfs = &thread_flags;
int pid = getpid();
std::stringstream ss;
std::string comm = utils::get_comm_name();
Expand Down Expand Up @@ -169,7 +168,7 @@ __visible_default void *operator new[](size_t size)
return p;
}

__visible_default void operator delete(void *ptr)
__visible_default void operator delete(void *ptr) noexcept
{
auto *tfs = &thread_flags;

Expand All @@ -187,7 +186,7 @@ __visible_default void operator delete(void *ptr)
tfs->hook_guard = false;
}

__visible_default void operator delete[](void *ptr)
__visible_default void operator delete[](void *ptr) noexcept
{
auto *tfs = &thread_flags;

Expand Down
1 change: 0 additions & 1 deletion src/stacktrace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ print_dump_stackmap_flamegraph(std::vector<std::pair<stack_trace_t, stack_info_t
size_t stack_size = sorted_stack.size();
for (int i = 0; i < stack_size; i++) {
const stack_info_t &info = sorted_stack[i].second;
size_t count = info.count;
uint64_t size = info.total_size;
const char *semicolon = "";

Expand Down
6 changes: 4 additions & 2 deletions src/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ std::string asprintf(const char *fmt, ...)
va_list args;
std::string str;
char *ptr;
int ret;

va_start(args, fmt);
ret = vasprintf(&ptr, fmt, args);
if (vasprintf(&ptr, fmt, args) < 0) {
va_end(args);
return {};
}
str = ptr;
free(ptr);
va_end(args);
Expand Down

0 comments on commit 877f601

Please sign in to comment.