Skip to content

Commit

Permalink
Some dialyzer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mworrell committed May 31, 2024
1 parent 4b00a71 commit 66cb9ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
15 changes: 4 additions & 11 deletions src/mqtt_sessions_process.erl
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,8 @@ packet_pubrec(#{ packet_id := PacketId }, #state{ awaiting_ack = WaitAck } = Sta
{ok, #wait_for{ msg_nr = MsgNr, type = pubrec }} ->
WaitFor = #wait_for{
msg_nr = MsgNr,
type = pubcomp
type = pubcomp,
queued = mqtt_sessions_timestamp:timestamp()
},
{WaitAck#{ PacketId => WaitFor }, ?MQTT_RC_SUCCESS};
{ok, #wait_for{ type = pubcomp }} ->
Expand Down Expand Up @@ -1083,8 +1084,6 @@ disconnect_transport(#state{ transport = {M, F, A} } = State) ->
erlang:apply(M, F, [disconnect | A]),
State#state{ transport = undefined, is_connected = false }.

reply_to_transport(undefined, State) ->
State;
reply_to_transport(_Msg, #state{ transport = undefined } = State) ->
State;
reply_to_transport(Msg, State) ->
Expand All @@ -1095,8 +1094,6 @@ reply_to_transport(Msg, State) ->
force_disconnect(State)
end.

reply_or_drop(undefined, State) ->
State;
reply_or_drop(_Msg, #state{ is_connected = false } = State) ->
State;
reply_or_drop(Msg, State) ->
Expand All @@ -1107,8 +1104,6 @@ reply_or_drop(Msg, State) ->
force_disconnect(State)
end.

reply_or_queue(undefined, _MsgNr, State) ->
State;
reply_or_queue(Msg, MsgNr, #state{ is_connected = false } = State) ->
maybe_purge( queue(Msg, MsgNr, State) );
reply_or_queue(Msg, MsgNr, State) ->
Expand Down Expand Up @@ -1172,7 +1167,7 @@ maybe_purge_ack(WaitAcks) ->
end,
WaitAcks).

maybe_purge_buffer(Buffer) ->
maybe_purge_buffer(Buffer) when is_map(Buffer) ->
case maps:size(Buffer) > ?MAX_BUFFERED of
true -> purge_buffer(Buffer);
false -> Buffer
Expand Down Expand Up @@ -1213,9 +1208,7 @@ purge_buffer(Buffer) ->
-spec encode( mqtt_packet_map:mqtt_version(), mqtt_packet_map:mqtt_packet() | list( mqtt_packet_map:mqtt_packet() )) -> binary().
encode(ProtocolVersion, Msg) when is_map(Msg) ->
{ok, Bin} = mqtt_packet_map:encode(ProtocolVersion, Msg),
Bin;
encode(ProtocolVersion, Ms) when is_list(Ms) ->
iolist_to_binary([ encode(ProtocolVersion, M) || M <- Ms ]).
Bin.


%% @doc Set the new connection, disconnect existing transport.
Expand Down
2 changes: 1 addition & 1 deletion test/mqtt_sessions_protocol_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
-dialyzer({nowarn_function, connect_disconnect_v5_test/1}).
-dialyzer({nowarn_function, connect_reconnect_v5_test/1}).
-dialyzer({nowarn_function, connect_reconnect_clean_v5_test/1}).

-dialyzer({nowarn_function, connect_reconnect_buffered_v5_test/1}).

%%--------------------------------------------------------------------
%% COMMON TEST CALLBACK FUNCTIONS
Expand Down

0 comments on commit 66cb9ce

Please sign in to comment.