GithubHelp home page GithubHelp logo

Comments (6)

DrTobe avatar DrTobe commented on August 10, 2024 1

@osobiehl These functions are completely unused and just for compile-time checks. If you just want the code to compile, remove these functions and try again.

from rust-mbedtls.

Taowyoo avatar Taowyoo commented on August 10, 2024

Hi @DrTobe , I guess this error is related to : 612e36c . Did you remember why you made this change?

It seems that that commit hard coded the size of many C types (which may change in different platform) when computing the size of contexts.

And more importantly, the size of these contexts actually are not able to be hard coded since the type definitions in C side can change with different config.

from rust-mbedtls.

DrTobe avatar DrTobe commented on August 10, 2024

The reasoning for these semi-hardcoded sizes is explained in the comment above:

// If the C API changes, the serde implementation needs to be reviewed for correctness. The
// following (unused) functions will most probably fail to compile when this happens so a
// compilation failure here reminds us of reviewing the serde impl.

Actually, I have tried to make this a little bit more platform-independent. Before, the sizes were fully-hardcoded with a 64-bit platform in mind. I changed these sizes to be dynamic in commit 5027a7c but that defeats the purpose of these checks. So I tried to calculate these sizes in a platform-independent way. Apparently, this does not work for some platforms.

Actually, it is unnecessarily painful to calculate C type sizes by hand for different platforms. Should we try to find a completely different approach here which avoids manual size calculations? Maybe, we could copy+translate the expected C types to Rust with a #[repr(C)] attribute. Then, we could just compare the sizes of the copied Rust types and the actual C types. Whenever the C types change, these should be different.

from rust-mbedtls.

Taowyoo avatar Taowyoo commented on August 10, 2024

@DrTobe I see what you mean here.
And regarding the different approach you mentioned, I think it can be achieved by having a copy if the bindgen rust code here, so we could use it for checking if C API is changed

from rust-mbedtls.

DrTobe avatar DrTobe commented on August 10, 2024

That sounds smart but there is still the problem you mentioned above:

And more importantly, the size of these contexts actually are not able to be hard coded since the type definitions in C side can change with different config.

How can we handle the config changes then?

from rust-mbedtls.

Taowyoo avatar Taowyoo commented on August 10, 2024

I think my words about config changes was wrong.
Because with a specific version of mbedtls-sys , there is no feature about changing the config that will results the change on definition of those contexts.
So that's not a problem, and if a different version of mbedtls-sys is using with different definition of contexts, then it fails in the case why we need these checks here.

from rust-mbedtls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.