Skip to content

Commit a1b8d69

Browse files
Merge pull request #1891 from rabbitmq/fix-dialyzer-warnings-v3.7.x
Fix dialyzer warnings v3.7.x
2 parents cef66a3 + fd72f6e commit a1b8d69

27 files changed

+141
-124
lines changed

src/lager_exchange_backend.erl

Lines changed: 4 additions & 4 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").
@@ -165,8 +165,8 @@ handle_log_event({log, Message},
165165
headers = Headers},
166166
Body = rabbit_data_coercion:to_binary(Formatter:format(Message, FormatConfig)),
167167
case rabbit_basic:publish(LogExch, RoutingKey, AmqpMsg, Body) of
168-
{ok, _DeliveredQPids} -> ok;
169-
{error, not_found} -> ok
168+
ok -> ok;
169+
{error, not_found} -> ok
170170
end,
171171
{ok, State};
172172
false ->

src/rabbit.erl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,10 @@ ensure_config() ->
333333
log_boot_error_and_exit(check_config_file, ErrFmt, ErrArgs)
334334
end,
335335
case rabbit_config:prepare_and_use_config() of
336-
{error, Reason} ->
337-
{Format, Arg} = case Reason of
338-
{generation_error, Error} -> {"~s", [Error]};
339-
Other -> {"~p", [Other]}
340-
end,
336+
{error, {generation_error, Error}} ->
341337
log_boot_error_and_exit(generate_config_file,
342-
"~nConfig file generation failed "++Format,
343-
Arg);
338+
"~nConfig file generation failed ~s",
339+
Error);
344340
ok -> ok
345341
end.
346342

@@ -683,6 +679,7 @@ stop_apps(Apps) ->
683679
end,
684680
ok.
685681

682+
-spec handle_app_error(_) -> fun((_, _) -> no_return()).
686683
handle_app_error(Term) ->
687684
fun(App, {bad_return, {_MFA, {'EXIT', ExitReason}}}) ->
688685
throw({Term, App, ExitReason});
@@ -972,6 +969,7 @@ boot_error(Class, Reason) ->
972969
[lager:pr_stacktrace(erlang:get_stacktrace(), {Class, Reason})] ++
973970
LogLocations).
974971

972+
-spec log_boot_error_and_exit(_, _, _) -> no_return().
975973
log_boot_error_and_exit(Reason, Format, Args) ->
976974
rabbit_log:error(Format, Args),
977975
io:format(standard_error, "~nBOOT FAILED~n===========~n" ++ Format ++ "~n", Args),

src/rabbit_amqqueue.erl

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@
8080
-spec declare
8181
(name(), boolean(), boolean(), rabbit_framing:amqp_table(),
8282
rabbit_types:maybe(pid()), rabbit_types:username()) ->
83-
{'new' | 'existing' | 'absent' | 'owner_died',
84-
rabbit_types:amqqueue()} |
83+
{'new' | 'existing' | 'owner_died', rabbit_types:amqqueue()} |
84+
{'absent', rabbit_types:amqqueue(), absent_reason()} |
8585
rabbit_types:channel_exit().
8686
-spec declare
8787
(name(), boolean(), boolean(), rabbit_framing:amqp_table(),
@@ -129,7 +129,7 @@
129129
-spec notify_policy_changed(rabbit_types:amqqueue()) -> 'ok'.
130130
-spec consumers(rabbit_types:amqqueue()) ->
131131
[{pid(), rabbit_types:ctag(), boolean(), non_neg_integer(),
132-
rabbit_framing:amqp_table()}].
132+
rabbit_framing:amqp_table(), binary()}].
133133
-spec consumer_info_keys() -> rabbit_types:info_keys().
134134
-spec consumers_all(rabbit_types:vhost()) ->
135135
[{name(), pid(), rabbit_types:ctag(), boolean(),
@@ -161,7 +161,7 @@
161161
-spec notify_down_all(qpids(), pid()) -> ok_or_errors().
162162
-spec notify_down_all(qpids(), pid(), non_neg_integer()) ->
163163
ok_or_errors().
164-
-spec activate_limit_all(qpids(), pid()) -> ok_or_errors().
164+
-spec activate_limit_all(qpids(), pid()) -> ok.
165165
-spec basic_get(rabbit_types:amqqueue(), pid(), boolean(), pid()) ->
166166
{'ok', non_neg_integer(), qmsg()} | 'empty'.
167167
-spec credit
@@ -453,6 +453,8 @@ not_found_or_absent(Name) ->
453453
[Q] -> {absent, Q, nodedown} %% Q exists on stopped node
454454
end.
455455

456+
-spec not_found_or_absent_dirty(name()) -> not_found_or_absent().
457+
456458
not_found_or_absent_dirty(Name) ->
457459
%% We should read from both tables inside a tx, to get a
458460
%% consistent view. But the chances of an inconsistency are small,
@@ -465,7 +467,7 @@ not_found_or_absent_dirty(Name) ->
465467
with(Name, F, E) ->
466468
with(Name, F, E, 2000).
467469

468-
with(Name, F, E, RetriesLeft) ->
470+
with(#resource{} = Name, F, E, RetriesLeft) ->
469471
case lookup(Name) of
470472
{ok, Q = #amqqueue{state = live}} when RetriesLeft =:= 0 ->
471473
%% Something bad happened to that queue, we are bailing out
@@ -527,9 +529,15 @@ retry_wait(Q = #amqqueue{pid = QPid, name = Name, state = QState}, F, E, Retries
527529
with(Name, F) -> with(Name, F, fun (E) -> {error, E} end).
528530

529531
with_or_die(Name, F) ->
530-
with(Name, F, fun (not_found) -> rabbit_misc:not_found(Name);
531-
({absent, Q, Reason}) -> rabbit_misc:absent(Q, Reason)
532-
end).
532+
with(Name, F, die_fun(Name)).
533+
534+
-spec die_fun(name()) ->
535+
fun((not_found_or_absent()) -> no_return()).
536+
537+
die_fun(Name) ->
538+
fun (not_found) -> rabbit_misc:not_found(Name);
539+
({absent, Q, Reason}) -> rabbit_misc:absent(Q, Reason)
540+
end.
533541

534542
assert_equivalence(#amqqueue{name = QName,
535543
durable = DurableQ,

src/rabbit_amqqueue_process.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ terminate_shutdown(Fun, #q{status = Status} = State) ->
355355
QName = qname(State),
356356
notify_decorators(shutdown, State),
357357
[emit_consumer_deleted(Ch, CTag, QName, ActingUser) ||
358-
{Ch, CTag, _, _, _} <-
358+
{Ch, CTag, _, _, _, _} <-
359359
rabbit_queue_consumers:all(Consumers)],
360360
State1#q{backing_queue_state = Fun(BQS)}
361361
end.

src/rabbit_basic.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
-type properties_input() ::
3030
rabbit_framing:amqp_property_record() | [{atom(), any()}].
3131
-type publish_result() ::
32-
{ok, [pid()]} | rabbit_types:error('not_found').
32+
ok | rabbit_types:error('not_found').
3333
-type header() :: any().
3434
-type headers() :: rabbit_framing:amqp_table() | 'undefined'.
3535

@@ -107,8 +107,8 @@ publish(Delivery = #delivery{
107107

108108
publish(X, Delivery) ->
109109
Qs = rabbit_amqqueue:lookup(rabbit_exchange:route(X, Delivery)),
110-
DeliveredQPids = rabbit_amqqueue:deliver(Qs, Delivery),
111-
{ok, DeliveredQPids}.
110+
_QPids = rabbit_amqqueue:deliver(Qs, Delivery),
111+
ok.
112112

113113
delivery(Mandatory, Confirm, Message, MsgSeqNo) ->
114114
#delivery{mandatory = Mandatory, confirm = Confirm, sender = self(),

src/rabbit_channel.erl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,9 +773,7 @@ send(Command, #ch{writer_pid = WriterPid}) ->
773773
ok = rabbit_writer:send_command(WriterPid, Command).
774774

775775
format_soft_error(#amqp_error{name = N, explanation = E, method = M}) ->
776-
io_lib:format("operation ~s caused a channel exception ~s: ~ts", [M, N, E]);
777-
format_soft_error(Reason) ->
778-
Reason.
776+
io_lib:format("operation ~s caused a channel exception ~s: ~ts", [M, N, E]).
779777

780778
handle_exception(Reason, State = #ch{protocol = Protocol,
781779
channel = Channel,

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: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ run_checks([C|Cs]) ->
5353
node_health_check(list_channels) ->
5454
case rabbit_channel:info_local([pid]) of
5555
L when is_list(L) ->
56-
ok;
57-
Other ->
58-
ErrorMsg = io_lib:format("list_channels unexpected output: ~p",
59-
[Other]),
60-
{error_string, ErrorMsg}
56+
ok
6157
end;
6258

6359
node_health_check(list_queues) ->
@@ -66,11 +62,7 @@ node_health_check(list_queues) ->
6662
node_health_check(rabbit_node_monitor) ->
6763
case rabbit_node_monitor:partitions() of
6864
L when is_list(L) ->
69-
ok;
70-
Other ->
71-
ErrorMsg = io_lib:format("rabbit_node_monitor reports unexpected partitions value: ~p",
72-
[Other]),
73-
{error_string, ErrorMsg}
65+
ok
7466
end;
7567

7668
node_health_check(alarms) ->
@@ -87,9 +79,5 @@ health_check_queues([]) ->
8779
health_check_queues([VHost|RestVHosts]) ->
8880
case rabbit_amqqueue:info_local(VHost) of
8981
L when is_list(L) ->
90-
health_check_queues(RestVHosts);
91-
Other ->
92-
ErrorMsg = io_lib:format("list_queues unexpected output for vhost ~s: ~p",
93-
[VHost, Other]),
94-
{error_string, ErrorMsg}
82+
health_check_queues(RestVHosts)
9583
end.

src/rabbit_mirror_queue_master.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,18 @@
8181
%% Backing queue
8282
%% ---------------------------------------------------------------------------
8383

84+
-spec start(_, _) -> no_return().
8485
start(_Vhost, _DurableQueues) ->
8586
%% This will never get called as this module will never be
8687
%% installed as the default BQ implementation.
8788
exit({not_valid_for_generic_backing_queue, ?MODULE}).
8889

90+
-spec stop(_) -> no_return().
8991
stop(_Vhost) ->
9092
%% Same as start/1.
9193
exit({not_valid_for_generic_backing_queue, ?MODULE}).
9294

95+
-spec delete_crashed(_) -> no_return().
9396
delete_crashed(_QName) ->
9497
exit({not_valid_for_generic_backing_queue, ?MODULE}).
9598

@@ -223,6 +226,7 @@ purge(State = #state { gm = GM,
223226
{Count, BQS1} = BQ:purge(BQS),
224227
{Count, State #state { backing_queue_state = BQS1 }}.
225228

229+
-spec purge_acks(_) -> no_return().
226230
purge_acks(_State) -> exit({not_implemented, {?MODULE, purge_acks}}).
227231

228232
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
@@ -58,7 +58,8 @@
5858

5959
-spec remove_from_queue
6060
(rabbit_amqqueue:name(), pid(), [pid()]) ->
61-
{'ok', pid(), [pid()], [node()]} | {'error', 'not_found'}.
61+
{'ok', pid(), [pid()], [node()]} | {'error', 'not_found'} |
62+
{'error', {'not_synced', [pid()]}}.
6263
-spec add_mirrors(rabbit_amqqueue:name(), [node()], 'sync' | 'async') ->
6364
'ok'.
6465
-spec store_updated_slaves(rabbit_types:amqqueue()) ->

0 commit comments

Comments
 (0)