From 3a74611a904fc817b71d7227f56e50258ea8b115 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Tue, 26 Feb 2008 18:31:59 +0000 Subject: [PATCH] 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 --- apps/plugins/test_disk.c | 6 +++--- 1 file 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;