xiaoxiang781216 commented on code in PR #15198:
URL: https://github.com/apache/nuttx/pull/15198#discussion_r1886067983


##########
libs/libc/misc/lib_pathbuffer.c:
##########
@@ -82,21 +80,24 @@ static struct pathbuffer_s g_pathbuffer =
 
 FAR char *lib_get_pathbuffer(void)
 {
-  irqstate_t flags;
   int index;
+  uint32_t free_bitmap;
 
-  /* Try to find a free buffer */
-
-  flags = spin_lock_irqsave(&g_pathbuffer.lock);
-  index = ffsl(g_pathbuffer.free_bitmap) - 1;
-  if (index >= 0 && index < CONFIG_LIBC_PATHBUFFER_MAX)
+  do
     {
-      g_pathbuffer.free_bitmap &= ~(1u << index);
-      spin_unlock_irqrestore(&g_pathbuffer.lock, flags);
-      return g_pathbuffer.buffer[index];
+      free_bitmap = atomic_read(&g_pathbuffer.free_bitmap);
+      index = ffsl(free_bitmap) - 1;
+      if (index >= 0 && index < CONFIG_LIBC_PATHBUFFER_MAX)

Review Comment:
   ```
   if (index < 0)
     {
        break;
     }
   ```



##########
libs/libc/misc/lib_pathbuffer.c:
##########
@@ -82,21 +80,24 @@ static struct pathbuffer_s g_pathbuffer =
 
 FAR char *lib_get_pathbuffer(void)
 {
-  irqstate_t flags;
   int index;
+  uint32_t free_bitmap;
 
-  /* Try to find a free buffer */
-
-  flags = spin_lock_irqsave(&g_pathbuffer.lock);
-  index = ffsl(g_pathbuffer.free_bitmap) - 1;
-  if (index >= 0 && index < CONFIG_LIBC_PATHBUFFER_MAX)
+  do

Review Comment:
   for (; ; )



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to