Skip to content

[lib][console] Remove redundant NULL checks before free#518

Merged
travisg merged 1 commit into
littlekernel:masterfrom
TzengKyle:cocci/free
Jul 3, 2026
Merged

[lib][console] Remove redundant NULL checks before free#518
travisg merged 1 commit into
littlekernel:masterfrom
TzengKyle:cocci/free

Conversation

@TzengKyle

Copy link
Copy Markdown
Contributor

Summary

Remove redundant NULL checks before free() in lib/console/console.c.

In the no_mem_error path of command_loop(), free(outbuf) and free(args) are sufficient because free(NULL) is defined as a no-op in C. This simplifies the cleanup path without changing behavior.

Testing

-make qemu-virt-arm64-test

Copilot AI review requested due to automatic review settings July 3, 2026 04:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR simplifies the command_loop() cleanup path in LK’s console library by removing redundant NULL checks before calling free() in the no_mem_error: label.

Changes:

  • Replace if (ptr) free(ptr); patterns with unconditional free(outbuf); free(args); in the no_mem_error cleanup path.
  • Align the error-path cleanup style with the already-unconditional cleanup used on the normal return path in the same function.

@travisg travisg merged commit 88f5a3d into littlekernel:master Jul 3, 2026
120 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants