25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-26 16:26:24 +01:00

Fix problems detected by Dialyzer

This commit is contained in:
Badlop 2011-08-17 18:43:19 +02:00
parent 6eb5b0d298
commit 7355e810a8
6 changed files with 47 additions and 58 deletions

View File

@ -232,7 +232,7 @@ server_start(State, Mech, ClientIn) ->
%% @spec (State, ClientIn) -> Ok | Continue | Error
%% State = saslstate()
%% ClientIn = string()
%% Ok = {ok, Props}
%% Ok = {ok, Props} | {ok, Props, ServerOut}
%% Props = [Prop]
%% Prop = [{Key, Value}]
%% Key = atom()

View File

@ -92,9 +92,7 @@ mech_step(#state{step = 2} = State, ClientIn) ->
_Else ->
{error, 'not-supported'}
end
end;
_Else ->
{error, 'bad-protocol'}
end
end;
_Else ->
{error, 'bad-protocol'}
@ -146,12 +144,8 @@ parse_attribute(Attribute) ->
true ->
if
SecondChar == $= ->
case string:substr(Attribute, 3) of
String when is_list(String) ->
String = string:substr(Attribute, 3),
{lists:nth(1, Attribute), String};
_Else ->
{error, 'bad-format failed'}
end;
true ->
{error, 'bad-format second char not equal sign'}
end;
@ -193,5 +187,5 @@ is_alpha(Char) when Char >= $a, Char =< $z ->
is_alpha(Char) when Char >= $A, Char =< $Z ->
true;
is_alpha(_) ->
true.
false.

View File

@ -122,12 +122,12 @@ start(Host) ->
{iterationcount, int}]}
]),
update_table(Host, Backend),
maybe_scram_passwords(Host),
maybe_scram_passwords(HostB),
mnesia:create_table(reg_users_counter,
[{ram_copies, [node()]},
{attributes, record_info(fields, reg_users_counter)}]),
update_reg_users_counter_table(Host),
maybe_alert_password_scrammed_without_option(Host),
maybe_alert_password_scrammed_without_option(HostB),
ok.
stop(_Host) ->
@ -544,9 +544,9 @@ is_scrammed(Host) ->
forced_scram -> true
end.
action_password_format(Host) ->
action_password_format(HostB) ->
OptionScram = is_option_scram(),
case {OptionScram, get_format_first_element(Host)} of
case {OptionScram, get_format_first_element(HostB)} of
{true, scram} -> scram;
{true, any} -> scram;
{true, plain} -> must_scram;
@ -555,8 +555,8 @@ action_password_format(Host) ->
{false, scram} -> forced_scram
end.
get_format_first_element(Host) ->
case gen_storage:dirty_select(Host, passwd, []) of
get_format_first_element(HostB) ->
case gen_storage:dirty_select(HostB, passwd, []) of
[] -> any;
[#passwd{password = ""} | _] -> scram;
[#passwd{} | _] -> plain

View File

@ -163,9 +163,8 @@ add_user(El, Domain) ->
Password = exmpp_xml:get_attribute(El,<<"password">>,none),
add_user(El, Domain, User, PasswordFormat, Password).
%% @spec (El::xmlel(), Domain::string(), User::binary(), PasswordFormat, Password::binary() | none)
%% @spec (El::xmlel(), Domain::string(), User::binary(), PasswordFormat::binary(), Password::binary() | none)
%% -> ok | {error, ErrorText::string()}
%% PasswordFormat = <<"plaintext">> | <<"scram">>
%% @doc Add a new user to the database.
%% If user already exists, it will be only updated.
add_user(El, Domain, User, <<"plaintext">>, none) ->
@ -174,7 +173,7 @@ add_user(El, Domain, User, <<"plaintext">>, none) ->
io:format(""),
populate_user_with_elements(El, Domain, User),
ok;
add_user(El, Domain, User, PasswordFormat, Password) ->
add_user(El, Domain, User, <<"scram">> = PasswordFormat, Password) ->
Password2 = prepare_password(PasswordFormat, Password, El),
case create_user(User,Password2,Domain) of
ok ->
@ -217,7 +216,7 @@ populate_user_with_elements(El, Domain, User) ->
%% -> ok | {atomic, exists} | {error, not_allowed}
%% @doc Create a new user
create_user(User,Password,Domain) ->
case ejabberd_auth:try_register(?BTL(User),?BTL(Domain),?BTL(Password)) of
case ejabberd_auth:try_register(?BTL(User),?BTL(Domain),Password) of
{atomic,ok} -> ok;
{atomic, exists} -> {atomic, exists};
{error, not_allowed} -> {error, not_allowed};

View File

@ -452,12 +452,6 @@ normal_state({route, From, ToNick,
From, Err);
_ ->
ToJID = find_jid_by_nick(ToNick, StateData),
SrcIsVisitor = is_visitor(From, StateData),
DstIsModerator = is_moderator(ToJID, StateData),
PmFromVisitors = (StateData#state.config)#config.allow_private_messages_from_visitors,
if SrcIsVisitor == false;
PmFromVisitors == anyone;
(PmFromVisitors == moderators) and (DstIsModerator) ->
case ToJID of
false ->
ErrText = "Recipient is not in the conference room",
@ -470,6 +464,12 @@ normal_state({route, From, ToNick,
ToNick),
From, Err);
_ ->
SrcIsVisitor = is_visitor(From, StateData),
DstIsModerator = is_moderator(ToJID, StateData),
PmFromVisitors = (StateData#state.config)#config.allow_private_messages_from_visitors,
if SrcIsVisitor == false;
PmFromVisitors == anyone;
(PmFromVisitors == moderators) and (DstIsModerator) ->
{ok, #user{nick = FromNick}} =
?DICT:find(jlib:jid_tolower(From),
StateData#state.users),
@ -477,8 +477,7 @@ normal_state({route, From, ToNick,
jid_replace_resource(
StateData#state.jid,
FromNick),
ToJID, Packet)
end;
ToJID, Packet);
true ->
ErrText = "It is not allowed to send private messages",
Err = exmpp_stanza:reply_with_error(Packet,
@ -489,6 +488,8 @@ normal_state({route, From, ToNick,
StateData#state.jid,
ToNick),
From, Err)
end
end
end;
{true, false} ->

View File

@ -162,12 +162,7 @@ get_local_stat(_Server, [], Name) when Name == <<"users/all-hosts/total">> ->
ejabberd_auth:get_vh_registered_users_number(Host)
+ Total
end, 0, ejabberd_config:get_global_option(hosts)),
case NumUsers of
{'EXIT', _Reason} ->
?STATERR(<<"500">>, <<"Internal Server Error">>);
Users ->
?STATVAL(list_to_binary(integer_to_list(Users)), <<"users">>)
end;
?STATVAL(list_to_binary(integer_to_list(NumUsers)), <<"users">>);
get_local_stat(_Server, _, Name) ->
?STATERR(<<"404">>, <<"Not Found">>).