xiaoxiang781216 commented on a change in pull request #5915:
URL: https://github.com/apache/incubator-nuttx/pull/5915#discussion_r839753085



##########
File path: sched/sched/sched_note.c
##########
@@ -133,7 +167,7 @@ static void note_common(FAR struct tcb_s *tcb,
 
   clock_systime_timespec(&ts);
 #else
-  uint32_t systime    = (uint32_t)clock_systime_ticks();
+  clock_t systime    = (clock_t)clock_systime_ticks();

Review comment:
       remove the cast

##########
File path: sched/sched/sched_note.c
##########
@@ -419,20 +443,8 @@ static void note_spincommon(FAR struct tcb_s *tcb,
 
   note_common(tcb, &note.nsp_cmn, sizeof(struct note_spinlock_s), type);
 
-  note.nsp_spinlock[0] = (uint8_t)((uintptr_t)spinlock & 0xff);
-  note.nsp_spinlock[1] = (uint8_t)(((uintptr_t)spinlock >> 8)  & 0xff);
-#if UINTPTR_MAX > UINT16_MAX
-  note.nsp_spinlock[2] = (uint8_t)(((uintptr_t)spinlock >> 16) & 0xff);
-  note.nsp_spinlock[3] = (uint8_t)(((uintptr_t)spinlock >> 24) & 0xff);
-#if UINTPTR_MAX > UINT32_MAX
-  note.nsp_spinlock[4] = (uint8_t)(((uintptr_t)spinlock >> 32) & 0xff);
-  note.nsp_spinlock[5] = (uint8_t)(((uintptr_t)spinlock >> 40) & 0xff);
-  note.nsp_spinlock[6] = (uint8_t)(((uintptr_t)spinlock >> 48) & 0xff);
-  note.nsp_spinlock[7] = (uint8_t)(((uintptr_t)spinlock >> 56) & 0xff);
-#endif
-#endif
-
-  note.nsp_value    = (uint8_t)*spinlock;
+  sched_note_flatten(note.nsp_spinlock, &spinlock, sizeof(uintptr_t));

Review comment:
        sizeof(&spinlock)

##########
File path: sched/sched/sched_note.c
##########
@@ -825,20 +826,9 @@ void sched_note_syscall_leave(int nr, uintptr_t result)
   note_common(tcb, &note.nsc_cmn, sizeof(struct note_syscall_leave_s),
               NOTE_SYSCALL_LEAVE);
   DEBUGASSERT(nr <= UCHAR_MAX);
-  note.nsc_nr     = nr;
-
-  note.nsc_result[0] = (uint8_t)(result & 0xff);
-  note.nsc_result[1] = (uint8_t)((result >> 8)  & 0xff);
-#if UINTPTR_MAX > UINT16_MAX
-  note.nsc_result[2] = (uint8_t)((result >> 16) & 0xff);
-  note.nsc_result[3] = (uint8_t)((result >> 24) & 0xff);
-#if UINTPTR_MAX > UINT32_MAX
-  note.nsc_result[4] = (uint8_t)((result >> 32) & 0xff);
-  note.nsc_result[5] = (uint8_t)((result >> 40) & 0xff);
-  note.nsc_result[6] = (uint8_t)((result >> 48) & 0xff);
-  note.nsc_result[7] = (uint8_t)((result >> 56) & 0xff);
-#endif
-#endif
+  note.nsc_nr = nr;
+
+  sched_note_flatten(note.nsc_result, &result, sizeof(uintptr_t));

Review comment:
       sizeof(result)

##########
File path: sched/sched/sched_note.c
##########
@@ -789,18 +800,8 @@ void sched_note_syscall_enter(int nr, int argc, ...)
   for (i = 0; i < argc; i++)
     {
       arg = (uintptr_t)va_arg(ap, uintptr_t);
-      *args++ = (uint8_t)(arg & 0xff);
-      *args++ = (uint8_t)((arg >> 8)  & 0xff);
-#if UINTPTR_MAX > UINT16_MAX
-      *args++ = (uint8_t)((arg >> 16) & 0xff);
-      *args++ = (uint8_t)((arg >> 24) & 0xff);
-#if UINTPTR_MAX > UINT32_MAX
-      *args++ = (uint8_t)((arg >> 32) & 0xff);
-      *args++ = (uint8_t)((arg >> 40) & 0xff);
-      *args++ = (uint8_t)((arg >> 48) & 0xff);
-      *args++ = (uint8_t)((arg >> 56) & 0xff);
-#endif
-#endif
+      sched_note_flatten(args, &arg, sizeof(uintptr_t));

Review comment:
       sizeof(arg)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to