Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enforce result checking for blob and mem #4389

Merged
merged 2 commits into from
Jan 31, 2024
Merged

Conversation

jmayclin
Copy link
Contributor

@jmayclin jmayclin commented Jan 30, 2024

Description of changes:

s2n-tls has strict standard for checking the results of functions, but we rely on contributors remembering to check all of these values. This PR adds "must use" attributes to emit warnings when these conventions are not followed, and also fixed all of those warning that currently exist in our codebase.

Call-outs:

We should probably be adding MUST_USE in more places. Additionally, we should consider Werror for unit tests, but we need to fix the remaining enum-conversion warning in s2n_signature_algorithms_test.c before doing that.

Ideally we'd switch everything to S2N_RESULT, but that is a much larger effort. This PR instead aims for incremental progress.

s2n_blob_zero does not force usage of the return result because it is used in DEFER_CLEANUP's in a few places.

Testing:

I manually added the -Werror flag to our unit tests and then fixed all failures.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added the s2n-core team label Jan 30, 2024
@jmayclin jmayclin marked this pull request as ready for review January 30, 2024 23:24
@lrstewart
Copy link
Contributor

Can you change the commit name? Enforcing proper error checking isn't really "style" :P

Copy link
Contributor

@lrstewart lrstewart left a comment

Choose a reason for hiding this comment

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

If we're not going to switch to S2N_RESULT, I guess this is better than nothing.

Could you open an issue to do the same to s2n_stuffer methods? I think those are the other ones I've seen people miss a lot.

@jmayclin jmayclin changed the title style: enforce result checking for blob and mem enforce result checking for blob and mem Jan 30, 2024
@jmayclin jmayclin enabled auto-merge (squash) January 31, 2024 19:04
@jmayclin jmayclin merged commit c128140 into aws:main Jan 31, 2024
31 checks passed
@jmayclin jmayclin deleted the result-warn branch July 1, 2024 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants