Skip to content

Commit 69fb0fe

Browse files
lukebakkenmergify[bot]
authored andcommitted
Make dialyzer happy by ensuring rabbit_data_coercion:to_list/1 can handle inet:ip_address()
(cherry picked from commit 6c39f68)
1 parent f0e8960 commit 69fb0fe

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

deps/rabbit_common/src/rabbit_data_coercion.erl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,27 @@ to_binary(Val) when is_integer(Val) -> integer_to_binary(Val);
1818
to_binary(Val) when is_function(Val) -> list_to_binary(io_lib:format("~w", [Val]));
1919
to_binary(Val) -> Val.
2020

21-
-spec to_list(Val :: integer() | list() | binary() | atom() | map()) -> list().
21+
-spec to_list(Val :: integer() | list() | binary() | atom() | map() | inet:ip_address()) -> list().
2222
to_list(Val) when is_list(Val) -> Val;
2323
to_list(Val) when is_map(Val) -> maps:to_list(Val);
2424
to_list(Val) when is_atom(Val) -> atom_to_list(Val);
2525
to_list(Val) when is_binary(Val) -> binary_to_list(Val);
26-
to_list(Val) when is_integer(Val) -> integer_to_list(Val).
26+
to_list(Val) when is_integer(Val) -> integer_to_list(Val);
27+
to_list({V0, V1, V2, V3}=Val) when (is_integer(V0) andalso (V0 >=0 andalso V0 =< 255)) andalso
28+
(is_integer(V1) andalso (V1 >=0 andalso V1 =< 255)) andalso
29+
(is_integer(V2) andalso (V2 >=0 andalso V2 =< 255)) andalso
30+
(is_integer(V3) andalso (V3 >=0 andalso V3 =< 255)) ->
31+
io_lib:format("~w", [Val]);
32+
to_list({V0, V1, V2, V3, V4, V5, V6, V7}=Val)
33+
when (is_integer(V0) andalso (V0 >=0 andalso V0 =< 65535)) andalso
34+
(is_integer(V1) andalso (V1 >=0 andalso V1 =< 65535)) andalso
35+
(is_integer(V2) andalso (V2 >=0 andalso V2 =< 65535)) andalso
36+
(is_integer(V3) andalso (V3 >=0 andalso V3 =< 65535)) andalso
37+
(is_integer(V4) andalso (V4 >=0 andalso V4 =< 65535)) andalso
38+
(is_integer(V5) andalso (V5 >=0 andalso V5 =< 65535)) andalso
39+
(is_integer(V6) andalso (V6 >=0 andalso V6 =< 65535)) andalso
40+
(is_integer(V7) andalso (V7 >=0 andalso V7 =< 65535)) ->
41+
io_lib:format("~w", [Val]).
2742

2843
-spec to_atom(Val :: atom() | list() | binary()) -> atom().
2944
to_atom(Val) when is_atom(Val) -> Val;

deps/rabbitmq_auth_backend_http/src/rabbit_auth_backend_http.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ parse_peeraddr(unknown) ->
200200
parse_peeraddr(PeerAddr) ->
201201
handle_inet_ntoa_peeraddr(inet:ntoa(PeerAddr), PeerAddr).
202202

203-
-spec handle_inet_ntoa_peeraddr({'error', term()} | string(), inet:ip_address()) -> string().
203+
-spec handle_inet_ntoa_peeraddr({'error', term()} | string(), inet:ip_address() | unknown) -> string().
204204
handle_inet_ntoa_peeraddr({error, einval}, PeerAddr) ->
205205
rabbit_data_coercion:to_list(PeerAddr);
206206
handle_inet_ntoa_peeraddr(PeerAddrStr, _PeerAddr0) ->

0 commit comments

Comments
 (0)