Skip to content
Browse files

Minimal changes to get zero Dialyzer warnings

Nice to see that Dialyzer caught a bug from parallel development,
adding the is_empty_estimate/1 function, and today's merge of
the new QuickCheck model.
  • Loading branch information...
1 parent e42900f commit 9513402b100adb13c8bbcb6e1042b8722991d65c @slfritchie slfritchie committed
Showing with 8 additions and 13 deletions.
  1. +1 −1 src/bitcask.erl
  2. +1 −1 src/bitcask_fileops.erl
  3. +6 −11 src/bitcask_nifs.erl
View
2 src/bitcask.erl
@@ -738,7 +738,7 @@ expired_threshold(Cutoff) ->
-spec is_empty_estimate(reference()) -> boolean().
is_empty_estimate(Ref) ->
State = get_state(Ref),
- {KeyCount, _, _} = bitcask_nifs:keydir_info(State#bc_state.keydir),
+ {KeyCount, _, _, _} = bitcask_nifs:keydir_info(State#bc_state.keydir),
KeyCount == 0.
-spec status(reference()) -> {integer(), [{string(), integer(), integer(), integer()}]}.
View
2 src/bitcask_fileops.erl
@@ -236,7 +236,7 @@ fold_keys(fresh, _Fun, Acc) -> Acc;
fold_keys(State, Fun, Acc) ->
fold_keys(State, Fun, Acc, default).
--spec fold_keys(fresh | #filestate{}, fun((binary(), integer(), {integer(), integer()}, any()) -> any()), any(), datafile | hintfile | default) ->
+-spec fold_keys(fresh | #filestate{}, fun((binary(), integer(), {integer(), integer()}, any()) -> any()), any(), datafile | hintfile | default | recovery) ->
any() | {error, any()}.
fold_keys(#filestate { fd = Fd } = State, Fun, Acc, Mode) ->
case Mode of
View
17 src/bitcask_nifs.erl
@@ -88,7 +88,7 @@
integer(), integer(), integer(), integer()) ->
ok | already_exists.
-spec keydir_put_int(reference(), binary(), integer(), integer(),
- binary(), integer(), boolean(), integer(), binary()) ->
+ binary(), integer(), 0 | 1, integer(), binary()) ->
ok | already_exists.
-spec keydir_get(reference(), binary()) ->
not_found | #bitcask_entry{}.
@@ -112,7 +112,9 @@
any() | {error, any()}.
-spec keydir_info(reference()) ->
{integer(), integer(),
- [{integer(), integer(), integer(), integer(), integer()}], integer(), boolean()}.
+ [{integer(), integer(), integer(), integer(), integer(),
+ integer(), integer()}],
+ {integer(), integer(), boolean()}}.
-spec keydir_release(reference()) ->
ok.
-spec lock_acquire(string(), integer()) ->
@@ -201,11 +203,7 @@ keydir_put(Ref, Key, FileId, TotalSz, Offset, Tstamp, NewestPutB,
keydir_put_int(_Ref, _Key, _FileId, _TotalSz, _Offset, _Tstamp, _NewestPutI,
_OldFileId, _OldOffset) ->
- case random:uniform(999999999999) of
- 666 -> ok;
- 667 -> already_exists;
- _ -> exit("NIF library not loaded")
- end.
+ erlang:nif_error({error, not_loaded}).
keydir_get(Ref, Key) ->
case keydir_get_int(Ref, Key) of
@@ -320,10 +318,7 @@ keydir_wait_pending(Ref) ->
end.
keydir_info(_Ref) ->
- case random:uniform(999999999999) of
- 666 -> {make_bogus_non_neg(), make_bogus_non_neg(), [{make_bogus_non_neg(), random:uniform(4242), random:uniform(4242), random:uniform(4242), random:uniform(4242)}]};
- _ -> exit("NIF library not loaded")
- end.
+ erlang:nif_error({error, not_loaded}).
keydir_release(_Ref) ->
case random:uniform(999999999999) of

0 comments on commit 9513402

Please sign in to comment.
Something went wrong with that request. Please try again.