Merge pull request #4206 from z8674558/fix-dialyzer

fix dialyzer warnings
This commit is contained in:
Zaiming Shi 2021-02-19 09:57:14 +01:00 committed by GitHub
commit 3353a2f402
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 12 deletions

View File

@ -106,7 +106,7 @@ load_hooks() ->
ok = emqx_auth_http:register_metrics(), ok = emqx_auth_http:register_metrics(),
PoolOpts = proplists:get_value(pool_opts, AuthReq), PoolOpts = proplists:get_value(pool_opts, AuthReq),
PoolName = proplists:get_value(pool_name, AuthReq), PoolName = proplists:get_value(pool_name, AuthReq),
ehttpc_sup:start_pool(PoolName, PoolOpts), {ok, _} = ehttpc_sup:start_pool(PoolName, PoolOpts),
case application:get_env(?APP, super_req) of case application:get_env(?APP, super_req) of
undefined -> undefined ->
emqx:hook('client.authenticate', {emqx_auth_http, check, [#{auth => maps:from_list(AuthReq), emqx:hook('client.authenticate', {emqx_auth_http, check, [#{auth => maps:from_list(AuthReq),
@ -114,7 +114,7 @@ load_hooks() ->
{ok, SuperReq} -> {ok, SuperReq} ->
PoolOpts1 = proplists:get_value(pool_opts, SuperReq), PoolOpts1 = proplists:get_value(pool_opts, SuperReq),
PoolName1 = proplists:get_value(pool_name, SuperReq), PoolName1 = proplists:get_value(pool_name, SuperReq),
ehttpc_sup:start_pool(PoolName1, PoolOpts1), {ok, _} = ehttpc_sup:start_pool(PoolName1, PoolOpts1),
emqx:hook('client.authenticate', {emqx_auth_http, check, [#{auth => maps:from_list(AuthReq), emqx:hook('client.authenticate', {emqx_auth_http, check, [#{auth => maps:from_list(AuthReq),
super => maps:from_list(SuperReq)}]}) super => maps:from_list(SuperReq)}]})
end end
@ -125,7 +125,7 @@ load_hooks() ->
ok = emqx_acl_http:register_metrics(), ok = emqx_acl_http:register_metrics(),
PoolOpts2 = proplists:get_value(pool_opts, ACLReq), PoolOpts2 = proplists:get_value(pool_opts, ACLReq),
PoolName2 = proplists:get_value(pool_name, ACLReq), PoolName2 = proplists:get_value(pool_name, ACLReq),
ehttpc_sup:start_pool(PoolName2, PoolOpts2), {ok, _} = ehttpc_sup:start_pool(PoolName2, PoolOpts2),
emqx:hook('client.check_acl', {emqx_acl_http, check_acl, [#{acl => maps:from_list(ACLReq)}]}) emqx:hook('client.check_acl', {emqx_acl_http, check_acl, [#{acl => maps:from_list(ACLReq)}]})
end, end,
ok. ok.
@ -133,9 +133,9 @@ load_hooks() ->
unload_hooks() -> unload_hooks() ->
emqx:unhook('client.authenticate', {emqx_auth_http, check}), emqx:unhook('client.authenticate', {emqx_auth_http, check}),
emqx:unhook('client.check_acl', {emqx_acl_http, check_acl}), emqx:unhook('client.check_acl', {emqx_acl_http, check_acl}),
ehttpc_sup:stop_pool('emqx_auth_http/auth_req'), _ = ehttpc_sup:stop_pool('emqx_auth_http/auth_req'),
ehttpc_sup:stop_pool('emqx_auth_http/super_req'), _ = ehttpc_sup:stop_pool('emqx_auth_http/super_req'),
ehttpc_sup:stop_pool('emqx_auth_http/acl_req'), _ = ehttpc_sup:stop_pool('emqx_auth_http/acl_req'),
ok. ok.
parse_host(Host) -> parse_host(Host) ->

View File

@ -129,7 +129,7 @@ add(_Bindings, Params) ->
case Re of case Re of
#{result := ok} -> return({ok, Re}); #{result := ok} -> return({ok, Re});
#{result := <<"ok">>} -> return({ok, Re}); #{result := <<"ok">>} -> return({ok, Re});
_ -> return({error, Re}) _ -> return({error, {add, Re}})
end end
end. end.

View File

@ -59,12 +59,12 @@ insert_user(User = #emqx_user{login = Login}) ->
%% @doc Update User %% @doc Update User
-spec(update_user(tuple(), binary()) -> ok | {error, any()}). -spec(update_user(tuple(), binary()) -> ok | {error, any()}).
update_user(Login, NewPassword) -> update_user(Login, NewPassword) ->
User = #emqx_user{login = Login, password = encrypted_data(NewPassword)}, ret(mnesia:transaction(fun do_update_user/2, [Login, encrypted_data(NewPassword)])).
ret(mnesia:transaction(fun do_update_user/1, [User])).
do_update_user(User = #emqx_user{login = Login}) -> do_update_user(Login, NewPassword) ->
case mnesia:read(?TABLE, Login) of case mnesia:read(?TABLE, Login) of
[{?TABLE, Login, _, CreateAt}] -> mnesia:write(User#emqx_user{created_at = CreateAt}); [#emqx_user{} = User] ->
mnesia:write(User#emqx_user{password = NewPassword});
[] -> mnesia:abort(noexisted) [] -> mnesia:abort(noexisted)
end. end.
@ -119,7 +119,7 @@ hash(Password, SaltBin, HashType) ->
emqx_passwd:hash(HashType, <<SaltBin/binary, Password/binary>>). emqx_passwd:hash(HashType, <<SaltBin/binary, Password/binary>>).
salt() -> salt() ->
rand:seed(exsplus, erlang:timestamp()), {_AlgHandler, _AlgState} = rand:seed(exsplus, erlang:timestamp()),
Salt = rand:uniform(16#ffffffff), <<Salt:32>>. Salt = rand:uniform(16#ffffffff), <<Salt:32>>.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------