From: Denis PILAT <denis.pilat@st.com>
To: gdb-patches <gdb-patches@sourceware.org>
Subject: [rfc] Overflow in transfer-rate
Date: Mon, 11 Jun 2007 12:05:00 -0000 [thread overview]
Message-ID: <466D3A7D.9030101@st.com> (raw)
In symfile.c/print_transfer_performance (), an overflow can occure when data_count (see below) is a large number.
I propose either the following 1st patch, or to pass to "%llu"into the ui_out_field_fmt functino call, see the next patch proposal.
Index: symfile.c
===================================================================
--- symfile.c (revision 215)
+++ symfile.c (working copy)
@@ -1821,7 +1821,7 @@ print_transfer_performance (struct ui_fi
if (time_count > 0)
{
ui_out_field_fmt (uiout, "transfer-rate", "%lu",
- 1000 * (data_count * 8) / time_count);
+ ((data_count / time_count) * 8 * 1000);
ui_out_text (uiout, " bits/sec");
}
else
This 2nd option would fix all possible overflow, but I'm not sure yet the %llu is supported under windows.
Index: symfile.c
===================================================================
--- symfile.c (revision 215)
+++ symfile.c (working copy)
@@ -1820,13 +1820,13 @@ print_transfer_performance (struct ui_fi
ui_out_text (uiout, "Transfer rate: ");
if (time_count > 0)
{
- ui_out_field_fmt (uiout, "transfer-rate", "%lu",
- 1000 * (data_count * 8) / time_count);
+ ui_out_field_fmt (uiout, "transfer-rate", "%llu",
+ 1000ULL * (data_count * 8) / time_count);
ui_out_text (uiout, " bits/sec");
}
else
{
- ui_out_field_fmt (uiout, "transferred-bits", "%lu", (data_count * 8));
+ ui_out_field_fmt (uiout, "transferred-bits", "%llu", (data_count * 8ULL));
ui_out_text (uiout, " bits in <1 sec");
}
if (write_count > 0)
Please give me your opinion.
--
Denis
next reply other threads:[~2007-06-11 12:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-11 12:05 Denis PILAT [this message]
2007-06-11 12:52 ` Andrew STUBBS
2007-06-11 13:15 ` Denis PILAT
2007-07-01 22:10 ` Daniel Jacobowitz
2007-07-02 7:36 ` Denis PILAT
2007-07-03 15:32 ` Daniel Jacobowitz
2007-07-04 17:19 ` Joel Brobecker
2007-07-04 18:00 ` Mark Kettenis
2007-07-04 18:15 ` Daniel Jacobowitz
2007-07-04 18:20 ` Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=466D3A7D.9030101@st.com \
--to=denis.pilat@st.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox