You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "bettermultiply (via GitHub)" <gi...@apache.org> on 2025/12/25 16:11:01 UTC

[I] C bindings: Panic across FFI boundaries and duplicate mode [opendal]

bettermultiply opened a new issue, #7101:
URL: https://github.com/apache/opendal/issues/7101

   Hi, I am reading Opendal's C bindings(and hoping to do some contribute).
   
   I find that there are several codes share the same pattern:
   ```
   assert!(!scheme.is_null());
   let scheme = std::ffi::CStr::from_ptr(scheme)
       .to_str()
       .expect("malformed scheme");
   ```
   Is it better to encapsulate it into a function like `parse_c_string(*const c_char)` ? 
   
   And I notice that the panic generate from assert!() will be accross FFI boundaries which is undefined behavior(I see this in a post three years ago, I do not know whether it is still the truth). Is it good to use `assert!` here? or replace it with error, which can be caught by `opendal_error`. 
   
   Or the panic is just expected here for the error will only happen when developing and won't happen in production, so ruin the whole program is the best choice here?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] C bindings: Panic across FFI boundaries and duplicate mode [opendal]

Posted by "bettermultiply (via GitHub)" <gi...@apache.org>.
bettermultiply commented on issue #7101:
URL: https://github.com/apache/opendal/issues/7101#issuecomment-3691587026

   I also have doubts if it's too simple to wrap. I'm only raising this idea from a readability perspective, and I believe it won't result in much performance loss (of course, I'm a newbie, and this view is very likely wrong TT). 
   
   Hoping a C expert can give me an answer(lesson).
   
   Thank you for your quick respons. ❤️


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] C bindings: Panic across FFI boundaries and duplicate mode [opendal]

Posted by "bettermultiply (via GitHub)" <gi...@apache.org>.
bettermultiply closed issue #7101: C bindings: Panic across FFI boundaries and duplicate mode
URL: https://github.com/apache/opendal/issues/7101


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] C bindings: Panic across FFI boundaries and duplicate mode [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #7101:
URL: https://github.com/apache/opendal/issues/7101#issuecomment-3691601292

   Thank you for your interest! Compared to readability issues, we might create a more enjoyable experience by implementing more meaningful features in the C bindings. For instance, we could introduce the newly added `ReadOptions` and `WriteOptions` in the C bindings, allowing C-side users to fully use these features.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] C bindings: Panic across FFI boundaries and duplicate mode [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #7101:
URL: https://github.com/apache/opendal/issues/7101#issuecomment-3691578760

   > Is it better to encapsulate it into a function like parse_c_string(*const c_char) ?
   
   It might be, but I'm not a C expert. This code may be simple enough that it isn't worth a wrapper.
   
   > Or the panic is just expected here for the error will only happen when developing and won't happen in production, so ruin the whole program is the best choice here?
   
   Yes, this should not happen under any circumstances.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] C bindings: Panic across FFI boundaries and duplicate mode [opendal]

Posted by "bettermultiply (via GitHub)" <gi...@apache.org>.
bettermultiply commented on issue #7101:
URL: https://github.com/apache/opendal/issues/7101#issuecomment-3691652381

   Oh, I'm also very interested in this and I'd really like to try it. Thanks for telling me and give me hints. 
   So far, my question has been solved, so I'll close this issue. Hoping that I can bring another issue/pr that makes us enjoy =)
   
   Thank you again.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org