colis-anr / morbig

A static parser for POSIX Shell
Other
190 stars 8 forks source link

Make C stubs more conservative #131

Closed Niols closed 3 years ago

Niols commented 3 years ago

We make the C stubs more conservative by adding the const keyword wherever necessary. Otherwise, someone building against the C API could change values or pointers used by other functions of the API (or subsequent calls to the same functions).

fix #129

We should probably wait for the CI to be fixed before merging this, and also for #130 to add other tests that have to do with the C API.

@treinen Would you confirm that you do not encounter #129 anymore on this branch?

Niols commented 3 years ago

Also, an other note: the const keyword is added in two kind of places:

I think we want closures to be always const value* and not value*; I do not see any use of an API that would let C change pointers to OCaml functions. For the strings, it is not clear. We might consider that we do not actually use those strings and that, therefore, C should be free to change them if required. In this case, I would advise to remove the const keywords but to use the Bytes_val macros instead.

treinen commented 3 years ago

yes, this is fixed for me on the branch niols/conservative-cstub. Thanks -Ralf.