From d21b20835f7cbf3cf6037e43f8e964adb2af75e0 Mon Sep 17 00:00:00 2001 From: "dzzxzz@gmail.com" Date: Wed, 11 Jan 2012 11:19:41 +0000 Subject: [PATCH] avoid arithmetic overflow in the examples/file/readspeed.c and writespeed.c git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1916 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- examples/file/readspeed.c | 2 +- examples/file/writespeed.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/file/readspeed.c b/examples/file/readspeed.c index a41c126550..d83fdcb20f 100644 --- a/examples/file/readspeed.c +++ b/examples/file/readspeed.c @@ -55,7 +55,7 @@ void readspeed(const char* filename, int block_size) rt_free(buff_ptr); /* calculate read speed */ - rt_kprintf("File read speed: %d byte/s\n", total_length*RT_TICK_PER_SECOND/tick); + rt_kprintf("File read speed: %d byte/s\n", total_length /tick * RT_TICK_PER_SECOND); } #ifdef RT_USING_FINSH diff --git a/examples/file/writespeed.c b/examples/file/writespeed.c index 157b24f47a..5fa2f44452 100644 --- a/examples/file/writespeed.c +++ b/examples/file/writespeed.c @@ -63,7 +63,7 @@ void writespeed(const char* filename, int total_length, int block_size) rt_free(buff_ptr); /* calculate write speed */ - rt_kprintf("File write speed: %d byte/s\n", total_length*RT_TICK_PER_SECOND/tick); + rt_kprintf("File write speed: %d byte/s\n", total_length / tick * RT_TICK_PER_SECOND); } #ifdef RT_USING_FINSH