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 2020/08/17 14:27:48 UTC

[GitHub] [incubator-nuttx] ghn-certi commented on a change in pull request #1596: libc: Replace all [nx]sem_xxx with _SEM_XXX

ghn-certi commented on a change in pull request #1596:
URL: https://github.com/apache/incubator-nuttx/pull/1596#discussion_r471514302



##########
File path: libs/libc/wqueue/work_usrthread.c
##########
@@ -362,79 +362,73 @@ static pthread_addr_t work_usrthread(pthread_addr_t arg)
 
 int work_usrstart(void)
 {
-  /* Initialize work queue data structures */
-
 #ifdef CONFIG_BUILD_PROTECTED
-  {
-    /* Set up the work queue lock */
+  /* Set up the work queue lock */
 
-    nxsem_init(&g_usrsem, 0, 1);
+  _SEM_INIT(&g_usrsem, 0, 1);
 
-    /* Start a user-mode worker thread for use by applications. */
+  /* Start a user-mode worker thread for use by applications. */
 
-    g_usrwork.pid = task_create("uwork",
-                                CONFIG_LIB_USRWORKPRIORITY,
-                                CONFIG_LIB_USRWORKSTACKSIZE,
-                                (main_t)work_usrthread,
-                                (FAR char * const *)NULL);
+  g_usrwork.pid = task_create("uwork",
+                              CONFIG_LIB_USRWORKPRIORITY,
+                              CONFIG_LIB_USRWORKSTACKSIZE,
+                              (main_t)work_usrthread,
+                              (FAR char * const *)NULL);
 
-    DEBUGASSERT(g_usrwork.pid > 0);
-    if (g_usrwork.pid < 0)
-      {
-        int errcode = get_errno();
-        DEBUGASSERT(errcode > 0);
-        return -errcode;
-      }
+  DEBUGASSERT(g_usrwork.pid > 0);
+  if (g_usrwork.pid < 0)
+    {
+      int errcode = get_errno();
+      DEBUGASSERT(errcode > 0);
+      return -errcode;
+    }
 
-    return g_usrwork.pid;
-  }
+  return g_usrwork.pid;
 #else
-  {
-    pthread_t usrwork;
-    pthread_attr_t attr;
-    struct sched_param param;
-    int ret;
+  pthread_t usrwork;
+  pthread_attr_t attr;
+  struct sched_param param;
+  int ret;
 
-    /* Set up the work queue lock */
+  /* Set up the work queue lock */
 
-    pthread_mutex_init(&g_usrmutex, NULL);
+  pthread_mutex_init(&g_usrmutex, NULL);
 
-    /* Start a user-mode worker thread for use by applications. */
+  /* Start a user-mode worker thread for use by applications. */
 
-    pthread_attr_init(&attr);
-    pthread_attr_setstacksize(&attr, CONFIG_LIB_USRWORKSTACKSIZE);
+  pthread_attr_init(&attr);
+  pthread_attr_setstacksize(&attr, CONFIG_LIB_USRWORKSTACKSIZE);
 
 #ifdef CONFIG_SCHED_SPORADIC
-    /* Get the current sporadic scheduling parameters.  Those will not be
-     * modified.
-     */
-
-    ret = set_getparam(pid, &param);
-    if (ret < 0)
-      {
-        int erroode = get_errno();
-        return -errcode;
-      }
+  /* Get the current sporadic scheduling parameters.  Those will not be
+   * modified.
+   */
+
+  ret = set_getparam(pid, &param);
+  if (ret < 0)
+    {
+      int erroode = get_errno();

Review comment:
       ```suggestion
         int errcode = get_errno();
   ```
   I know that this typo was not introduced by this PR, but this file probably would not even build in case CONFIG_SCHED_SPORADIC is enabled, right?




----------------------------------------------------------------
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.

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