[rtems commit] Use uint32_t instead of long. Use unsigned defines ( Prevent overflows on 16bit targets)

Ralf Corsepius ralf at rtems.org
Wed Apr 17 10:19:35 UTC 2013


Module:    rtems
Branch:    master
Commit:    f205c18f0c182670e8fb48214227cbf4460215b2
Changeset: http://git.rtems.org/rtems/commit/?id=f205c18f0c182670e8fb48214227cbf4460215b2

Author:    Ralf Corsépius <ralf.corsepius at rtems.org>
Date:      Wed Apr 17 12:19:33 2013 +0200

Use uint32_t instead of long. Use unsigned defines (Prevent overflows on 16bit targets)

---

 testsuites/libtests/flashdisk01/init.c             |    6 +++---
 testsuites/libtests/flashdisk01/test-file-system.c |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/testsuites/libtests/flashdisk01/init.c b/testsuites/libtests/flashdisk01/init.c
index 8abca7d..bd38085 100644
--- a/testsuites/libtests/flashdisk01/init.c
+++ b/testsuites/libtests/flashdisk01/init.c
@@ -41,11 +41,11 @@ static rtems_task Init(rtems_task_argument argument);
 
 #define FLASHDISK_DEVICE_COUNT 1
 
-#define FLASHDISK_SEGMENT_COUNT 4
+#define FLASHDISK_SEGMENT_COUNT 4U
 
 #define FLASHDISK_SEGMENT_SIZE (16 * 1024)
 
-#define FLASHDISK_BLOCK_SIZE 512
+#define FLASHDISK_BLOCK_SIZE 512U
 
 #define FLASHDISK_BLOCKS_PER_SEGMENT \
   (FLASHDISK_SEGMENT_SIZE / FLASHDISK_BLOCK_SIZE)
@@ -347,7 +347,7 @@ uint32_t rtems_flashdisk_configuration_size = FLASHDISK_CONFIG_COUNT;
 #define CONFIGURE_MAXIMUM_TASKS 2
 #define CONFIGURE_MAXIMUM_SEMAPHORES 1
 
-#define CONFIGURE_MINIMUM_TASK_STACK_SIZE (32 * 1024)
+#define CONFIGURE_MINIMUM_TASK_STACK_SIZE (32U * 1024U)
 
 #define CONFIGURE_EXTRA_TASK_STACKS (8 * 1024)
 
diff --git a/testsuites/libtests/flashdisk01/test-file-system.c b/testsuites/libtests/flashdisk01/test-file-system.c
index 11ceb3a..10211c0 100644
--- a/testsuites/libtests/flashdisk01/test-file-system.c
+++ b/testsuites/libtests/flashdisk01/test-file-system.c
@@ -36,7 +36,7 @@
 
 #define ASSERT_SC(sc) assert((sc) == RTEMS_SUCCESSFUL)
 
-#define BUFFER_SIZE (32 * 1024)
+#define BUFFER_SIZE (32U * 1024U)
 
 #define HEADER_SIZE 8
 
@@ -147,8 +147,8 @@ static uint32_t simple_random(uint32_t v)
 
 static unsigned get_bucket_with_random(unsigned count, long random)
 {
-  long unsigned unit = (1U << 31) / count;
-  long unsigned bucket = (long unsigned) random / unit;
+  uint32_t unit = ((uint32_t) 1U << 31) / count;
+  uint32_t bucket = (uint32_t) random / unit;
 
   if (bucket != count) {
     return bucket;




More information about the vc mailing list