25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

Fix some dialyzer warnings

This commit is contained in:
Evgeniy Khramtsov 2017-02-16 14:18:36 +03:00
parent 8b2d308498
commit 218eeae797
10 changed files with 20 additions and 13 deletions

View File

@ -39,7 +39,7 @@
-type get_password_fun() :: fun((binary()) -> {false, any()} |
{binary(), atom()}).
-type check_password_fun() :: fun((binary(), binary(), binary(),
-type check_password_fun() :: fun((binary(), binary(), binary(), binary(),
fun((binary()) -> binary())) ->
{boolean(), any()} |
false).
@ -51,8 +51,8 @@
nonce = <<"">> :: binary(),
username = <<"">> :: binary(),
authzid = <<"">> :: binary(),
get_password = fun(_) -> {false, <<>>} end :: get_password_fun(),
check_password = fun(_, _, _, _, _) -> false end :: check_password_fun(),
get_password :: get_password_fun(),
check_password :: check_password_fun(),
auth_module :: atom(),
host = <<"">> :: binary(),
hostfqdn = <<"">> :: binary() | [binary()]}).
@ -111,7 +111,7 @@ mech_step(#state{step = 3, nonce = Nonce} = State,
{false, _} -> {error, not_authorized, UserName};
{Passwd, AuthModule} ->
case (State#state.check_password)(UserName, UserName, <<"">>,
proplists:get_value(<<"response">>, KeyVals, <<>>),
proplists:get_value(<<"response">>, KeyVals, <<>>),
fun (PW) ->
response(KeyVals,
UserName,

View File

@ -56,7 +56,7 @@
-record(state, {limits = treap:empty() :: treap:treap()}).
-record(captcha, {id :: binary(),
pid :: pid(),
pid :: pid() | undefined,
key :: binary(),
tref :: reference(),
args :: any()}).

View File

@ -93,7 +93,7 @@ change_shaper(Pid, Shaper) ->
reset_stream(Pid) -> do_call(Pid, reset_stream).
-spec starttls(pid(), fast_tls:tls_socket()) -> ok.
-spec starttls(pid(), fast_tls:tls_socket()) -> ok | {error, any()}.
starttls(Pid, TLSSocket) ->
do_call(Pid, {starttls, TLSSocket}).

View File

@ -218,7 +218,7 @@ code_change(_OldVsn, State, _Extra) ->
do_route(Domain, Destinations, Packet) ->
?DEBUG("route multicast:~n~s~nDomain: ~s~nDestinations: ~s~n",
[xmpp:pp(Packet), Domain,
str:join([jid:to_string(To) || To <- Destinations], ", ")]),
str:join([jid:to_string(To) || To <- Destinations], <<", ">>)]),
%% Try to find an appropriate multicast service
case mnesia:dirty_read(route_multicast, Domain) of

View File

@ -52,7 +52,7 @@
opts = [] :: opts() | '_' | '$2'}).
-type opts() :: [{atom(), any()}].
-type db_type() :: sql | mnesia | riak.
-type db_type() :: atom().
-callback start(binary(), opts()) -> ok | {ok, pid()}.
-callback stop(binary()) -> any().

View File

@ -1460,7 +1460,7 @@ send_stanza(FromString, ToString, Stanza) ->
try
#xmlel{} = El = fxml_stream:parse_element(Stanza),
#jid{} = From = jid:from_string(FromString),
#jid{} = To = jid:to_string(ToString),
#jid{} = To = jid:from_string(ToString),
Pkt = xmpp:decode(El, ?NS_CLIENT, [ignore_els]),
ejabberd_router:route(xmpp:set_from_to(Pkt, From, To))
catch _:{xmpp_codec, Why} ->

View File

@ -406,7 +406,7 @@ commands_result(Allow, From, To, Request) ->
announce_commands(From, To, Request)
end.
-spec announce_commands(adhoc_command(), jid(), jid(), adhoc_command()) ->
-spec announce_commands(empty | adhoc_command(), jid(), jid(), adhoc_command()) ->
adhoc_command() | {error, stanza_error()}.
announce_commands(Acc, From, #jid{lserver = LServer} = To,
#adhoc_command{node = Node} = Request) ->

View File

@ -253,7 +253,7 @@ filter_other({Stanza, #{jid := JID} = C2SState} = Acc) when ?is_stanza(Stanza) -
filter_other(Acc) ->
Acc.
-spec add_stream_feature([xmpp_element()], binary) -> [xmpp_element()].
-spec add_stream_feature([xmpp_element()], binary()) -> [xmpp_element()].
add_stream_feature(Features, Host) ->
case gen_mod:is_loaded(Host, ?MODULE) of
true ->

View File

@ -65,8 +65,7 @@ mod_opt_type(_) ->
depends(_, _) ->
[].
-spec decode_iq_subel(xmpp_element()) -> xmpp_element();
(xmlel()) -> xmlel().
-spec decode_iq_subel(xmpp_element() | xmlel()) -> xmpp_element() | xmlel().
%% Tell gen_iq_handler not to auto-decode IQ payload
decode_iq_subel(El) ->
El.

View File

@ -31,6 +31,8 @@
-include("xmpp.hrl").
-type c2s_state() :: ejabberd_c2s:state().
%%%===================================================================
%%% API
%%%===================================================================
@ -52,6 +54,8 @@ depends(_Host, _Opts) ->
mod_opt_type(_) ->
[].
-spec c2s_unauthenticated_packet(c2s_state(), iq()) ->
c2s_state() | {stop, c2s_state()}.
c2s_unauthenticated_packet(State, #iq{type = T, sub_els = [_]} = IQ)
when T == get; T == set ->
case xmpp:get_subtag(IQ, #legacy_auth{}) of
@ -63,6 +67,7 @@ c2s_unauthenticated_packet(State, #iq{type = T, sub_els = [_]} = IQ)
c2s_unauthenticated_packet(State, _) ->
State.
-spec c2s_stream_features([xmpp_element()], binary()) -> [xmpp_element()].
c2s_stream_features(Acc, LServer) ->
case gen_mod:is_loaded(LServer, ?MODULE) of
true ->
@ -74,6 +79,7 @@ c2s_stream_features(Acc, LServer) ->
%%%===================================================================
%%% Internal functions
%%%===================================================================
-spec authenticate(c2s_state(), iq()) -> c2s_state().
authenticate(#{server := Server} = State,
#iq{type = get, sub_els = [#legacy_auth{}]} = IQ) ->
LServer = jid:nameprep(Server),
@ -129,6 +135,7 @@ authenticate(#{stream_id := StreamID, server := Server,
process_auth_failure(State, U, Err, 'forbidden')
end.
-spec open_session(c2s_state(), iq(), binary()) -> c2s_state().
open_session(State, IQ, R) ->
case ejabberd_c2s:bind(R, State) of
{ok, State1} ->
@ -139,6 +146,7 @@ open_session(State, IQ, R) ->
ejabberd_c2s:send(State1, Res)
end.
-spec process_auth_failure(c2s_state(), binary(), stanza_error(), atom()) -> c2s_state().
process_auth_failure(State, User, StanzaErr, Reason) ->
State1 = ejabberd_c2s:send(State, StanzaErr),
ejabberd_c2s:handle_auth_failure(User, <<"legacy">>, Reason, State1).