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

[#491] Ensure enum string literals are null terminated #538

Conversation

orecham
Copy link
Contributor

@orecham orecham commented Dec 2, 2024

Notes for Reviewer

Fix bug where string literals were not null terminated and clean up implementation:

  1. The trait and macro were renamed (trying to be more precise):
    1. Trait: AsCStr which provides as_const_cstr() method, const alluding to the fact it is in .rodata
    2. Macro: CStrRepr so #[derive(CStrRepr)] reads more naturally
  2. The trait explicitly returns the CStr type
  3. The test now properly asserts the generated strings are valid c strings:
    assert_eq!(v1.as_const_cstr(), c"custom variant one");
    assert_eq!(v2.as_const_cstr(), c"variant two");
    
  4. Move CStrRepr macro into iceoryx2-ffi-macros since it is only used by iceoryx2-ffi

Unrelated: Also fix typo in existing assert_that message.

Pre-Review Checklist for the PR Author

  1. Add sensible notes for the reviewer
  2. PR title is short, expressive and meaningful
  3. Relevant issues are linked in the References section
  4. Every source code file has a copyright header with SPDX-License-Identifier: Apache-2.0 OR MIT
  5. Branch follows the naming format (iox2-123-introduce-posix-ipc-example)
  6. Commits messages are according to this guideline
  7. Tests follow the best practice for testing
  8. Changelog updated in the unreleased section including API breaking changes
  9. Assign PR to reviewer
  10. All checks have passed (except task-list-completed)

Checklist for the PR Reviewer

  • Commits are properly organized and messages are according to the guideline
  • Unit tests have been written for new behavior
  • Public API is documented
  • PR title describes the changes

Post-review Checklist for the PR Author

  1. All open points are addressed and tracked via issues

References

Closes #491

Copy link

codecov bot commented Dec 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.28%. Comparing base (83d797a) to head (c5ee757).
Report is 10 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #538      +/-   ##
==========================================
+ Coverage   79.04%   79.28%   +0.23%     
==========================================
  Files         203      203              
  Lines       25307    25230      -77     
==========================================
- Hits        20005    20003       -2     
+ Misses       5302     5227      -75     
Files with missing lines Coverage Δ
iceoryx2-bb/derive-macros/src/lib.rs 0.00% <ø> (ø)

... and 5 files with indirect coverage changes

iceoryx2-bb/derive-macros/src/lib.rs Outdated Show resolved Hide resolved
iceoryx2-bb/derive-macros/src/lib.rs Outdated Show resolved Hide resolved
@orecham orecham self-assigned this Dec 3, 2024
@orecham orecham force-pushed the iox2-491-fix-bug-in-enum-string-literal-generation branch 2 times, most recently from ee01d63 to bf54dfb Compare December 23, 2024 05:05
@orecham orecham force-pushed the iox2-491-fix-bug-in-enum-string-literal-generation branch 2 times, most recently from fc2e2a5 to fc6c300 Compare December 23, 2024 05:26
@orecham orecham force-pushed the iox2-491-fix-bug-in-enum-string-literal-generation branch from fc6c300 to e53f505 Compare December 23, 2024 05:32
@orecham
Copy link
Contributor Author

orecham commented Dec 23, 2024

@elfenpiff @elBoberido Finally got around to addressing issues in this PR. Only one of you needs to review.

Update:

  1. The trait explicitly returns the CStr type
  2. The trait and macro were renamed (trying to be more precise):
    1. Trait: AsCStr which provides as_const_cstr() method, const alluding to the fact it is in .rodata
    2. Macro: CStrRepr so #[derive(CStrRepr)] reads more naturally
  3. The test now properly asserts the generated strings are valid c strings:
    assert_eq!(v1.as_const_cstr(), c"custom variant one");
    assert_eq!(v2.as_const_cstr(), c"variant two");
    
  4. Move CStrRepr macro into iceoryx2-ffi-macros since it is only used by iceoryx2-ffi

@orecham orecham force-pushed the iox2-491-fix-bug-in-enum-string-literal-generation branch from e53f505 to 6dedde8 Compare December 23, 2024 05:48
@orecham orecham force-pushed the iox2-491-fix-bug-in-enum-string-literal-generation branch from 6dedde8 to c5ee757 Compare December 23, 2024 06:01
@elfenpiff elfenpiff merged commit 4fc172a into eclipse-iceoryx:main Dec 23, 2024
48 of 49 checks passed
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.

Provide error description strings via C/C++ API
3 participants