Skip to content

Fix multiple dialyzer errors #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/chumak_curve_if.erl
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,11 @@ box(Message, Nonce, PublicKey, SecretKey) ->
-spec box_open(Box::binary(),
Nonce::binary(),
PublicKey::binary(),
SecretKey::binary()) -> binary().
SecretKey::binary()) -> {ok, binary()}.
box_open(Box, Nonce, PublicKey, SecretKey) ->
case ?CURVE_MOD of
none ->
throw(not_supported);
nacl ->
{ok, Bin} = nacl:box_open(Box, Nonce, PublicKey, SecretKey),
Bin;
_ ->
?CURVE_MOD:box_open(Box, Nonce, PublicKey, SecretKey)
end.
3 changes: 1 addition & 2 deletions src/chumak_pattern.erl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
-export([module/1, error_msg/1]).

-type pattern_state() :: tuple().
-type module_name() :: chumak_pattern_req.

-callback valid_peer_type(SocketType::socket_type()) -> valid | invalid.
-callback init(Identity::string()) -> {ok, pattern_state()}.
Expand All @@ -36,7 +35,7 @@


%% @doc find matching pattern for a socket type.
-spec module(SocketType::socket_type()) -> module_name() | {error, invalid_socket_type}.
-spec module(SocketType::socket_type()) -> module() | {error, invalid_socket_type}.
module(req) -> chumak_req;
module(rep) -> chumak_rep;
module(dealer) -> chumak_dealer;
Expand Down
8 changes: 3 additions & 5 deletions src/chumak_peer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ send_cancel_subscription(PeerPid, Subscription) ->
gen_server:cast(PeerPid, {send_cancel_subscription, Subscription}).

%% @doc when incoming_queue is enabled, get item from queue
-spec incoming_queue_out(PeerPid::pid()) -> {out, Messages::list()} | empty.
-spec incoming_queue_out(PeerPid::pid()) -> {out, Messages::list()} | empty | {error, _}.
incoming_queue_out(PeerPid) ->
try
gen_server:call(PeerPid, incoming_queue_out)
Expand Down Expand Up @@ -350,7 +350,7 @@ do_handshake(#state{socket = Socket} = State, Decoder) ->
end.

-spec handshake(State::state()) ->
{ok, state()} | {error, Reason::string(), state()}.
{ok, state()} | {error, Reason::term(), state()}.
%% As described in https://rfc.zeromq.org/spec:26/CURVEZMQ/
handshake(#state{mechanism = curve, socket = Socket,
as_server = AsServer, decoder = Decoder,
Expand Down Expand Up @@ -452,9 +452,7 @@ handle_ready_response2(#state{socket=Socket,
{ok, NewState};
{error, {shutdown, invalid_peer_socket_type}, _} = InvSockTypeError->
send_invalid_socket_type_error(Socket, SocketType, PeerSocketType),
InvSockTypeError;
{error, _, _} = OtherError ->
OtherError
InvSockTypeError
end.

validate_peer_socket_type(#state{type=SocketType} = State,
Expand Down
4 changes: 2 additions & 2 deletions src/chumak_protocol.erl
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ encode_message_multipart(Multipart, Mechanism, SecurityData) ->
%% @doc Generate a traffic based on a message
-spec encode_more_message(Message::binary(),
Mechanism::security_mechanism(),
SecurityData::map()) -> Traffic::binary().
SecurityData::map()) -> {Traffic::binary(), map()}.
encode_more_message(Message, Mechanism, SecurityData)
when is_binary(Message) ->
{Frame, NewSecurityData} = build_message(Message,
Expand All @@ -684,7 +684,7 @@ encode_more_message(Message, Mechanism, SecurityData)
%% @doc Generate a traffic based on a message
-spec encode_last_message(Message::binary(),
Mechanism::security_mechanism(),
SecurityData::map()) -> Traffic::binary().
SecurityData::map()) -> {Traffic::binary(), map()}.
encode_last_message(Message, Mechanism, SecurityData)
when is_binary(Message) ->
{Frame, NewSecurityData} = build_message(Message,
Expand Down
14 changes: 1 addition & 13 deletions src/chumak_router.erl
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,4 @@ handle_queue_ready(#chumak_router{recv_queue=RecvQueue, pending_recv=nil}=State,

handle_queue_ready(#chumak_router{pending_recv={from, PendingRecv}}=State, Data)->
gen_server:reply(PendingRecv, {ok, Data}), %% if there is a waiter reply directly
State#chumak_router{pending_recv=nil}.

terminate_lbs(none) ->
ok;
terminate_lbs({_, Val, Next}) ->
terminate_lb(chumak_lb:to_list(Val)),
terminate_lbs(chumak_lbs:next(Next)).

terminate_lb([]) ->
ok;
terminate_lb([H | T]) ->
chumak_peer:close(H),
terminate_lb(T).
State#chumak_router{pending_recv=nil}.