Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #107 from Tropix126/fix/robot-macro-unsafe-scope
Browse files Browse the repository at this point in the history
fix: disallow unsafe code in robot macros
  • Loading branch information
Gavin-Niederman authored Mar 13, 2024
2 parents b51dc26 + 5f39db3 commit db1e06f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Before releasing:
### Fixed

- `pros_sys` bindings to the Motors C API now takes the correct port type (`i8`) as of PROS 4 (**Breaking Change**) (#66).
- Fixed the unintended `unsafe` context present in the `sync_robot` and `async_robot` family of macros (**Breaking Change**) (#107).

### Changed

Expand Down
6 changes: 4 additions & 2 deletions packages/pros-async/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ macro_rules! async_robot {

#[no_mangle]
extern "C" fn initialize() {
let robot = Default::default();
unsafe {
ROBOT = Some(Default::default());
ROBOT = Some(robot);
}
}
};
Expand All @@ -195,8 +196,9 @@ macro_rules! async_robot {

#[no_mangle]
extern "C" fn initialize() {
let robot = $init;
unsafe {
ROBOT = Some($init);
ROBOT = Some(robot);
}
}
};
Expand Down
6 changes: 4 additions & 2 deletions packages/pros-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ macro_rules! sync_robot {

#[no_mangle]
extern "C" fn initialize() {
let robot = Default::default();
unsafe {
ROBOT = Some(Default::default());
ROBOT = Some(robot);
}
}
};
Expand All @@ -133,8 +134,9 @@ macro_rules! sync_robot {

#[no_mangle]
extern "C" fn initialize() {
let robot = $init;
unsafe {
ROBOT = Some($init);
ROBOT = Some(robot);
}
}
};
Expand Down

0 comments on commit db1e06f

Please sign in to comment.