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

utils: add map iteration iterator #4377

Merged
merged 13 commits into from
Feb 2, 2024
Merged

utils: add map iteration iterator #4377

merged 13 commits into from
Feb 2, 2024

Conversation

jmayclin
Copy link
Contributor

Description of changes:

For #4339 we need to be able to iterate through the certs that are stored on the s2n_config.domain_name_to_cert_map. This PR adds iteration functionality to allow iteration over the values in a map. It also adds a simple helper to retrieve the size of a map.

Call-outs:

I purposely am not returning S2N_RESULT from the s2n_map_iterator_free function to avoid an "unused return value" warning when using DEFER_CLEANUP.

Testing:

Unit test cases have been added to test new functionality.

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

* shadow variables in test
* fix pointer alignment, because clang won't?
@jmayclin jmayclin marked this pull request as ready for review January 25, 2024 17:35
utils/s2n_map.h Outdated Show resolved Hide resolved
utils/s2n_map.h Outdated Show resolved Hide resolved
utils/s2n_map.c Outdated Show resolved Hide resolved
- use S2N_CLEANUP_RESULT
- use init rather than new
tests/unit/s2n_map_test.c Show resolved Hide resolved
utils/s2n_map.c Outdated Show resolved Hide resolved
utils/s2n_map.h Outdated Show resolved Hide resolved
This is necessary to allow for us to construct an s2n_map_iterator on
the stack.
@jmayclin jmayclin requested a review from lrstewart January 29, 2024 17:36
utils/s2n_map.h Outdated Show resolved Hide resolved
utils/s2n_map.c Outdated Show resolved Hide resolved
utils/s2n_map.c Outdated Show resolved Hide resolved
- remove pre-increment usage
- add explicit flag to track consumption
- remove unused header
- minimize diff in test file
@jmayclin jmayclin requested a review from lrstewart January 30, 2024 01:20
utils/s2n_map.c Show resolved Hide resolved
utils/s2n_map.c Outdated Show resolved Hide resolved
utils/s2n_map.c Outdated Show resolved Hide resolved
utils/s2n_map.c Show resolved Hide resolved
utils/s2n_map.c Outdated Show resolved Hide resolved
tests/unit/s2n_map_test.c Outdated Show resolved Hide resolved
tests/unit/s2n_map_iterator_test.c Outdated Show resolved Hide resolved
utils/s2n_map.c Outdated Show resolved Hide resolved
tests/unit/s2n_map_iterator_test.c Outdated Show resolved Hide resolved
tests/unit/s2n_map_iterator_test.c Outdated Show resolved Hide resolved
- add missed return assertions
- switch to expect-error-with-errno
- has_next returns bool
- define test constants
- remove unused variables
- remove unused functions
@jmayclin jmayclin requested a review from lrstewart January 31, 2024 01:21
utils/s2n_map.c Outdated Show resolved Hide resolved
tests/unit/s2n_map_iterator_test.c Outdated Show resolved Hide resolved
utils/s2n_map.c Outdated Show resolved Hide resolved
utils/s2n_map.c Outdated Show resolved Hide resolved
- switch error message for no more next
- add additional ensure ref
- call has_next rather than checking iterator
- fix error in test case
- missed the removal of a direct iterator check
@jmayclin jmayclin requested a review from lrstewart February 1, 2024 07:39
- some incredibly kind and thoughtful person added return-value-checks
  to our CI ☺️
@jmayclin jmayclin enabled auto-merge (squash) February 2, 2024 02:25
@jmayclin jmayclin disabled auto-merge February 2, 2024 02:26
@jmayclin jmayclin enabled auto-merge (squash) February 2, 2024 02:26
@jmayclin jmayclin requested a review from dougch as a code owner February 2, 2024 18:06
@jmayclin jmayclin removed the request for review from dougch February 2, 2024 19:11
@jmayclin jmayclin merged commit 33382e6 into aws:main Feb 2, 2024
31 checks passed
@jmayclin jmayclin deleted the map-iterator branch June 15, 2024 00:17
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