-
Brian Anderson authored
* Fix various unsafe declarations As reported by clippy. These are all cases where a pointer argument is dereferenced by a declared safe function. The functions are changed to be unsafe functions. Though some of these functions are declared pub, they all seem to be related to internal binding matters and appear to be written correctly, just declared incorrectly, so there shouldn't be any external impact for callers that aren't using the crocksdb API directly. Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Fix some clippy style lints Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Fix mutability of crocksdb_load_latest_options errptr This value can be mutated on the C side. Caught by clippy. Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Cleanup some unit-return functions Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Disable a clippy lint Signed-off-by:
Brian Anderson <andersrb@gmail.com> * make a transmute more typesafe Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Elide a lifetime Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Remove unnecessary unsafe blocks Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Use repr(C) structs of c_void for opaque types. These represent opaque RocksDB types. They are used behind pointers, but are also wrapped in other types in the higher-level bindings. These use the strategy for opaque C types described in the nomicon [1]: but with the exception that they contain c_void instead of [u8; 0], thus making them uninstantiable sized types instead of ZSTs. The c_void documentation publicly recommends using the ZST pattern from the nomicon, but in private documentation [2] warns about UB from dereferencing pointers to uninhabited types, which these bindings do. Additionally, these bindings wrap some these types directly (not through pointers) and it's impossible to repr(transparent) a ZST, without which the unsafe casts within are dubious. [1]: https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs [2]: https://doc.rust-lang.org/nightly/src/core/ffi.rs.html#28Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Apply repr(transparent) to various unsafe-cast wrappers These are wrappers of opaque FFI types, and pointers are being unsafely cast between the two. repr(transparent) is probably needed to make this well-defined. Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Replace mem::transmute with pointer casts Slightly more typesafe, and more explicit about what's being cast. Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Replace more mem::transmute with casts Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Remove a no-op mem::transmute Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Remove is_power_of_two std contains a branchless bitmagic version of this function Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Add clippy makefile target Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Add clippy to CI Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Fix types in memcpy This code is copying from c_void pointers when it should be copying from byte pointers. Fortunately c_void and u8 have the same size, but I don't know if that is guaranteed. Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Update src/rocksdb.rs Co-Authored-By:
kennytm <kennytm@gmail.com> Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Install clippy on travis Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Adjust clippy lints for CI toolchain Signed-off-by:
Brian Anderson <andersrb@gmail.com> * Make a typesafe cast Signed-off-by:
Brian Anderson <andersrb@gmail.com> * rustfmt Signed-off-by:
Brian Anderson <andersrb@gmail.com>