chore(gw): fix dialyzer warnings

This commit is contained in:
JianBo He 2021-09-10 17:41:57 +08:00
parent 18ed1c9794
commit 94c51f9253
2 changed files with 4 additions and 9 deletions

View File

@ -200,7 +200,7 @@ remove_listener(ListenerId) ->
#{<<"listeners">> => #{Type => NLConf}}
).
-spec update_listener(binary(), map()) -> ok | {error, any()}.
-spec update_listener(atom() | binary(), map()) -> ok | {error, any()}.
update_listener(ListenerId, NewConf0) ->
{GwName, Type, Name} = emqx_gateway_utils:parse_listener_id(ListenerId),
NewConf = maps:without([<<"id">>, <<"name">>,
@ -299,7 +299,7 @@ with_channel(GwName, ClientId, Fun) ->
%% Utils
%%--------------------------------------------------------------------
-spec return_http_error(integer(), binary()) -> {integer(), binary()}.
-spec return_http_error(integer(), any()) -> {integer(), binary()}.
return_http_error(Code, Msg) ->
{Code, emqx_json:encode(
#{code => codestr(Code),

View File

@ -33,7 +33,6 @@
, unix_ts_to_rfc3339/2
, listener_id/3
, parse_listener_id/1
, parse_listener_id2/1
]).
-export([ stringfy/1
@ -134,6 +133,8 @@ listener_id(GwName, Type, LisName) ->
(bin(LisName))/binary
>>).
parse_listener_id(Id) when is_atom(Id) ->
parse_listener_id(atom_to_binary(Id));
parse_listener_id(Id) ->
try
[GwName, Type, Name] = binary:split(bin(Id), <<":">>, [global]),
@ -142,12 +143,6 @@ parse_listener_id(Id) ->
_ : _ -> error({invalid_listener_id, Id})
end.
parse_listener_id2(Id) ->
{GwName, Type, Name} = parse_listener_id(Id),
{binary_to_existing_atom(GwName),
binary_to_existing_atom(Type),
binary_to_atom(Name)}.
bin(A) when is_atom(A) ->
atom_to_binary(A);
bin(L) when is_list(L); is_binary(L) ->