Skip to content

Commit

Permalink
contrib/plugins/cache: Fix string format
Browse files Browse the repository at this point in the history
This fixes on Darwin:

  plugins/cache.c:550:28: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                             l1_daccess,
                             ^~~~~~~~~~
  plugins/cache.c:551:28: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                             l1_dmisses,
                             ^~~~~~~~~~
  plugins/cache.c:553:28: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                             l1_iaccess,
                             ^~~~~~~~~~
  plugins/cache.c:554:28: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                             l1_imisses,
                             ^~~~~~~~~~
  plugins/cache.c:560:32: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                                 l2_access,
                                 ^~~~~~~~~
  plugins/cache.c:561:32: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                                 l2_misses,
                                 ^~~~~~~~~
  plugins/cache.c:665:52: warning: format specifies type 'long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
          g_string_append_printf(rep, ", %ld, %s\n", insn->l1_dmisses,
                                         ~~~         ^~~~~~~~~~~~~~~~
                                         %llu
  plugins/cache.c:678:52: warning: format specifies type 'long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
          g_string_append_printf(rep, ", %ld, %s\n", insn->l1_imisses,
                                         ~~~         ^~~~~~~~~~~~~~~~
                                         %llu
  plugins/cache.c:695:52: warning: format specifies type 'long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
          g_string_append_printf(rep, ", %ld, %s\n", insn->l2_misses,
                                         ~~~         ^~~~~~~~~~~~~~~
                                         %llu

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230907105004.88600-2-philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
philmd authored and bonzini committed Sep 7, 2023
1 parent 07c4523 commit 86e49b2
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions contrib/plugins/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,8 @@ static void append_stats_line(GString *line, uint64_t l1_daccess,
l1_dmiss_rate = ((double) l1_dmisses) / (l1_daccess) * 100.0;
l1_imiss_rate = ((double) l1_imisses) / (l1_iaccess) * 100.0;

g_string_append_printf(line, "%-14lu %-12lu %9.4lf%% %-14lu %-12lu"
" %9.4lf%%",
g_string_append_printf(line, "%-14" PRIu64 " %-12" PRIu64 " %9.4lf%%"
" %-14" PRIu64 " %-12" PRIu64 " %9.4lf%%",
l1_daccess,
l1_dmisses,
l1_daccess ? l1_dmiss_rate : 0.0,
Expand All @@ -556,7 +556,8 @@ static void append_stats_line(GString *line, uint64_t l1_daccess,

if (use_l2) {
l2_miss_rate = ((double) l2_misses) / (l2_access) * 100.0;
g_string_append_printf(line, " %-12lu %-11lu %10.4lf%%",
g_string_append_printf(line,
" %-12" PRIu64 " %-11" PRIu64 " %10.4lf%%",
l2_access,
l2_misses,
l2_access ? l2_miss_rate : 0.0);
Expand Down Expand Up @@ -662,8 +663,8 @@ static void log_top_insns(void)
if (insn->symbol) {
g_string_append_printf(rep, " (%s)", insn->symbol);
}
g_string_append_printf(rep, ", %ld, %s\n", insn->l1_dmisses,
insn->disas_str);
g_string_append_printf(rep, ", %" PRId64 ", %s\n",
insn->l1_dmisses, insn->disas_str);
}

miss_insns = g_list_sort(miss_insns, icmp);
Expand All @@ -675,8 +676,8 @@ static void log_top_insns(void)
if (insn->symbol) {
g_string_append_printf(rep, " (%s)", insn->symbol);
}
g_string_append_printf(rep, ", %ld, %s\n", insn->l1_imisses,
insn->disas_str);
g_string_append_printf(rep, ", %" PRId64 ", %s\n",
insn->l1_imisses, insn->disas_str);
}

if (!use_l2) {
Expand All @@ -692,8 +693,8 @@ static void log_top_insns(void)
if (insn->symbol) {
g_string_append_printf(rep, " (%s)", insn->symbol);
}
g_string_append_printf(rep, ", %ld, %s\n", insn->l2_misses,
insn->disas_str);
g_string_append_printf(rep, ", %" PRId64 ", %s\n",
insn->l2_misses, insn->disas_str);
}

finish:
Expand Down

0 comments on commit 86e49b2

Please sign in to comment.