diff options
author | Vladimir Mezentsev <vladimir.mezentsev@oracle.com> | 2022-06-13 23:49:52 -0700 |
---|---|---|
committer | Vladimir Mezentsev <vladimir.mezentsev@oracle.com> | 2022-06-14 11:05:41 -0700 |
commit | 8e2de6c81a90e98ed95dfc0ffef1e3df9cfff6b7 (patch) | |
tree | f7a74ca7a4403c7e0dd9223f9a1bfc0dba0710f6 /gprofng/src/parse.cc | |
parent | 362a867f2ac16f597d06e8a9a3f6c15afa7adf6f (diff) | |
download | gdb-8e2de6c81a90e98ed95dfc0ffef1e3df9cfff6b7.zip gdb-8e2de6c81a90e98ed95dfc0ffef1e3df9cfff6b7.tar.gz gdb-8e2de6c81a90e98ed95dfc0ffef1e3df9cfff6b7.tar.bz2 |
gprofng: fix build with -Werror=format-security
gprofng/ChangeLog
2022-06-13 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
PR gprofng/28968
* src/src/Hist_data.cc (print_row): Make param const.
* src/src/Hist_data.h (print_row): Likewise.
* src/src/Print.h: Remove unused functions and variables.
* src/Print.cc: Fix -Werror=format-security errors.
* src/parse.cc: Likewise.
Diffstat (limited to 'gprofng/src/parse.cc')
-rw-r--r-- | gprofng/src/parse.cc | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/gprofng/src/parse.cc b/gprofng/src/parse.cc index ab22270..eaed8ee 100644 --- a/gprofng/src/parse.cc +++ b/gprofng/src/parse.cc @@ -789,6 +789,12 @@ Experiment::process_seg_unmap_cmd (char */*cmd*/, hrtime_t ts, Vaddr vaddr) return 0; } +static bool +strstarts (const char *var, const char *x) +{ + return strncmp (var, x, strlen (x)) == 0; +} + int Experiment::process_Linux_kernel_cmd (hrtime_t ts) { @@ -815,10 +821,6 @@ Experiment::process_Linux_kernel_cmd (hrtime_t ts) * but again Analyzer handles the case of not finding the file or not reading DWARF from it. */ mod->set_file_name (dbe_strdup ("LinuxKernel")); - char last_mod_name[256]; - last_mod_name[0] = '\0'; - size_t line_n = 0; - char *line = NULL; char kallmodsyms_copy[MAXPATHLEN]; snprintf (kallmodsyms_copy, sizeof (kallmodsyms_copy), "%s/kallmodsyms", expt_name); @@ -834,6 +836,8 @@ Experiment::process_Linux_kernel_cmd (hrtime_t ts) } else { + size_t line_n = 0; + char *line = NULL; while (getline (&line, &line_n, fd) > 0) { long long unsigned sym_addr; @@ -851,9 +855,6 @@ Experiment::process_Linux_kernel_cmd (hrtime_t ts) if (strcmp (mod_name, "ctf") == 0) strcpy (mod_name, "shared_ctf"); - char *mod_name_ptr; - int skip; -#define strstarts(var, x) (strncmp(var, x, strlen (x)) == 0) if (strcmp (sym_name, "__per_cpu_start") == 0 || strcmp (sym_name, "__per_cpu_end") == 0 || strstarts (sym_name, "__crc_") @@ -878,24 +879,14 @@ Experiment::process_Linux_kernel_cmd (hrtime_t ts) || strstarts (sym_name, "__dtrace_probe_") || (strstr (sym_name, ".") != NULL && strstr (sym_name, ".clone.") == NULL)) - { - mod_name_ptr = last_mod_name; - skip = 1; - } - else - { - mod_name_ptr = mod_name; - skip = 0; - } -#undef strstarts + continue; - if (sym_text && skip == 0) + if (sym_text) { char fname[128]; - snprintf (fname, sizeof (fname), "%s`%s", mod_name_ptr, sym_name); + snprintf (fname, sizeof (fname), "%s`%s", mod_name, sym_name); Function *func = dbeSession->createFunction (); func->set_name (fname); - // func->flags |= FUNC_FLAG_???; // XXX func->size = sym_size; func->img_offset = sym_addr; func->module = mod; @@ -906,11 +897,10 @@ Experiment::process_Linux_kernel_cmd (hrtime_t ts) if (lo_max < sym_addr + sym_size) lo_max = sym_addr + sym_size; } - sprintf (last_mod_name, mod_name_ptr); } fclose (fd); + free (line); } - free (line); lo->size = lo_max; lo->functions->sort (func_cmp); mod->functions->sort (func_cmp); |