jingfei195887 opened a new pull request, #21806:
URL: https://github.com/apache/nuttx/pull/21806

   ## Summary
   
   * The `subdir` variable in `mountptrename()` is initialized to NULL and
     never assigned again, so the `subdir != NULL` check and the
     `fs_heap_free()` call on the error path can never run.
   * Remove the variable and the unreachable cleanup block. The `subdir` in
     `pseudorename()` is set by `fs_heap_asprintf()` and is left untouched.
   
   ## Impact
   
   * New or changed feature: NO, dead code removal only.
   * Impact on user: NO.
   * Impact on build: NO.
   * Impact on hardware: NO.
   * Impact on documentation: NO.
   * Impact on security: NO.
   * Impact on compatibility: NO, `rename()` behaves the same.
   
   ## Testing
   
   I confirm that changes are verified on local setup and works as intended:
   * Build Host: Ubuntu 22.04 x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0
   * Target: `sim:nsh` with `CONFIG_FS_TMPFS`, master 5d79bf455d. Verified on
     sim only.
   
   A tmpfs mount exercises `mountptrename()`: rename a file and a directory,
   move a directory into its own subdirectory, a missing source and a missing
   destination directory. The output is identical before and after:
   
   ```
   nsh> mv /t/f /t/g          (ok, cat /t/g prints "hello")
   nsh> mv /t/d /t/e          (ok)
   nsh> mv /t/e /t/e/sub/x
   nsh: mv: rename failed: 22
   nsh> mv /t/nofile /t/x
   nsh: mv: rename failed: 2
   nsh> mv /t/g /t/nodir/x
   nsh: mv: rename failed: 2
   ```
   
   * `./tools/checkpatch.sh -m -g master..HEAD`: all checks pass.
   * Make and CMake builds pass with no new warnings; `ostest` exits with
     status 0.
   
   ## PR verification Self-Check
   
   * [x] This PR introduces only one functional change.
   * [x] I have updated all required description fields above.
   * [x] My PR adheres to Contributing Guidelines and Documentation (git commit
     title and message, coding standard, etc).
   * [ ] My PR is still work in progress (not ready for review).
   * [x] My PR is ready for review and can be safely merged into a codebase.
   


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