summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2008-02-26 18:31:59 +0000
committerJens Arnold <amiconn@rockbox.org>2008-02-26 18:31:59 +0000
commit3a74611a904fc817b71d7227f56e50258ea8b115 (patch)
treebcf2eb389099b43a1217d24f26631a7d367fec69
parent97d7f39680ff973468c600d91ace1c7adf2773fd (diff)
downloadrockbox-3a74611a904fc817b71d7227f56e50258ea8b115.tar.gz
rockbox-3a74611a904fc817b71d7227f56e50258ea8b115.zip
FS #8635 by Andree Buschmann: Fix overflow in test_disk speed calculation. No precision is lost because filesize is always a multiple of (1<<8).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16428 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/test_disk.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/apps/plugins/test_disk.c b/apps/plugins/test_disk.c
index 216ef733bd..27dbdb3334 100644
--- a/apps/plugins/test_disk.c
+++ b/apps/plugins/test_disk.c
@@ -232,7 +232,7 @@ static bool file_speed(int chunksize, bool align)
time = *rb->current_tick - time;
rb->close(fd);
rb->snprintf(text_buf, sizeof text_buf, "Create (%d,%c): %ld KB/s",
- chunksize, align ? 'A' : 'U', (25 * filesize / time) >> 8);
+ chunksize, align ? 'A' : 'U', (25 * (filesize>>8) / time) );
log_text(text_buf, true);
/* Existing file write speed */
@@ -255,7 +255,7 @@ static bool file_speed(int chunksize, bool align)
time = *rb->current_tick - time;
rb->close(fd);
rb->snprintf(text_buf, sizeof text_buf, "Write (%d,%c): %ld KB/s",
- chunksize, align ? 'A' : 'U', (25 * filesize / time) >> 8);
+ chunksize, align ? 'A' : 'U', (25 * (filesize>>8) / time) );
log_text(text_buf, true);
/* File read speed */
@@ -278,7 +278,7 @@ static bool file_speed(int chunksize, bool align)
time = *rb->current_tick - time;
rb->close(fd);
rb->snprintf(text_buf, sizeof text_buf, "Read (%d,%c): %ld KB/s",
- chunksize, align ? 'A' : 'U', (25 * filesize / time) >> 8);
+ chunksize, align ? 'A' : 'U', (25 * (filesize>>8) / time) );
log_text(text_buf, true);
rb->remove(TEST_FILE);
return true;