Commit 970a27c
authored
Fix clippy warnings etc. (#393)
* 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 <[email protected]>
* Fix some clippy style lints
Signed-off-by: Brian Anderson <[email protected]>
* 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 <[email protected]>
* Cleanup some unit-return functions
Signed-off-by: Brian Anderson <[email protected]>
* Disable a clippy lint
Signed-off-by: Brian Anderson <[email protected]>
* make a transmute more typesafe
Signed-off-by: Brian Anderson <[email protected]>
* Elide a lifetime
Signed-off-by: Brian Anderson <[email protected]>
* Remove unnecessary unsafe blocks
Signed-off-by: Brian Anderson <[email protected]>
* 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#28
Signed-off-by: Brian Anderson <[email protected]>
* 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 <[email protected]>
* Replace mem::transmute with pointer casts
Slightly more typesafe, and more explicit about what's being cast.
Signed-off-by: Brian Anderson <[email protected]>
* Replace more mem::transmute with casts
Signed-off-by: Brian Anderson <[email protected]>
* Remove a no-op mem::transmute
Signed-off-by: Brian Anderson <[email protected]>
* Remove is_power_of_two
std contains a branchless bitmagic version of this function
Signed-off-by: Brian Anderson <[email protected]>
* Add clippy makefile target
Signed-off-by: Brian Anderson <[email protected]>
* Add clippy to CI
Signed-off-by: Brian Anderson <[email protected]>
* 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 <[email protected]>
* Update src/rocksdb.rs
Co-Authored-By: kennytm <[email protected]>
Signed-off-by: Brian Anderson <[email protected]>
* Install clippy on travis
Signed-off-by: Brian Anderson <[email protected]>
* Adjust clippy lints for CI toolchain
Signed-off-by: Brian Anderson <[email protected]>
* Make a typesafe cast
Signed-off-by: Brian Anderson <[email protected]>
* rustfmt
Signed-off-by: Brian Anderson <[email protected]>1 parent 3031723 commit 970a27c
File tree
12 files changed
+253
-213
lines changed- librocksdb_sys/src
- src
12 files changed
+253
-213
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
17 | 25 | | |
18 | 26 | | |
19 | 27 | | |
| |||
32 | 40 | | |
33 | 41 | | |
34 | 42 | | |
35 | | - | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
79 | 153 | | |
80 | 154 | | |
81 | 155 | | |
| |||
88 | 162 | | |
89 | 163 | | |
90 | 164 | | |
91 | | - | |
92 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
93 | 169 | | |
94 | 170 | | |
95 | 171 | | |
| |||
103 | 179 | | |
104 | 180 | | |
105 | 181 | | |
106 | | - | |
107 | | - | |
| 182 | + | |
| 183 | + | |
108 | 184 | | |
109 | 185 | | |
110 | 186 | | |
| |||
302 | 378 | | |
303 | 379 | | |
304 | 380 | | |
305 | | - | |
306 | | - | |
| 381 | + | |
| 382 | + | |
307 | 383 | | |
308 | | - | |
309 | | - | |
310 | | - | |
| 384 | + | |
311 | 385 | | |
312 | 386 | | |
313 | 387 | | |
| |||
634 | 708 | | |
635 | 709 | | |
636 | 710 | | |
637 | | - | |
| 711 | + | |
638 | 712 | | |
639 | 713 | | |
640 | 714 | | |
| |||
863 | 937 | | |
864 | 938 | | |
865 | 939 | | |
866 | | - | |
867 | | - | |
| 940 | + | |
| 941 | + | |
868 | 942 | | |
869 | 943 | | |
870 | 944 | | |
| |||
876 | 950 | | |
877 | 951 | | |
878 | 952 | | |
879 | | - | |
| 953 | + | |
880 | 954 | | |
881 | 955 | | |
882 | 956 | | |
| |||
887 | 961 | | |
888 | 962 | | |
889 | 963 | | |
890 | | - | |
| 964 | + | |
891 | 965 | | |
892 | | - | |
| 966 | + | |
893 | 967 | | |
894 | 968 | | |
895 | 969 | | |
| |||
1005 | 1079 | | |
1006 | 1080 | | |
1007 | 1081 | | |
1008 | | - | |
1009 | | - | |
| 1082 | + | |
| 1083 | + | |
1010 | 1084 | | |
1011 | 1085 | | |
1012 | 1086 | | |
1013 | 1087 | | |
1014 | 1088 | | |
1015 | 1089 | | |
1016 | | - | |
| 1090 | + | |
1017 | 1091 | | |
1018 | 1092 | | |
1019 | 1093 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
26 | | - | |
| 25 | + | |
27 | 26 | | |
28 | | - | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
37 | 34 | | |
38 | 35 | | |
39 | | - | |
| 36 | + | |
40 | 37 | | |
41 | 38 | | |
42 | 39 | | |
43 | 40 | | |
44 | 41 | | |
45 | 42 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
52 | 47 | | |
0 commit comments