Skip to content

Conversation

@lopopolo
Copy link
Collaborator

@lopopolo lopopolo commented Mar 23, 2025

  • Defend against NULL input buffer.
  • Use auto and static_cast to clean up type conversions.
  • Use BString::CopyInto API instead of raw memcpy.
  • NUL terminate the buffer if possible.

I've bumped the crate version to prep for a release. Should also include #154 before it gets cut.

I've also run this through clang-tidy and modernized things a bit.

@lopopolo lopopolo added the Tier-3 Rust Tier-3 platform label Mar 23, 2025
@lopopolo lopopolo requested a review from Kijewski March 23, 2025 03:39
@lopopolo
Copy link
Collaborator Author

@Kijewski would you be able to run the example in your haiku env?

@lopopolo lopopolo force-pushed the dev/lopopolo-haiku-null-buf branch from 44148a3 to 185a25d Compare March 23, 2025 17:00
@lopopolo lopopolo added the Unsafe-Proposed `unsafe` code is added or changed label Mar 23, 2025
- Defend against NULL input buffer.
- Use auto and static_cast to clean up type conversions.
- Use BString::CopyInto API instead of raw memcpy.
- NUL terminate the buffer if possible.
```sh
clang-tidy '--checks=*,-llvmlibc-restrict-system-libc-headers,-fuchsia-trailing-return' haiku/src/implementation.cc
```
@lopopolo lopopolo force-pushed the dev/lopopolo-haiku-null-buf branch from 4da4bca to f9b3292 Compare March 24, 2025 01:27
- extern C decl.
- [[nodiscard]] and [[maybe_unused]] attributes
- always null-terminate
- catch std::exception explicitly
- mark C ABI function as noexcept
- compare locale with nullptr
- avoid overflowing addition
- add doxygen doc comments (thanks ChatGPT)
@lopopolo
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tier-3 Rust Tier-3 platform Unsafe-Proposed `unsafe` code is added or changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant