Skip to content

Remove redundant return statements in UDP interconnect code#1829

Open
MutableFire wants to merge 2 commits into
apache:mainfrom
MutableFire:returns-remove
Open

Remove redundant return statements in UDP interconnect code#1829
MutableFire wants to merge 2 commits into
apache:mainfrom
MutableFire:returns-remove

Conversation

@MutableFire

@MutableFire MutableFire commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

In C, reaching the closing brace } of a void function implicitly returns control to the caller. Explicit return; statements in these positions are unnecessary noise that clutters the code. Removing them aligns the code with common C style guidelines and improves readability.

@tuhaihe

tuhaihe commented Jun 24, 2026

Copy link
Copy Markdown
Member

In C, reaching the closing brace } of a void function implicitly returns control to the caller. Explicit return; statements in these positions are unnecessary noise that clutters the code. Removing them aligns the code with common C style guidelines and improves readability.

Hi @MutableFire welcome to add these description to the commit message body.

Can take the .gitmessage as a commit template, FYI.

@MutableFire MutableFire force-pushed the returns-remove branch 5 times, most recently from 809681e to ec51c28 Compare June 24, 2026 09:44
In C, reaching the closing brace of a void function implicitly returns
control to the caller. Explicit 'return;' statements in these positions
are unnecessary noise that clutters the code. Removing them aligns the
code with common C style guidelines and improves readability.
@MutableFire

Copy link
Copy Markdown
Contributor Author

In C, reaching the closing brace } of a void function implicitly returns control to the caller. Explicit return; statements in these positions are unnecessary noise that clutters the code. Removing them aligns the code with common C style guidelines and improves readability.

Hi @MutableFire welcome to add these description to the commit message body.

Can take the .gitmessage as a commit template, FYI.

Done.

pg_freeaddrinfo_all(hint.ai_family, addrs);
if (sockfd != -1)
closesocket(sockfd);
return;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

any gcc warning ? I think no need if no warning.

@MutableFire MutableFire Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, there were no gcc warnings.
My main motivation, as described in the PR, is simply code clarity. I believe we should avoid unnecessary lines that don't add logic, as they make the code harder to read.
While I agree we should minimize diffs from upstream for standard PostgreSQL code, this is our own custom code. Therefore, I think it's perfectly fine to refine its style and clean it up.
Could you clarify your concern? Is there a specific reason you prefer keeping these return statements?

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