Skip to content

Review the unsafe fn (1st round).#2396

Merged
yellowhatter merged 2 commits intoeclipse-zenoh:mainfrom
ZettaScaleLabs:review_unsafe_1
Mar 23, 2026
Merged

Review the unsafe fn (1st round).#2396
yellowhatter merged 2 commits intoeclipse-zenoh:mainfrom
ZettaScaleLabs:review_unsafe_1

Conversation

@evshary
Copy link
Copy Markdown
Contributor

@evshary evshary commented Jan 28, 2026

Description

The PR is the 1st round review dealing with #1684.
We wanted to make sure

  1. Don't use unsafe fn if we can avoid the UB inside the function
  2. Every unsafe fn should include /// # Safety
  3. Enable unsafe_op_in_unsafe_fn, which will be enabled by default in Edition 2024
  4. Having // SAFETY before an unsafe block.

What does this PR do?

Fix the unsafe fn usage inside Zenoh

Why is this change needed?

Ensure that we are using unsafe correctly.

Related Issues

#1684


🏷️ Label-Based Checklist

Based on the labels applied to this PR, please complete these additional requirements:

Labels: enhancement

✨ Enhancement Requirements

Since this PR enhances existing functionality:

  • Enhancement scope documented - Clear description of what is being improved
  • Minimum necessary code - Implementation is as simple as possible, doesn't overcomplicate the system
  • Backwards compatible - Existing code/APIs still work unchanged
  • No new APIs added - Only improving existing functionality
  • Tests updated - Existing tests pass, new test cases added if needed
  • Performance improvement measured - If applicable, before/after metrics provided
  • Documentation updated - Existing docs updated to reflect improvements
  • User impact documented - How users benefit from this enhancement

Remember: Enhancements should not introduce new APIs or breaking changes.

Instructions:

  1. Check off items as you complete them (change - [ ] to - [x])
  2. The PR checklist CI will verify these are completed

This checklist updates automatically when labels change, but preserves your checked boxes.

Signed-off-by: ChenYing Kuo <evshary@gmail.com>
@evshary evshary mentioned this pull request Jan 28, 2026
@evshary evshary added the enhancement Existing things could work better label Jan 28, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 28, 2026

Codecov Report

❌ Patch coverage is 40.00000% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.47%. Comparing base (58c41b5) to head (7a5dc70).
⚠️ Report is 8 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
commons/zenoh-util/src/ffi/mod.rs 0.00% 10 Missing ⚠️
commons/zenoh-util/src/lib_loader.rs 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2396      +/-   ##
==========================================
- Coverage   72.63%   72.47%   -0.16%     
==========================================
  Files         390      390              
  Lines       63366    63370       +4     
==========================================
- Hits        46026    45930      -96     
- Misses      17340    17440     +100     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@evshary evshary requested a review from yellowhatter January 30, 2026 03:51
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
@yellowhatter yellowhatter merged commit 1536e94 into eclipse-zenoh:main Mar 23, 2026
28 checks passed
@evshary evshary deleted the review_unsafe_1 branch March 24, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Existing things could work better

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants