Fix dialyzer errors and warnings

This commit is contained in:
Thomas Arts 2024-03-19 10:57:54 +01:00
parent 1d6ae82c6d
commit 16d0533acf
4 changed files with 19 additions and 11 deletions

View File

@ -14,6 +14,10 @@
deprecated_function_calls deprecated_function_calls
]}. ]}.
{dialyzer, [{plt_apps, all_deps},
{base_plt_apps, [erts, kernel, stdlib, mnesia ]}
]}.
{profiles, {profiles,
[ [
{test, {test,

View File

@ -250,7 +250,7 @@ release_snapshot(SHandle) ->
%% <li> `{tx, TxOpts}' - A `rocksdb' transaction with sligth modifications</li> %% <li> `{tx, TxOpts}' - A `rocksdb' transaction with sligth modifications</li>
%% <li> `batch' - A `rocksdb' batch operation</li> %% <li> `batch' - A `rocksdb' batch operation</li>
%% </ul> %% </ul>
%% %%
%% By default, transactions are combined with a snapshot with 1 retry. %% By default, transactions are combined with a snapshot with 1 retry.
%% The snapshot ensures that writes from concurrent transactions don't leak into the transaction context. %% The snapshot ensures that writes from concurrent transactions don't leak into the transaction context.
%% A transaction will be retried if it detects that the commit set conflicts with recent changes. %% A transaction will be retried if it detects that the commit set conflicts with recent changes.
@ -320,7 +320,7 @@ incr_attempt({I,O}, {Ri,Ro}) when is_integer(I), is_integer(O),
end; end;
incr_attempt(_, _) -> incr_attempt(_, _) ->
error. error.
retry_activity(F, Alias, #{activity := #{ type := Type retry_activity(F, Alias, #{activity := #{ type := Type
, attempt := A , attempt := A
, retries := R} = Act} = Ctxt) -> , retries := R} = Act} = Ctxt) ->
@ -532,7 +532,7 @@ rdb_transaction(DbRef, Opts) ->
rocksdb:transaction(DbRef, Opts). rocksdb:transaction(DbRef, Opts).
rdb_transaction_commit_and_pop(H) -> rdb_transaction_commit_and_pop(H) ->
try rdb_transaction_commit(H) try rdb_transaction_commit(H)
after after
pop_ctxt() pop_ctxt()
end. end.
@ -559,6 +559,7 @@ rdb_release_batch(H) ->
rocksdb:release_batch(H). rocksdb:release_batch(H).
%% @doc Aborts an ongoing {@link activity/2} %% @doc Aborts an ongoing {@link activity/2}
-spec abort(_) -> no_return().
abort(Reason) -> abort(Reason) ->
case mnesia_compatible_aborts() of case mnesia_compatible_aborts() of
true -> true ->
@ -846,7 +847,7 @@ update_index_do_bag(Ixs, Name, R, Key, Obj, Opts) ->
not_found not_found
end end
end. end.
update_index_do([{_Pos,ordered} = Ix|Ixs], Name, R, Key, Obj, Rest, Opts) -> update_index_do([{_Pos,ordered} = Ix|Ixs], Name, R, Key, Obj, Rest, Opts) ->
Tab = {Name, index, Ix}, Tab = {Name, index, Ix},
#{ix_vals_f := IxValsF} = IRef = ensure_ref(Tab, R), #{ix_vals_f := IxValsF} = IRef = ensure_ref(Tab, R),
@ -1018,7 +1019,7 @@ alias_of(Tab) ->
%% and when releasing, all batches are released. This will not ensure %% and when releasing, all batches are released. This will not ensure
%% atomicity, but there is no way in rocksdb to achieve atomicity %% atomicity, but there is no way in rocksdb to achieve atomicity
%% across db instances. At least, data should end up where you expect. %% across db instances. At least, data should end up where you expect.
%% %%
%% @end %% @end
-spec as_batch(ref_or_tab(), fun( (db_ref()) -> Res )) -> Res. -spec as_batch(ref_or_tab(), fun( (db_ref()) -> Res )) -> Res.
as_batch(Tab, F) -> as_batch(Tab, F) ->
@ -1321,7 +1322,7 @@ rdb_fold(Tab, Fun, Acc, Prefix, Limit) when is_function(Fun, 3)
true = valid_limit(Limit), true = valid_limit(Limit),
mrdb_select:rdb_fold(ensure_ref(Tab), Fun, Acc, Prefix, Limit). mrdb_select:rdb_fold(ensure_ref(Tab), Fun, Acc, Prefix, Limit).
valid_limit(L) -> valid_limit(L) ->
case L of case L of
infinity -> infinity ->
true; true;
@ -1559,11 +1560,11 @@ rdb_merge_(#{db_ref := DbRef, cf_handle := CfH}, K, Op, WOpts) ->
rocksdb:merge(DbRef, CfH, K, Op, WOpts). rocksdb:merge(DbRef, CfH, K, Op, WOpts).
write_opts(#{write_opts := Os}, Opts) -> Os ++ Opts; write_opts(#{write_opts := Os}, Opts) -> Os ++ Opts;
write_opts(_, Opts) -> write_opts(_, Opts) ->
Opts. Opts.
read_opts(#{read_opts := Os}, Opts) -> Os ++ Opts; read_opts(#{read_opts := Os}, Opts) -> Os ++ Opts;
read_opts(_, Opts) -> read_opts(_, Opts) ->
Opts. Opts.
-define(EOT, '$end_of_table'). -define(EOT, '$end_of_table').

View File

@ -11,9 +11,9 @@
, index_ref/2 , index_ref/2
]). ]).
-record(mrdb_ix_iter, { i :: mrdb:iterator() -record(mrdb_ix_iter, { i :: mrdb:mrdb_iterator()
, type = set :: set | bag , type = set :: set | bag
, sub :: mrdb:ref() | pid() , sub :: pid() | mrdb:db_ref()
}). }).
-type ix_iterator() :: #mrdb_ix_iter{}. -type ix_iterator() :: #mrdb_ix_iter{}.
@ -22,7 +22,7 @@
-type object() :: tuple(). -type object() :: tuple().
-record(subst, { i :: mrdb:iterator() -record(subst, { i :: mrdb:mrdb_iterator()
, vals_f , vals_f
, cur , cur
, mref }). , mref }).
@ -121,6 +121,7 @@ iterator_move_bag(#mrdb_ix_iter{i = I, sub = Sub}, Dir) ->
Other Other
end. end.
-spec opt_read(mrdb:ref_or_tab(), Key :: any()) -> any().
opt_read(R, Key) -> opt_read(R, Key) ->
case mrdb:read(R, Key, []) of case mrdb:read(R, Key, []) of
[Obj] -> [Obj] ->

View File

@ -3,7 +3,9 @@
-export([ do/2 ]). -export([ do/2 ]).
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-endif.
%% We use a gen_server-based FIFO queue (one queue per alias) to manage the %% We use a gen_server-based FIFO queue (one queue per alias) to manage the
%% critical section. %% critical section.