From patchwork Fri Nov 7 13:46:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabien Proriol X-Patchwork-Id: 408139 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DF1751400A8 for ; Sat, 8 Nov 2014 00:48:29 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XmjsO-00006s-F0; Fri, 07 Nov 2014 13:46:56 +0000 Received: from mx0a-00158d01.pphosted.com ([208.84.65.189]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XmjsK-0008W4-Ui for linux-mtd@lists.infradead.org; Fri, 07 Nov 2014 13:46:55 +0000 Received: from pps.filterd (m0043267.ppops.net [127.0.0.1]) by mx0a-00158d01.pphosted.com (8.14.5/8.14.5) with SMTP id sA7Dk0Wl001180 for ; Fri, 7 Nov 2014 05:46:32 -0800 Received: from mx4.jdsu.com ([141.169.254.4]) by mx0a-00158d01.pphosted.com with ESMTP id 1qgguva0j1-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Fri, 07 Nov 2014 05:46:31 -0800 Received: from EUEXHTCA02.ds.jdsu.net (10.237.69.12) by MX4.jdsu.com (141.169.254.4) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 7 Nov 2014 14:46:26 +0100 Received: from EUEXMB01.ds.jdsu.net ([fe80::942f:1810:27a2:359d]) by EUEXHTCA02.ds.jdsu.net ([fe80::9522:9bca:dce1:4bc7%16]) with mapi id 14.03.0181.006; Fri, 7 Nov 2014 14:45:14 +0100 From: Fabien Proriol To: "linux-mtd@lists.infradead.org" Subject: [PATCH] Fix flashcp display Thread-Topic: [PATCH] Fix flashcp display Thread-Index: AQHP+pE7jTL+m7ESrEGIx0OeI81SNw== Date: Fri, 7 Nov 2014 13:46:28 +0000 Message-ID: <545CCCD3.6020006@jdsu.com> Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.8.0 x-originating-ip: [10.239.69.13] Content-ID: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.12.52, 1.0.28, 0.0.0000 definitions=2014-11-07_06:2014-11-07, 2014-11-07, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1411070111 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141107_054653_128567_4794181A X-CRM114-Status: GOOD ( 13.07 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [208.84.65.189 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [208.84.65.189 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From e65a012df12fa39ed0a6c5a71b5dc952b4c982fc Mon Sep 17 00:00:00 2001 From: Fabien Proriol Date: Thu, 6 Nov 2014 15:54:20 +0100 Subject: [PATCH] flashcp: Use %llu to print filestat.st_size filestat.st_size type is off_t. For some paltforms, off_t can be 32 or 64bit but there is no C99 format specifier for off_t. The best way to print it with printf is to cast it to long long and print with %llu Signed-off-by: Fabien Proriol --- flashcp.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/flashcp.c b/flashcp.c index d58c81b..04495bd 100644 --- a/flashcp.c +++ b/flashcp.c @@ -296,7 +296,7 @@ int main (int argc,char *argv[]) * write the entire file to flash * **********************************/ - if (flags & FLAG_VERBOSE) log_printf (LOG_NORMAL,"Writing data: 0k/%luk (0%%)",KB (filestat.st_size)); + if (flags & FLAG_VERBOSE) log_printf (LOG_NORMAL,"Writing data: 0k/%lluk (0%%)",KB ((unsigned long long)filestat.st_size)); size = filestat.st_size; i = BUFSIZE; written = 0; @@ -304,10 +304,10 @@ int main (int argc,char *argv[]) { if (size < BUFSIZE) i = size; if (flags & FLAG_VERBOSE) - log_printf (LOG_NORMAL,"\rWriting data: %dk/%luk (%lu%%)", + log_printf (LOG_NORMAL,"\rWriting data: %dk/%lluk (%llu%%)", KB (written + i), - KB (filestat.st_size), - PERCENTAGE (written + i,filestat.st_size)); + KB ((unsigned long long)filestat.st_size), + PERCENTAGE (written + i,(unsigned long long)filestat.st_size)); /* read from filename */ safe_read (fil_fd,filename,src,i,flags & FLAG_VERBOSE); @@ -325,8 +325,8 @@ int main (int argc,char *argv[]) exit (EXIT_FAILURE); } log_printf (LOG_ERROR, - "Short write count returned while writing to x%.8x-0x%.8x on %s: %d/%lu bytes written to flash\n", - written,written + i,device,written + result,filestat.st_size); + "Short write count returned while writing to x%.8x-0x%.8x on %s: %d/%llu bytes written to flash\n", + written,written + i,device,written + result,(unsigned long long)filestat.st_size); exit (EXIT_FAILURE); } @@ -335,10 +335,10 @@ int main (int argc,char *argv[]) } if (flags & FLAG_VERBOSE) log_printf (LOG_NORMAL, - "\rWriting data: %luk/%luk (100%%)\n", - KB (filestat.st_size), - KB (filestat.st_size)); - DEBUG("Wrote %d / %luk bytes\n",written,filestat.st_size); + "\rWriting data: %lluk/%lluk (100%%)\n", + KB ((unsigned long long)filestat.st_size), + KB ((unsigned long long)filestat.st_size)); + DEBUG("Wrote %d / %lluk bytes\n",written,(unsigned long long)filestat.st_size); /********************************** * verify that flash == file data * @@ -349,16 +349,16 @@ int main (int argc,char *argv[]) size = filestat.st_size; i = BUFSIZE; written = 0; - if (flags & FLAG_VERBOSE) log_printf (LOG_NORMAL,"Verifying data: 0k/%luk (0%%)",KB (filestat.st_size)); + if (flags & FLAG_VERBOSE) log_printf (LOG_NORMAL,"Verifying data: 0k/%lluk (0%%)",KB ((unsigned long long)filestat.st_size)); while (size) { if (size < BUFSIZE) i = size; if (flags & FLAG_VERBOSE) log_printf (LOG_NORMAL, - "\rVerifying data: %dk/%luk (%lu%%)", + "\rVerifying data: %dk/%lluk (%lu%%)", KB (written + i), - KB (filestat.st_size), - PERCENTAGE (written + i,filestat.st_size)); + KB ((unsigned long long)filestat.st_size), + PERCENTAGE (written + i,(unsigned long long)filestat.st_size)); /* read from filename */ safe_read (fil_fd,filename,src,i,flags & FLAG_VERBOSE); @@ -380,10 +380,10 @@ int main (int argc,char *argv[]) } if (flags & FLAG_VERBOSE) log_printf (LOG_NORMAL, - "\rVerifying data: %luk/%luk (100%%)\n", + "\rVerifying data: %lluk/%lluk (100%%)\n", KB (filestat.st_size), KB (filestat.st_size)); - DEBUG("Verified %d / %luk bytes\n",written,filestat.st_size); + DEBUG("Verified %d / %lluk bytes\n",written,(unsigned long long)filestat.st_size); exit (EXIT_SUCCESS); }