You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/04/28 12:14:05 UTC

[GitHub] [incubator-nuttx] zhuyanlinzyl opened a new pull request, #6173: nuttx: fix coverity check error

zhuyanlinzyl opened a new pull request, #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173

   ## Summary
   
   Patch 1:  fix deadcode in pthread_mutexinit
   Patch 2: timer:settime: check return value of clock_abstime2ticks
   
   ## Impact
   
   No. bug fix
   
   ## Testing
   
   Testing in armv8-m board
   


-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173#discussion_r872401117


##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -97,7 +97,7 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
           type    = attr->type;
 #endif
 #ifdef CONFIG_PTHREAD_MUTEX_BOTH
-          robust  = attr->robust;
+          flags  = attr->robust == PTHREAD_MUTEX_ROBUST ? _PTHREAD_MFLAGS_ROBUST : 0;

Review Comment:
   ```suggestion
             flags   = (attr->robust == PTHREAD_MUTEX_ROBUST ?
                                   _PTHREAD_MFLAGS_ROBUST : 0);
   ```



##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -97,7 +97,7 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
           type    = attr->type;
 #endif
 #ifdef CONFIG_PTHREAD_MUTEX_BOTH
-          robust  = attr->robust;
+          flags  = attr->robust == PTHREAD_MUTEX_ROBUST ? _PTHREAD_MFLAGS_ROBUST : 0;

Review Comment:
   ```suggestion
             flags   = (attr->robust == PTHREAD_MUTEX_ROBUST ?
                           _PTHREAD_MFLAGS_ROBUST : 0);
   ```



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173#discussion_r872596876


##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -69,9 +69,9 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
 #endif
 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
 #ifdef CONFIG_PTHREAD_MUTEX_DEFAULT_UNSAFE
-  uint8_t robust = PTHREAD_MUTEX_STALLED;
+  uint8_t flags = 0;
 #else
-  uint8_t robust = PTHREAD_MUTEX_ROBUST;
+  uint8_t flags = _PTHREAD_MFLAGS_ROBUST;

Review Comment:
   Here: `robust == PTHREAD_MUTEX_STALLED || robust == _PTHREAD_MFLAGS_ROBUST`
   It checks `robust` against `_PTHREAD_MFLAGS_ROBUST` and not `PTHREAD_MUTEX_ROBUST`



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173#discussion_r861488261


##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -124,11 +117,20 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
 #endif
 
 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
-      /* Initial internal fields of the mutex */
 
       mutex->flink  = NULL;
+
+#ifdef CONFIG_PTHREAD_MUTEX_BOTH
+      /* Initial internal fields of the mutex */
+
       mutex->flags  = (robust == PTHREAD_MUTEX_ROBUST ?

Review Comment:
   still missing init value



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] zhuyanlinzyl commented on a diff in pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
zhuyanlinzyl commented on code in PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173#discussion_r861428495


##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -124,11 +117,20 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
 #endif
 
 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
-      /* Initial internal fields of the mutex */
 
       mutex->flink  = NULL;
+
+#ifdef CONFIG_PTHREAD_MUTEX_BOTH
+      /* Initial internal fields of the mutex */
+
       mutex->flags  = (robust == PTHREAD_MUTEX_ROBUST ?

Review Comment:
   @pkarashchenko  please review again



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173#discussion_r868142838


##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -68,11 +68,9 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
 #  endif
 #endif
 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
-#ifdef CONFIG_PTHREAD_MUTEX_DEFAULT_UNSAFE
-  uint8_t robust = PTHREAD_MUTEX_STALLED;
-#else
-  uint8_t robust = PTHREAD_MUTEX_ROBUST;
-#endif
+#  ifdef CONFIG_PTHREAD_MUTEX_BOTH
+  uint8_t robust;

Review Comment:
   @zhuyanlinzyl let fix the warning by initializing robust to _PTHREAD_MFLAGS_ROBUST



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173#discussion_r872658327


##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -69,9 +69,9 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
 #endif
 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
 #ifdef CONFIG_PTHREAD_MUTEX_DEFAULT_UNSAFE
-  uint8_t robust = PTHREAD_MUTEX_STALLED;
+  uint8_t flags = 0;
 #else
-  uint8_t robust = PTHREAD_MUTEX_ROBUST;
+  uint8_t flags = _PTHREAD_MFLAGS_ROBUST;

Review Comment:
   Ok, pthread_mutexattr_setrobust check the wrong macro, @zhuyanlinzyl please change "robust == _PTHREAD_MFLAGS_ROBUST" to "robust == PTHREAD_MUTEX_ROBUST"



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173#discussion_r872602161


##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -69,9 +69,9 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
 #endif
 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
 #ifdef CONFIG_PTHREAD_MUTEX_DEFAULT_UNSAFE
-  uint8_t robust = PTHREAD_MUTEX_STALLED;
+  uint8_t flags = 0;
 #else
-  uint8_t robust = PTHREAD_MUTEX_ROBUST;
+  uint8_t flags = _PTHREAD_MFLAGS_ROBUST;

Review Comment:
   Those two in fact are both 1s, so code works



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] pkarashchenko merged pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
pkarashchenko merged PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173


-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173#discussion_r872401117


##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -97,7 +97,7 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
           type    = attr->type;
 #endif
 #ifdef CONFIG_PTHREAD_MUTEX_BOTH
-          robust  = attr->robust;
+          flags  = attr->robust == PTHREAD_MUTEX_ROBUST ? _PTHREAD_MFLAGS_ROBUST : 0;

Review Comment:
   ```suggestion
             flags   = (attr->robust == PTHREAD_MUTEX_ROBUST ?
                       _PTHREAD_MFLAGS_ROBUST : 0);
   ```



##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -97,7 +97,7 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
           type    = attr->type;
 #endif
 #ifdef CONFIG_PTHREAD_MUTEX_BOTH
-          robust  = attr->robust;
+          flags  = attr->robust == PTHREAD_MUTEX_ROBUST ? _PTHREAD_MFLAGS_ROBUST : 0;

Review Comment:
   ```suggestion
             flags   = (attr->robust == PTHREAD_MUTEX_ROBUST ?
                        _PTHREAD_MFLAGS_ROBUST : 0);
   ```



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173#discussion_r860852802


##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -124,11 +117,20 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
 #endif
 
 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
-      /* Initial internal fields of the mutex */
 
       mutex->flink  = NULL;
+
+#ifdef CONFIG_PTHREAD_MUTEX_BOTH
+      /* Initial internal fields of the mutex */
+
       mutex->flags  = (robust == PTHREAD_MUTEX_ROBUST ?

Review Comment:
   If you removed `uint8_t robust` at lines 72 and 74, then what is checked here?



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173#discussion_r861509226


##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -68,11 +68,9 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
 #  endif
 #endif
 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
-#ifdef CONFIG_PTHREAD_MUTEX_DEFAULT_UNSAFE
-  uint8_t robust = PTHREAD_MUTEX_STALLED;
-#else
-  uint8_t robust = PTHREAD_MUTEX_ROBUST;
-#endif
+#  ifdef CONFIG_PTHREAD_MUTEX_BOTH
+  uint8_t robust;

Review Comment:
   may not initialize if attr is NULL.



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] zhuyanlinzyl commented on a diff in pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
zhuyanlinzyl commented on code in PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173#discussion_r861428451


##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -124,11 +117,20 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
 #endif
 
 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
-      /* Initial internal fields of the mutex */
 
       mutex->flink  = NULL;
+
+#ifdef CONFIG_PTHREAD_MUTEX_BOTH
+      /* Initial internal fields of the mutex */
+
       mutex->flags  = (robust == PTHREAD_MUTEX_ROBUST ?

Review Comment:
   Yes, I add uint8_t robust when CONFIG_PTHREAD_MUTEX_BOTH is enable.



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173#discussion_r872405355


##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -69,9 +69,9 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
 #endif
 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
 #ifdef CONFIG_PTHREAD_MUTEX_DEFAULT_UNSAFE
-  uint8_t robust = PTHREAD_MUTEX_STALLED;
+  uint8_t flags = 0;
 #else
-  uint8_t robust = PTHREAD_MUTEX_ROBUST;
+  uint8_t flags = _PTHREAD_MFLAGS_ROBUST;

Review Comment:
   I think we also need to change `pthread_mutexattr_setrobust` because currently it has
   ```
   int pthread_mutexattr_setrobust(pthread_mutexattr_t *attr, int robust)
   {
   #if defined(CONFIG_PTHREAD_MUTEX_UNSAFE)
   
     if (attr != NULL && robust == PTHREAD_MUTEX_STALLED)
       {
         return OK;
       }
   
     return EINVAL;
   
   #elif defined(CONFIG_PTHREAD_MUTEX_BOTH)
   
     if (attr != NULL && (robust == PTHREAD_MUTEX_STALLED ||
         robust == _PTHREAD_MFLAGS_ROBUST))
       {
         attr->robust = robust;
         return OK;
       }
   
     return EINVAL;
   
   #else /* Default: CONFIG_PTHREAD_MUTEX_ROBUST */
   
     if (attr != NULL && robust == _PTHREAD_MFLAGS_ROBUST)
       {
         return OK;
       }
   
     return EINVAL;
   #endif
   }
   ```
   so it becomes inconsistent with this changes



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173#discussion_r872401117


##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -97,7 +97,7 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
           type    = attr->type;
 #endif
 #ifdef CONFIG_PTHREAD_MUTEX_BOTH
-          robust  = attr->robust;
+          flags  = attr->robust == PTHREAD_MUTEX_ROBUST ? _PTHREAD_MFLAGS_ROBUST : 0;

Review Comment:
   ```suggestion
             flags   = attr->robust == PTHREAD_MUTEX_ROBUST ? _PTHREAD_MFLAGS_ROBUST : 0;
   ```



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173#discussion_r872595023


##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -69,9 +69,9 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
 #endif
 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
 #ifdef CONFIG_PTHREAD_MUTEX_DEFAULT_UNSAFE
-  uint8_t robust = PTHREAD_MUTEX_STALLED;
+  uint8_t flags = 0;
 #else
-  uint8_t robust = PTHREAD_MUTEX_ROBUST;
+  uint8_t flags = _PTHREAD_MFLAGS_ROBUST;

Review Comment:
   Where it is inconsistent? you mean the error check or variable naming.



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6173: nuttx: fix coverity check error

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6173:
URL: https://github.com/apache/incubator-nuttx/pull/6173#discussion_r861488865


##########
sched/pthread/pthread_mutexinit.c:
##########
@@ -124,11 +117,20 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
 #endif
 
 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
-      /* Initial internal fields of the mutex */
 
       mutex->flink  = NULL;
+
+#ifdef CONFIG_PTHREAD_MUTEX_BOTH
+      /* Initial internal fields of the mutex */
+
       mutex->flags  = (robust == PTHREAD_MUTEX_ROBUST ?

Review Comment:
   what is the exact error reported here by coverity?



-- 
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-unsubscribe@nuttx.apache.org

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