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

mark add_len / set_len as deprecated #251

Merged
merged 2 commits into from
Apr 15, 2019
Merged

Conversation

hannesm
Copy link
Member

@hannesm hannesm commented Apr 8, 2019

extracted from #245 to stay focused there. I haven't seen any voice for keeping add_len and set_len -- though there's still work to be done until we can remove these function (as @talex5 listed here):
Other uses of set_len and add_len (from e.g. https://github.com/search?q=org%3Amirage+add_len&type=Code):

@dinosaure
Copy link
Member

ocaml-git does not use add_len anymore which is error-prone 👍

@avsm
Copy link
Member

avsm commented Apr 8, 2019

I am good with the deprecation, but could we add some instructions to the deprecation string to note that:

  • it'll be removed in version 5.0.0 (this helps packagers set the constraints from the logs)
  • what to do if they are still using that function (look at Cstruct.xxx instead)

(I am basing this off Lwt's excellent mode of deprecating which actually embeds the version number so there's a clear path for users when they see the message)

@hannesm
Copy link
Member Author

hannesm commented Apr 8, 2019

@avsm of course, if we agree on when to remove these functions.

AFAICT, there is no replacement for these two functions. as talex5 mentioned above, there may be need for a truncate function, and we have to figure out what to replace them with on a case-by-case study. they are not used widely, so IMHO it is better to deprecate them now instead of waiting until we have a replacement for them. in addition, it is still unclear to me what the semantics (esp. in error cases) of add_len and set_len should be, maybe you know more about that?

my intuition was always: when i have a Cstruct.t as view on data, there's no way to look left and right of the cstruct. and the above functions (together with sub atm) violate that. of course, my intuition may be wrong -- pls let me know if I've misunderstood this library, or assumed too much.

@hannesm
Copy link
Member Author

hannesm commented Apr 9, 2019

I rebased and added some information to the [@@ocaml.deprecated] attribute.

@hannesm
Copy link
Member Author

hannesm commented Apr 15, 2019

rebased again, imho good to merge

@avsm avsm merged commit 7c2edb7 into mirage:master Apr 15, 2019
@hannesm hannesm deleted the deprecated branch April 15, 2019 17:41
avsm added a commit to avsm/opam-repository that referenced this pull request Apr 19, 2019
…uct-sexp and cstruct-lwt (5.0.0)

CHANGES:

**Security**: This release tightens bounds checks to ensure
that data outside a given view (but still inside the underlying
buffer) cannot be accessed.

- `sub` does more checks (mirage/ocaml-cstruct#244 mirage/ocaml-cstruct#245 @hannesm @talex5 review by @dinosaure)
- `add_len` and `set_len` are now deprecated and will be removed
  in a future release. (mirage/ocaml-cstruct#251 @hannesm)
- do not add user-provided data for bounds checks
  (mirage/ocaml-cstruct#253 @hannesm, report and review by @talex5)
- improve CI to add fuzzing (mirage/ocaml-cstruct#255 mirage/ocaml-cstruct#252 @avsm @yomimono @talex5)

**Remove Unix dependency**: cstruct now uses the new `bigarray-compat`
library instead of Bigarray directly, to avoid a dependency on Unix
when using OCaml compilers less than 4.06.0.  This will break downstream
libraries that do not have a direct dependency on `Bigarray`.  Simply
fix it in your library by adding a `bigarray` dependency in your dune
file. (mirage/ocaml-cstruct#247 @TheLortex)

**Capability module**: To improve the safety of future code with stronger type
checking, this release introduces a new `Cstruct_cap` module which makes the
underlying Cstruct an abstract type instead of a record. In return for this
extra abstraction, the module can enforce read-only, write only, and read/write
buffers by tracking them as phantom type variables.  Although this library
shares an implementation internally with classic `Cstruct`, it is a significant
revision and so we will be gradually migrating to it.  Feedback on it is
welcome! (mirage/ocaml-cstruct#237 @dinosaure and many excited reviewers)

**Ppx compare functions**: A new `compare_X` function is generated for
`cenum` declarations. This respects custom ids supplied in the cenum
declaration and so is more robust than polymorphic compare (mirage/ocaml-cstruct#248 @emillon)

The CI has also been switched over to both Azure Pipelines and Drone in
addition to Travis, and as a result the tests all run on Windows, macOS,
various Linux distributions, on x86 and arm64 machines, and runs AFL
fuzz tests on the Drone cloud (mirage/ocaml-cstruct#255 @avsm).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants