Skip to content

Commit 28fc8ee

Browse files
committed
Fix many Dialyzer warnings
1 parent e21f24f commit 28fc8ee

13 files changed

+50
-34
lines changed

src/lager_exchange_backend.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
-record(state, {level :: {'mask', integer()},
4040
formatter :: atom(),
4141
format_config :: any(),
42-
init_exchange_ts = undefined :: rabbit_types:timestamp(),
43-
exchange = undefined :: #resource{}}).
42+
init_exchange_ts = undefined :: integer() | undefined,
43+
exchange = undefined :: #resource{} | undefined}).
4444

4545
-ifdef(TEST).
4646
-include_lib("eunit/include/eunit.hrl").

src/lqueue.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
?MODULE/1
3131
]).
3232

33-
-opaque ?MODULE() :: {non_neg_integer(), queue:queue(term())}.
33+
-opaque ?MODULE() :: ?MODULE(_).
3434
-opaque ?MODULE(T) :: {non_neg_integer(), queue:queue(T)}.
3535
-type value() :: any().
3636
-type result(T) :: 'empty' | {'value', T}.

src/rabbit.erl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,10 @@ ensure_config() ->
314314
log_boot_error_and_exit(check_config_file, ErrFmt, ErrArgs)
315315
end,
316316
case rabbit_config:prepare_and_use_config() of
317-
{error, Reason} ->
318-
{Format, Arg} = case Reason of
319-
{generation_error, Error} -> {"~s", [Error]};
320-
Other -> {"~p", [Other]}
321-
end,
317+
{error, {generation_error, Error}} ->
322318
log_boot_error_and_exit(generate_config_file,
323-
"~nConfig file generation failed "++Format,
324-
Arg);
319+
"~nConfig file generation failed ~s",
320+
Error);
325321
ok -> ok
326322
end.
327323

@@ -688,6 +684,7 @@ stop_apps(Apps) ->
688684
end,
689685
ok.
690686

687+
-spec handle_app_error(_) -> fun((_, _) -> no_return()).
691688
handle_app_error(Term) ->
692689
fun(App, {bad_return, {_MFA, {'EXIT', ExitReason}}}) ->
693690
throw({Term, App, ExitReason});
@@ -1006,6 +1003,7 @@ boot_error(Class, Reason) ->
10061003
[lager:pr_stacktrace(erlang:get_stacktrace(), {Class, Reason})] ++
10071004
LogLocations).
10081005

1006+
-spec log_boot_error_and_exit(_, _, _) -> no_return().
10091007
log_boot_error_and_exit(Reason, Format, Args) ->
10101008
rabbit_log:error(Format, Args),
10111009
io:format(standard_error, "~nBOOT FAILED~n===========~n" ++ Format ++ "~n", Args),

src/rabbit_config.erl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ maybe_set_net_ticktime(KernelConfig) ->
121121
io:format(standard_error,
122122
"~nCouldn't set net_ticktime to ~p "
123123
"as net_kernel is busy changing net_ticktime to ~p seconds ~n",
124-
[NetTickTime, NewNetTicktime]);
125-
_ ->
126-
ok
124+
[NetTickTime, NewNetTicktime])
127125
end
128126
end.
129127

src/rabbit_health_check.erl

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,15 @@ run_checks([C|Cs]) ->
5151
Error
5252
end.
5353

54+
%% A lot of health checks seem to not be able to fail anymore.
5455
node_health_check(list_channels) ->
5556
case rabbit_channel:info_local([pid]) of
5657
L when is_list(L) ->
57-
ok;
58-
Other ->
59-
ErrorMsg = io_lib:format("list_channels unexpected output: ~p",
60-
[Other]),
61-
{error_string, ErrorMsg}
58+
ok%;
59+
% Other ->
60+
% ErrorMsg = io_lib:format("list_channels unexpected output: ~p",
61+
% [Other]),
62+
% {error_string, ErrorMsg}
6263
end;
6364

6465
node_health_check(list_queues) ->
@@ -67,11 +68,11 @@ node_health_check(list_queues) ->
6768
node_health_check(rabbit_node_monitor) ->
6869
case rabbit_node_monitor:partitions() of
6970
L when is_list(L) ->
70-
ok;
71-
Other ->
72-
ErrorMsg = io_lib:format("rabbit_node_monitor reports unexpected partitions value: ~p",
73-
[Other]),
74-
{error_string, ErrorMsg}
71+
ok%;
72+
% Other ->
73+
% ErrorMsg = io_lib:format("rabbit_node_monitor reports unexpected partitions value: ~p",
74+
% [Other]),
75+
% {error_string, ErrorMsg}
7576
end;
7677

7778
node_health_check(alarms) ->
@@ -88,9 +89,9 @@ health_check_queues([]) ->
8889
health_check_queues([VHost|RestVHosts]) ->
8990
case rabbit_amqqueue:info_local(VHost) of
9091
L when is_list(L) ->
91-
health_check_queues(RestVHosts);
92-
Other ->
93-
ErrorMsg = io_lib:format("list_queues unexpected output for vhost ~s: ~p",
94-
[VHost, Other]),
95-
{error_string, ErrorMsg}
92+
health_check_queues(RestVHosts)%;
93+
% Other ->
94+
% ErrorMsg = io_lib:format("list_queues unexpected output for vhost ~s: ~p",
95+
% [VHost, Other]),
96+
% {error_string, ErrorMsg}
9697
end.

src/rabbit_mirror_queue_master.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,18 @@
7070
%% Backing queue
7171
%% ---------------------------------------------------------------------------
7272

73+
-spec start(_, _) -> no_return().
7374
start(_Vhost, _DurableQueues) ->
7475
%% This will never get called as this module will never be
7576
%% installed as the default BQ implementation.
7677
exit({not_valid_for_generic_backing_queue, ?MODULE}).
7778

79+
-spec stop(_) -> no_return().
7880
stop(_Vhost) ->
7981
%% Same as start/1.
8082
exit({not_valid_for_generic_backing_queue, ?MODULE}).
8183

84+
-spec delete_crashed(_) -> no_return().
8285
delete_crashed(_QName) ->
8386
exit({not_valid_for_generic_backing_queue, ?MODULE}).
8487

@@ -228,6 +231,7 @@ purge(State = #state { gm = GM,
228231
{Count, BQS1} = BQ:purge(BQS),
229232
{Count, State #state { backing_queue_state = BQS1 }}.
230233

234+
-spec purge_acks(_) -> no_return().
231235
purge_acks(_State) -> exit({not_implemented, {?MODULE, purge_acks}}).
232236

233237
publish(Msg = #basic_message { id = MsgId }, MsgProps, IsDelivered, ChPid, Flow,

src/rabbit_mirror_queue_misc.erl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161

6262
-spec remove_from_queue
6363
(rabbit_amqqueue:name(), pid(), [pid()]) ->
64-
{'ok', pid(), [pid()], [node()]} | {'error', 'not_found'}.
64+
{'ok', pid(), [pid()], [node()]} | {'error', 'not_found'} |
65+
{'error', {'not_synced', [pid()]}}.
6566

6667
remove_from_queue(QueueName, Self, DeadGMPids) ->
6768
rabbit_misc:execute_mnesia_transaction(

src/rabbit_mirror_queue_sync.erl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ master_prepare(Ref, QName, Log, SPids) ->
7878
non_neg_integer(),
7979
bq(), bqs()) ->
8080
{'already_synced', bqs()} | {'ok', bqs()} |
81+
{'cancelled', bqs()} |
8182
{'shutdown', any(), bqs()} |
8283
{'sync_died', any(), bqs()}.
8384

src/rabbit_networking.erl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ tcp_listener_addresses_auto(Port) ->
177177

178178
-spec tcp_listener_spec
179179
(name_prefix(), address(), [gen_tcp:listen_option()], module(), module(),
180-
protocol(), any(), non_neg_integer(), label()) ->
180+
any(), protocol(), non_neg_integer(), label()) ->
181181
supervisor:child_spec().
182182

183183
tcp_listener_spec(NamePrefix, {IPAddress, Port, Family}, SocketOpts,
@@ -285,6 +285,10 @@ tcp_listener_stopped(Protocol, Opts, IPAddress, Port) ->
285285
port = Port,
286286
opts = Opts}).
287287

288+
%% @todo Temporary, to be removed before merge. Real fix is
289+
%% in an OTP PR at https://github.com/erlang/otp/pull/2117
290+
-dialyzer({nowarn_function, record_distribution_listener/0}).
291+
288292
record_distribution_listener() ->
289293
{Name, Host} = rabbit_nodes:parts(node()),
290294
{port, Port, _Version} = erl_epmd:port_please(Name, Host),
@@ -449,6 +453,7 @@ gethostaddr(Host, Family) ->
449453
{error, Reason} -> host_lookup_error(Host, Reason)
450454
end.
451455

456+
-spec host_lookup_error(_, _) -> no_return().
452457
host_lookup_error(Host, Reason) ->
453458
rabbit_log:error("invalid host ~p - ~p~n", [Host, Reason]),
454459
throw({error, {invalid_host, Host, Reason}}).

src/rabbit_plugins.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ is_loadable(App) ->
310310

311311

312312
%% List running plugins along with their version.
313-
-spec running_plugins() -> [{atom(), Vsn :: string()}].
313+
-spec running_plugins() -> {ok, [{atom(), Vsn :: string()}]}.
314314
running_plugins() ->
315315
ActivePlugins = active(),
316316
{ok, [{App, Vsn} || {App, _ , Vsn} <- rabbit_misc:which_applications(), lists:member(App, ActivePlugins)]}.

0 commit comments

Comments
 (0)