Browse Source

[components][libc][posix] fix RT_NAME_MAX misspelled as NAME_MAX (#7489)

DylanLiuH2O 2 years ago
parent
commit
92a253c88f
1 changed files with 3 additions and 3 deletions
  1. 3 3
      components/libc/posix/ipc/mqueue.c

+ 3 - 3
components/libc/posix/ipc/mqueue.c

@@ -138,7 +138,7 @@ mqd_t mq_open(const char *name, int oflag, ...)
     /* lock posix mqueue list */
     /* lock posix mqueue list */
     rt_sem_take(&posix_mq_lock, RT_WAITING_FOREVER);
     rt_sem_take(&posix_mq_lock, RT_WAITING_FOREVER);
     int len = rt_strlen(name);
     int len = rt_strlen(name);
-    if (len > PATH_MAX || len > NAME_MAX)
+    if (len > PATH_MAX || len > RT_NAME_MAX)
     {
     {
         rt_set_errno(ENAMETOOLONG);
         rt_set_errno(ENAMETOOLONG);
         goto __return;
         goto __return;
@@ -159,9 +159,9 @@ mqd_t mq_open(const char *name, int oflag, ...)
     {
     {
         va_start(arg, oflag);
         va_start(arg, oflag);
         mode = (mode_t)va_arg(arg, unsigned int);
         mode = (mode_t)va_arg(arg, unsigned int);
-        mode = mode;
+        mode = (mode_t)mode; /* self-assignment avoids compiler optimization */
         attr = (struct mq_attr *)va_arg(arg, struct mq_attr *);
         attr = (struct mq_attr *)va_arg(arg, struct mq_attr *);
-        attr = attr;
+        attr = (struct mq_attr *)attr; /* self-assignment avoids compiler optimization */
         va_end(arg);
         va_end(arg);
 
 
         if (attr->mq_maxmsg <= 0)
         if (attr->mq_maxmsg <= 0)