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


##########
libs/libc/misc/lib_pathbuffer.c:
##########
@@ -82,22 +80,24 @@ static struct pathbuffer_s g_pathbuffer =
 
 FAR char *lib_get_pathbuffer(void)
 {
-  irqstate_t flags;
-  int index;
-
-  /* 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)
+  for (; ; )
     {
-      g_pathbuffer.free_bitmap &= ~(1u << index);
-      spin_unlock_irqrestore(&g_pathbuffer.lock, flags);
-      return g_pathbuffer.buffer[index];
+      int32_t free_bitmap = atomic_read(&g_pathbuffer.free_bitmap);
+      int index = ffsl(free_bitmap) - 1;
+      if (index < 0 || index >= CONFIG_LIBC_PATHBUFFER_MAX)
+        {
+          break;
+        }
+
+      int32_t update;

Review Comment:
   move to the beginning of loop



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