Skip to content

Fixed !BN_copy() to BN_copy() == NULL to match openssl coding style#30573

Closed
ams4222 wants to merge 1 commit intoopenssl:masterfrom
ams4222:master
Closed

Fixed !BN_copy() to BN_copy() == NULL to match openssl coding style#30573
ams4222 wants to merge 1 commit intoopenssl:masterfrom
ams4222:master

Conversation

@ams4222
Copy link
Copy Markdown

@ams4222 ams4222 commented Mar 25, 2026

This PR cleans code to align with the coding style guide OpenSSL provides.

The BN_copy function returns a BIGNUM *. If there is an error, it returns NULL.

Before code cleanup:
if (!BN_copy(a, b))
This is an implicit check that checks if BIGNUM * is NULL. This goes against the coding style guidelines in Chapter 15.

After code cleanup:
if (BN_copy(a, b) == NULL)
This code change eliminates that implicit form to explicitly check if BIGNUM * is NULL.

All 99 instances of this implicit check have been resolved.

Fixes #30565

@ams4222
Copy link
Copy Markdown
Author

ams4222 commented Mar 25, 2026

Tagging @bbbrumley for visibility!

goto end;

err = !BN_copy(A, a);
err = (BN_copy(A, a) == NULL);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

per coding style, the project likely prefers to drop the outer parenthesis here for readability

goto end;
err = !BN_copy(B, b);
err = (BN_copy(B, b) == NULL);
if (err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NIT: per coding style, the project likely prefers to drop the outer parenthesis here for readability

@bbbrumley
Copy link
Copy Markdown
Contributor

@ams4222 thank you for the PR! I went through all lines of the diff, only spotted those two nits. Good job 👍

Go ahead and bring this out of DRAFT status, and let's get feedback from the maintainers.

(idk if they'll take a CLA waiver for this. Let's see.)

@openssl-machine openssl-machine added approval: review pending This pull request needs review by a committer hold: cla required The contributor needs to submit a license agreement labels Mar 25, 2026
@ams4222 ams4222 changed the title DRAFT fixed !BN_copy() to BN_copy() == NULL to match openssl coding style Fixed !BN_copy() to BN_copy() == NULL to match openssl coding style Mar 25, 2026
@bbbrumley
Copy link
Copy Markdown
Contributor

Thank you for the new commit!

Don't worry about the CLA check failure, it'll fall off when the commits get squashed.

LGTM, maintainers will chime in soon ;)

esyr
esyr previously approved these changes Mar 26, 2026
@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label Mar 26, 2026
@t8m t8m added branch: master Applies to master branch triaged: refactor The issue/pr requests/implements refactoring triaged: cleanup The issue/pr deals with cleanup of comments/docs not altering code significantly tests: exempted The PR is exempt from requirements for testing labels Mar 26, 2026
@t8m
Copy link
Copy Markdown
Member

t8m commented Mar 26, 2026

Although this is technically not copyrightable change, I think, we would still prefer if you could please sign CLA.
https://openssl-library.org/policies/cla/index.html

t8m
t8m previously approved these changes Mar 26, 2026
@openssl-machine openssl-machine added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Mar 26, 2026
@ams4222 ams4222 dismissed stale reviews from t8m and esyr via 87e37ea March 26, 2026 15:38
@openssl-machine openssl-machine added approval: review pending This pull request needs review by a committer and removed approval: done This pull request has the required number of approvals hold: cla required The contributor needs to submit a license agreement labels Mar 26, 2026
@ams4222
Copy link
Copy Markdown
Author

ams4222 commented Mar 26, 2026

Filled out the CLA

@openssl-machine openssl-machine added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Mar 26, 2026
@openssl-machine openssl-machine added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Mar 27, 2026
@openssl-machine
Copy link
Copy Markdown
Collaborator

This pull request is ready to merge

openssl-machine pushed a commit that referenced this pull request Mar 31, 2026
Per the coding style guide, Chapter 15, "Expressions"[1]:

    Do not use implicit checks for numbers (not) being 0 or pointers
    (not) being NULL.

Change occurrences of "!BN_copy(a, b)" checks to "BN_copy() == NULL"
to align with the coding style guide.

[1] https://www.openssl.org/policies/technical/coding-style.html#expressions

Resolves: #30565
CLA: trivial

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Tue Mar 31 00:10:41 2026
(Merged from #30573)
@esyr
Copy link
Copy Markdown
Member

esyr commented Mar 31, 2026

Pushed to master, thank you for your contribution.

@esyr esyr closed this Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Applies to master branch severity: fips change The pull request changes FIPS provider sources tests: exempted The PR is exempt from requirements for testing triaged: cleanup The issue/pr deals with cleanup of comments/docs not altering code significantly triaged: refactor The issue/pr requests/implements refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace implicit !BN_copy() checks with explicit == NULL

5 participants