[rtems commit] nsecs/init.c: Use long to avoid overflow on 16-bit targets

Joel Sherrill joel at rtems.org
Mon Oct 13 16:27:41 UTC 2014


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

Author:    Joel Sherrill <joel.sherrill at oarcorp.com>
Date:      Mon Oct 13 11:13:11 2014 -0500

nsecs/init.c: Use long to avoid overflow on 16-bit targets

---

 testsuites/samples/nsecs/init.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/testsuites/samples/nsecs/init.c b/testsuites/samples/nsecs/init.c
index ba739eb..59995f1 100644
--- a/testsuites/samples/nsecs/init.c
+++ b/testsuites/samples/nsecs/init.c
@@ -122,14 +122,15 @@ rtems_task Init(
   for (index=1 ; index <=10 ; index++ ) {
     struct timespec start, stop;
     struct timespec diff;
-    int j, max = (index * 10000);
+    long j, max = (index * 10000L);
     rtems_clock_get_uptime( &start );
       for (j=0 ; j<max ; j++ )
         dummy_function_empty_body_to_force_call();
     rtems_clock_get_uptime( &stop );
 
     subtract_em( &start, &stop, &diff );
-    printf( "loop of %d %" PRIdtime_t ":%ld %" PRIdtime_t ":%ld --> %" PRIdtime_t ":%ld\n",
+    printf( "loop of %ld %" PRIdtime_t
+              ":%ld %" PRIdtime_t ":%ld --> %" PRIdtime_t ":%ld\n",
       max,
       start.tv_sec, start.tv_nsec,
       stop.tv_sec, stop.tv_nsec,



More information about the vc mailing list