From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2182 invoked by alias); 11 Jun 2007 12:05:44 -0000 Received: (qmail 2173 invoked by uid 22791); 11 Jun 2007 12:05:43 -0000 X-Spam-Check-By: sourceware.org Received: from s200aog12.obsmtp.com (HELO s200aog12.obsmtp.com) (207.126.144.126) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 11 Jun 2007 12:05:35 +0000 Received: from source ([164.129.1.35]) (using TLSv1) by eu1sys200aob012.postini.com ([207.126.147.11]) with SMTP; Mon, 11 Jun 2007 12:05:24 UTC Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6F116DA4E for ; Mon, 11 Jun 2007 12:05:23 +0000 (GMT) Received: from mail1.cro.st.com (mail1.cro.st.com [164.129.40.131]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 338634C183 for ; Mon, 11 Jun 2007 12:05:23 +0000 (GMT) Received: from [164.129.44.95] (crx595.cro.st.com [164.129.44.95]) by mail1.cro.st.com (MOS 3.7.5a-GA) with ESMTP id CKU32354 (AUTH "denis pilat"); Mon, 11 Jun 2007 14:05:17 +0200 (CEST) Message-ID: <466D3A7D.9030101@st.com> Date: Mon, 11 Jun 2007 12:05:00 -0000 From: Denis PILAT User-Agent: Thunderbird 1.5.0.12 (X11/20070509) MIME-Version: 1.0 To: gdb-patches Subject: [rfc] Overflow in transfer-rate Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-06/txt/msg00144.txt.bz2 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