sim: mn10300: clean up pointer casts
authorMike Frysinger <vapier@gentoo.org>
Mon, 1 Nov 2021 03:21:36 +0000 (23:21 -0400)
committerMike Frysinger <vapier@gentoo.org>
Mon, 1 Nov 2021 03:21:36 +0000 (23:21 -0400)
The void *data field is used to past arbitrary data between event
handlers, and these are using it to pass an enum.  Fix up the casts
to avoid using (long) to cast to/from pointers since there is no
guarantee that's the right size.

sim/mn10300/dv-mn103ser.c
sim/mn10300/dv-mn103tim.c

index 3465954f75f7d4b2fc3ecebc1cd4ec9c863dfb22..d2140e22c196630c434da6341998dbe39789ff2e 100644 (file)
@@ -238,7 +238,7 @@ do_polling_event (struct hw *me,
 {
   SIM_DESC sd = hw_system (me);
   struct mn103ser *serial = hw_data(me);
-  long serial_reg = (long) data;
+  long serial_reg = (uintptr_t) data;
   char c;
   int count, status;
 
@@ -280,7 +280,7 @@ do_polling_event (struct hw *me,
   /* Schedule next polling event */
   serial->device[serial_reg].event
     = hw_event_queue_schedule (me, 1000,
-                              do_polling_event, (void *)serial_reg);
+                              do_polling_event, (void *)(uintptr_t)serial_reg);
 
 }
 
@@ -424,7 +424,7 @@ read_status_reg (struct hw *me,
       serial->device[serial_reg].event
        = hw_event_queue_schedule (me, 1000,
                                   do_polling_event,
-                                  (void *) (long) serial_reg);
+                                  (void *)(uintptr_t)serial_reg);
     }
 
   if ( nr_bytes == 1 )
index ad9c24bbc6e8cfb2b36aa9dc7b45fa61f2b0d35a..76f87380d1d8bc9f0ae56cf514b549a249390882 100644 (file)
@@ -570,7 +570,7 @@ do_counter_event (struct hw *me,
                  void *data)
 {
   struct mn103tim *timers = hw_data(me);
-  long timer_nr = (long) data;
+  long timer_nr = (uintptr_t) data;
   int next_timer;
 
   /* Check if counting is still enabled. */
@@ -596,7 +596,7 @@ do_counter_event (struct hw *me,
       /* FIX: Check if div_ratio has changed and if it's now 0. */
       timers->timer[timer_nr].event
        = hw_event_queue_schedule (me, timers->timer[timer_nr].div_ratio,
-                                  do_counter_event, (void *)timer_nr);
+                                  do_counter_event, (void *)(uintptr_t)timer_nr);
     }
   else
     {
@@ -611,7 +611,7 @@ do_counter6_event (struct hw *me,
                  void *data)
 {
   struct mn103tim *timers = hw_data(me);
-  long timer_nr = (long) data;
+  long timer_nr = (uintptr_t) data;
   int next_timer;
 
   /* Check if counting is still enabled. */
@@ -625,7 +625,7 @@ do_counter6_event (struct hw *me,
       /* FIX: Check if div_ratio has changed and if it's now 0. */
       timers->timer[timer_nr].event
        = hw_event_queue_schedule (me, timers->timer[timer_nr].div_ratio,
-                                  do_counter6_event, (void *)timer_nr);
+                                  do_counter6_event, (void *)(uintptr_t)timer_nr);
     }
   else
     {
@@ -808,7 +808,7 @@ write_mode_reg (struct hw *me,
              timers->timer[timer_nr].event
                = hw_event_queue_schedule(me, div_ratio,
                                          do_counter_event,
-                                         (void *)(timer_nr)); 
+                                         (void *)(uintptr_t)timer_nr);
            }
        }
     }
@@ -908,7 +908,7 @@ write_tm6md (struct hw *me,
          timers->timer[timer_nr].event
            = hw_event_queue_schedule(me, div_ratio,
                                      do_counter6_event,
-                                     (void *)(timer_nr)); 
+                                     (void *)(uintptr_t)timer_nr);
        }
     }
   else