pkarashchenko commented on code in PR #12969:
URL: https://github.com/apache/nuttx/pull/12969#discussion_r1723393953


##########
fs/vfs/fs_lock.c:
##########
@@ -602,6 +608,8 @@ int file_getlk(FAR struct file *filep, FAR struct flock 
*flock)
       flock->l_len = flock->l_end - flock->l_start + 1;
     }
 
+out_free:
+  lib_put_pathbuffer(path);
   return OK;

Review Comment:
   should we `return ret;` here instead?



##########
libs/libc/misc/lib_pathbuffer.c:
##########
@@ -0,0 +1,146 @@
+/****************************************************************************
+ * libs/libc/misc/lib_pathbuffer.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/mutex.h>
+#include <nuttx/lib/lib.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+/****************************************************************************
+ * Pre-processor definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct pathbuffer_s
+{
+  mutex_t lock;         /* Lock for the buffer */
+  int free_bitmap;      /* Bitmap of free buffer */

Review Comment:
   ```suggestion
     unsigned int free_bitmap;      /* Bitmap of free buffer */
   ```



##########
fs/vfs/fs_lock.c:
##########
@@ -774,6 +808,8 @@ void file_closelk(FAR struct file *filep)
     }
 
   nxmutex_unlock(&g_protect_lock);
+out:
+  lib_put_pathbuffer(path);

Review Comment:
   Maybe better
   ```suggestion
   out:
     nxmutex_unlock(&g_protect_lock);
   out_free:
     lib_put_pathbuffer(path);
   ```
   and remove `nxmutex_unlock(&g_protect_lock);` before `goto out;`?



##########
fs/vfs/fs_lock.c:
##########
@@ -731,36 +752,49 @@ void file_closelk(FAR struct file *filep)
   FAR struct file_lock_bucket_s *bucket;
   FAR struct file_lock_s *file_lock;
   FAR struct file_lock_s *temp;
-  char path[PATH_MAX];
+  FAR char *path;
   bool deleted = false;
   int ret;
 
+  if (filep->locked == false)

Review Comment:
   ```suggestion
     if (!filep->locked)
   ```



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