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

capi: Fix 'unused return value' warnings #882

Merged
merged 2 commits into from
Jul 14, 2022
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 regex-capi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ffi_fn! {

ffi_fn! {
fn rure_error_free(err: *mut Error) {
unsafe { Box::from_raw(err); }
unsafe { drop(Box::from_raw(err)); }
}
}

Expand Down
18 changes: 9 additions & 9 deletions regex-capi/src/rure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ ffi_fn! {

ffi_fn! {
fn rure_free(re: *const Regex) {
unsafe { Box::from_raw(re as *mut Regex); }
unsafe { drop(Box::from_raw(re as *mut Regex)); }
}
}

Expand Down Expand Up @@ -257,10 +257,10 @@ ffi_fn! {
fn rure_iter_capture_names_free(it: *mut IterCaptureNames) {
unsafe {
let it = &mut *it;
while let Some(ptr) = it.name_ptrs.pop(){
CString::from_raw(ptr);
while let Some(ptr) = it.name_ptrs.pop() {
drop(CString::from_raw(ptr));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might as well go the whole nine yards here and add drop(..) around other calls to from_raw as well. e.g., Box::from_raw. Would you mind doing that as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review comment. I searched Box::from_raw and applied the same fix at 1324f2d

}
Box::from_raw(it);
drop(Box::from_raw(it));
}
}
}
Expand Down Expand Up @@ -316,7 +316,7 @@ ffi_fn! {

ffi_fn! {
fn rure_iter_free(it: *mut Iter) {
unsafe { Box::from_raw(it); }
unsafe { drop(Box::from_raw(it)); }
}
}

Expand Down Expand Up @@ -407,7 +407,7 @@ ffi_fn! {

ffi_fn! {
fn rure_captures_free(captures: *const Captures) {
unsafe { Box::from_raw(captures as *mut Captures); }
unsafe { drop(Box::from_raw(captures as *mut Captures)); }
}
}

Expand Down Expand Up @@ -447,7 +447,7 @@ ffi_fn! {

ffi_fn! {
fn rure_options_free(options: *mut Options) {
unsafe { Box::from_raw(options); }
unsafe { drop(Box::from_raw(options)); }
}
}

Expand Down Expand Up @@ -527,7 +527,7 @@ ffi_fn! {

ffi_fn! {
fn rure_set_free(re: *const RegexSet) {
unsafe { Box::from_raw(re as *mut RegexSet); }
unsafe { drop(Box::from_raw(re as *mut RegexSet)); }
}
}

Expand Down Expand Up @@ -624,6 +624,6 @@ fn rure_escape(

ffi_fn! {
fn rure_cstring_free(s: *mut c_char) {
unsafe { CString::from_raw(s); }
unsafe { drop(CString::from_raw(s)); }
}
}