crafcat7 commented on code in PR #15198:
URL: https://github.com/apache/nuttx/pull/15198#discussion_r1886553089
##########
libs/libc/misc/lib_pathbuffer.c:
##########
@@ -82,22 +80,26 @@ static struct pathbuffer_s g_pathbuffer =
FAR char *lib_get_pathbuffer(void)
{
- irqstate_t flags;
int index;
+ int32_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)
+ for (; ; )
{
- 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)
+ {
+ break;
+ }
+
+ int32_t update = free_bitmap & ~(1u << index);
Review Comment:
Done
##########
libs/libc/misc/lib_pathbuffer.c:
##########
@@ -82,22 +80,26 @@ static struct pathbuffer_s g_pathbuffer =
FAR char *lib_get_pathbuffer(void)
{
- irqstate_t flags;
int index;
Review Comment:
Done
--
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]