Make dialyzer happy

This commit is contained in:
Carlos Martín Nieto
2013-07-31 05:00:23 +02:00
parent 5e0aba3458
commit 73f31eac2f
8 changed files with 17 additions and 12 deletions

View File

@@ -16,6 +16,6 @@ tree(#geef_object{type=commit,handle=Handle}) ->
Other Other
end. end.
-spec lookup(pid(), geef_oid() | iolist()) -> geef_object(). -spec lookup(pid(), geef_oid() | iolist()) -> {ok, geef_object()} | {error, term()}.
lookup(Repo, Id) -> lookup(Repo, Id) ->
geef_obj:lookup(Repo, Id, commit). geef_obj:lookup(Repo, Id, commit).

View File

@@ -27,7 +27,7 @@
%% @doc Create a new index. This index is empty and not associated to %% @doc Create a new index. This index is empty and not associated to
%% any repository. %% any repository.
-spec new() -> pid(). -spec new() -> {ok, pid()} | ignore | {error, term()}.
new() -> new() ->
{ok, Handle} = geef_nif:index_new(), {ok, Handle} = geef_nif:index_new(),
start_link(Handle). start_link(Handle).
@@ -66,6 +66,7 @@ stop(Pid) ->
gen_server:call(Pid, stop). gen_server:call(Pid, stop).
%% @private %% @private
-spec start_link(term()) -> {ok, pid()} | ignore | {error, term()}.
start_link(Handle) -> start_link(Handle) ->
gen_server:start_link(?MODULE, Handle, []). gen_server:start_link(?MODULE, Handle, []).

View File

@@ -75,7 +75,6 @@ odb_write(_Handle, _Contents, _Type) ->
oid_fmt(_Oid) -> oid_fmt(_Oid) ->
nif_error(?LINE). nif_error(?LINE).
-spec oid_parse(iolist()) -> binary().
oid_parse(_Sha) -> oid_parse(_Sha) ->
nif_error(?LINE). nif_error(?LINE).

View File

@@ -15,7 +15,7 @@ hex(#geef_oid{oid=Oid}) ->
geef_nif:oid_fmt(Oid). geef_nif:oid_fmt(Oid).
%% @doc Parse an iolist as a hash %% @doc Parse an iolist as a hash
-spec parse(iolist()) -> geef_oid(). -spec parse(iolist() | binary()) -> geef_oid().
parse(Sha) -> parse(Sha) ->
Oid = geef_nif:oid_parse(Sha), Oid = geef_nif:oid_parse(Sha),
#geef_oid{oid=Oid}. #geef_oid{oid=Oid}.

View File

@@ -56,7 +56,7 @@ do_unpack(Len, Rest) when Len - 4 > size(Rest) ->
do_unpack(Len, Rest) -> do_unpack(Len, Rest) ->
{Len - 4, Rest}. {Len - 4, Rest}.
-spec parse_pkt(binary(), non_neg_integer()) -> {{want | have}, geef_oid(), binary()} | {done, binary()} | {flush, binary()}. -spec parse_pkt(binary(), non_neg_integer()) -> {{want | have, geef_oid()}, binary()} | {done, binary()} | {flush, binary()}.
parse_pkt(In, 0) -> parse_pkt(In, 0) ->
{flush, In}; {flush, In};
parse_pkt(In, Len) -> parse_pkt(In, Len) ->
@@ -72,6 +72,7 @@ parse_pkt(In, Len) ->
<<_:LenLF/binary, Rest/binary>> = Rest1, <<_:LenLF/binary, Rest/binary>> = Rest1,
{Pkt, Rest}. {Pkt, Rest}.
-spec pkt_type(binary()) -> {have | want | done, non_neg_integer(), binary()}.
pkt_type(<<"have ", Rest/binary>>) -> pkt_type(<<"have ", Rest/binary>>) ->
{have, 5 + ?SHA_LEN, Rest}; {have, 5 + ?SHA_LEN, Rest};
pkt_type(<<"want ", Rest/binary>>) -> pkt_type(<<"want ", Rest/binary>>) ->

View File

@@ -1,5 +1,5 @@
-record(geef_reference, {handle, name :: binary(), type :: atom(), target :: binary() | geef_oid()}). -record(geef_reference, {handle, name :: binary(), type :: oid | symbolic, target :: binary() | geef_oid()}).
-record(geef_oid, {oid}). -record(geef_oid, {oid :: binary()}).
-record(geef_object, {type :: atom(), id :: geef_oid(), handle}). -record(geef_object, {type :: atom(), id :: geef_oid(), handle}).
-record(geef_index_entry, -record(geef_index_entry,
{ctime :: non_neg_integer(), mtime :: non_neg_integer(), {ctime :: non_neg_integer(), mtime :: non_neg_integer(),
@@ -14,8 +14,8 @@
-record(geef_tree_entry, {mode, type, id, name}). -record(geef_tree_entry, {mode, type, id, name}).
-record(geef_signature, {name :: iolist(), email :: iolist(), time :: geef_time()}). -record(geef_signature, {name :: iolist(), email :: iolist(), time :: geef_time()}).
-type geef_reference() :: #geef_reference{}. -type geef_reference() :: #geef_reference{name :: binary(), target :: binary() | geef_oid()}.
-type geef_oid() :: #geef_oid{}. -type geef_oid() :: #geef_oid{oid :: binary()}.
-type geef_object() :: #geef_object{}. -type geef_object() :: #geef_object{}.
-type geef_index_entry() :: #geef_index_entry{}. -type geef_index_entry() :: #geef_index_entry{}.
-type geef_request() :: #geef_request{}. -type geef_request() :: #geef_request{}.

View File

@@ -18,8 +18,12 @@ new(Name, Handle) ->
-spec create(pid(), iolist(), geef_oid() | binary(), boolean()) -> {ok, geef_reference()} | {error, term()}. -spec create(pid(), iolist(), geef_oid() | binary(), boolean()) -> {ok, geef_reference()} | {error, term()}.
create(Repo, Refname, Target, Force) -> create(Repo, Refname, Target, Force) ->
{ok, Ref} = geef_repo:create_reference(Repo, Refname, Target, Force), case geef_repo:create_reference(Repo, Refname, Target, Force) of
{ok, new(Refname, Ref)}. {ok, Ref} ->
{ok, new(Refname, Ref)};
Err = {error, _} ->
Err
end.
-spec lookup(pid(), iolist()) -> {ok, geef_reference()} | {error, term()}. -spec lookup(pid(), iolist()) -> {ok, geef_reference()} | {error, term()}.
lookup(Repo, Refname) -> lookup(Repo, Refname) ->

View File

@@ -10,7 +10,7 @@
-spec lookup(pid(), geef_oid() | iolist()) -> {ok, geef_object()} | {error, term()}. -spec lookup(pid(), geef_oid() | iolist()) -> {ok, geef_object()} | {error, term()}.
lookup(Repo, Id) -> lookup(Repo, Id) ->
geef_object:lookup(Repo, Id, tag). geef_obj:lookup(Repo, Id, tag).
-spec peel(geef_object()) -> {ok, geef_object()} | {error, term()}. -spec peel(geef_object()) -> {ok, geef_object()} | {error, term()}.
peel(#geef_object{type=tag, handle=Handle}) -> peel(#geef_object{type=tag, handle=Handle}) ->