Skip to content

examples/rust: Remove some redundant unsafe blocks #34

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

Merged
merged 1 commit into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/rust/echo-request/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub extern "C" fn uwr_request_handler(addr: *mut u8) -> i32 {
uwr_init_ctx(ctx, addr, 4096);

// Set where we will copy the request into
uwr_set_req_buf(ctx, unsafe { addr_of_mut!(REQUEST_BUF) }, LUW_SRB_NONE);
uwr_set_req_buf(ctx, addr_of_mut!(REQUEST_BUF), LUW_SRB_NONE);

// Define the Response Body Text.

Expand Down
4 changes: 2 additions & 2 deletions examples/rust/large-upload/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub unsafe extern "C" fn uwr_response_end_handler() {

#[no_mangle]
pub extern "C" fn uwr_request_handler(addr: *mut u8) -> i32 {
let ctx: *mut luw_ctx_t = unsafe { addr_of_mut!(CTX) };
let ctx: *mut luw_ctx_t = addr_of_mut!(CTX);
let mut f;
let bytes_wrote: isize;
let mut total = unsafe { TOTAL_BYTES_WROTE };
Expand All @@ -41,7 +41,7 @@ pub extern "C" fn uwr_request_handler(addr: *mut u8) -> i32 {
uwr_init_ctx(ctx, addr, 0);
uwr_set_req_buf(
ctx,
unsafe { addr_of_mut!(REQUEST_BUF) },
addr_of_mut!(REQUEST_BUF),
LUW_SRB_NONE,
);

Expand Down
4 changes: 2 additions & 2 deletions examples/rust/upload-reflector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub fn upload_reflector(ctx: *mut luw_ctx_t) -> i32 {

#[no_mangle]
pub extern "C" fn uwr_request_handler(addr: *mut u8) -> i32 {
let ctx: *mut luw_ctx_t = unsafe { addr_of_mut!(CTX) };
let ctx: *mut luw_ctx_t = addr_of_mut!(CTX);

if unsafe { REQUEST_BUF.is_null() } {
uwr_init_ctx(ctx, addr, 0 /* Response offset */);
Expand All @@ -87,7 +87,7 @@ pub extern "C" fn uwr_request_handler(addr: *mut u8) -> i32 {
*/
uwr_set_req_buf(
ctx,
unsafe { addr_of_mut!(REQUEST_BUF) },
addr_of_mut!(REQUEST_BUF),
LUW_SRB_APPEND | LUW_SRB_ALLOC | LUW_SRB_FULL_SIZE,
);
} else {
Expand Down