aldanor / hdf5-rust

HDF5 for Rust
https://docs.rs/hdf5
Apache License 2.0
310 stars 85 forks source link

Fix latest round of clippy lints #191

Closed mulimoen closed 2 years ago

aldanor commented 2 years ago

@mulimoen Thanks for taking care of all this - many lints actually make sense - e.g. there was some old code that couldn't use [T; N] deriving Clone for all N so we had to do it manually, etc.

There's a few things I've pointed out that are questionable:

mulimoen commented 2 years ago

Thanks @aldanor for reviewing this. Align checks are for casting to pointer-to-pointer, e.g. error: casting from *mut u8 to a more-strictly-aligned pointer (*mut *const u8) (1 < 8 bytes). Could be I have misunderstood some of this code, quite a lot of tricky pointer logic there.

aldanor commented 2 years ago

Given that we allocate memory either via libc::malloc, whose man states:

The malloc() and calloc() functions return a pointer to the allocated memory that is suitably aligned for any kind of variable.

Or via H5allocate_memory:

=> in whichever case, 8-byte alignment is pretty much guaranteed and we don't need to check it ourselves?

mulimoen commented 2 years ago

That is some great detective work @aldanor! I would also not expect to see any alignment issues as allocations in C tends to be very conservative, so it's great that we can remove these checks

aldanor commented 2 years ago

Great, thanks!