Skip to content

linux: drop unnecessary code#2003

Merged
giuseppe merged 1 commit intocontainers:mainfrom
eriksjolund:drop-unnecessary-code
Feb 9, 2026
Merged

linux: drop unnecessary code#2003
giuseppe merged 1 commit intocontainers:mainfrom
eriksjolund:drop-unnecessary-code

Conversation

@eriksjolund
Copy link
Contributor

Any negative number will do. There is no need to explicitly set labelfd to -1.

cleanup_close only closes when the number is non-negative.

crun/src/libcrun/utils.h

Lines 103 to 109 in d0c1224

static inline void
cleanup_closep (void *p)
{
int *pp = (int *) p;
if (*pp >= 0)
TEMP_FAILURE_RETRY (close (*pp));
}

@gemini-code-assist
Copy link

Summary of Changes

Hello @eriksjolund, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on code simplification within the libcrun project by eliminating a redundant line of code. Specifically, it removes an explicit assignment of -1 to the labelfd variable after an error condition. This change is justified because the cleanup_close utility function, which is responsible for closing file descriptors, is designed to correctly handle any non-positive value, thus rendering the explicit -1 assignment unnecessary and improving code clarity.

Highlights

  • Code Cleanup: Removed an unnecessary assignment of labelfd = -1 in src/libcrun/linux.c. The cleanup_close function correctly handles any non-positive file descriptor value, making the explicit -1 assignment redundant after an error.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/libcrun/linux.c
    • Removed the line labelfd = -1; within the error handling block, as it was redundant.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request proposes a minor code cleanup by removing a redundant assignment. In the error path, the labelfd variable is already guaranteed to hold a negative value from the return of the function call. Therefore, explicitly re-assigning it to -1 is unnecessary for the subsequent logic that checks if labelfd >= 0. The change is correct and makes the code slightly more concise. I have no issues with this modification.

@packit-as-a-service
Copy link

TMT tests failed. @containers/packit-build please check.

Copy link
Collaborator

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

I tend to agree, it doesn't do anything nor it improves readability.

@eriksjolund can you please put the PR description into the commit description?

@eriksjolund eriksjolund force-pushed the drop-unnecessary-code branch from 1242f5f to 0ec442c Compare February 9, 2026 07:15
Any negative number will do. There is no need to explicitly set `labelfd` to `-1`.
cleanup_close only closes when the number is non-negative.
See:
https://github.com/containers/crun/blob/d0c1224f0d4d3525b8a3414efe3dbc5f3177637f/src/libcrun/utils.h#L103-L109

Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
@eriksjolund eriksjolund force-pushed the drop-unnecessary-code branch from 0ec442c to 8fa7341 Compare February 9, 2026 07:18
@packit-as-a-service
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@eriksjolund
Copy link
Contributor Author

@eriksjolund can you please put the PR description into the commit description?

Done

@packit-as-a-service
Copy link

TMT tests failed. @containers/packit-build please check.

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

@giuseppe giuseppe merged commit 9f30f81 into containers:main Feb 9, 2026
42 of 47 checks passed
@eriksjolund eriksjolund deleted the drop-unnecessary-code branch February 12, 2026 09:44
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