From 40e7c6397cad5609b612dfbeef52aff93096cebd Mon Sep 17 00:00:00 2001 From: riccardo manfrin Date: Thu, 26 Sep 2024 09:39:32 +0200 Subject: [PATCH 1/3] Fixup dialyzer --- include/eradius_lib.hrl | 2 +- src/eradius_lib.erl | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/eradius_lib.hrl b/include/eradius_lib.hrl index eef81b4f..b1fe9231 100644 --- a/include/eradius_lib.hrl +++ b/include/eradius_lib.hrl @@ -6,7 +6,7 @@ -type atom_name() :: atom(). -type atom_ip() :: atom(). -type atom_port() :: atom(). --type atom_address() :: {atom_name(), {atom_ip(), atom_port()}}. +-type atom_address() :: {atom_name(), atom_ip(), atom_port()}. -type atom_address_pair() :: {atom_address(), atom_address()}. %%- cmds diff --git a/src/eradius_lib.erl b/src/eradius_lib.erl index 71ac2de9..a10b2239 100644 --- a/src/eradius_lib.erl +++ b/src/eradius_lib.erl @@ -229,7 +229,7 @@ decode_request_id(_Req) -> {bad_pdu, "invalid request id"}. decode_request(Packet, Secret) -> decode_request(Packet, Secret, undefined). --spec decode_request(binary(), secret(), authenticator()) -> #radius_request{} | {bad_pdu, list()}. +-spec decode_request(binary(), secret(), authenticator() | undefined) -> #radius_request{} | {bad_pdu, list()}. decode_request(Packet, Secret, Authenticator) -> case (catch decode_request0(Packet, Secret, Authenticator)) of {'EXIT', _} -> {bad_pdu, "decode packet error"}; @@ -261,13 +261,13 @@ decode_request0(< Request end. --spec validate_packet_authenticator(non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer(), binary(), binary(), authenticator(), authenticator() | 'undefined') -> ok. +-spec validate_packet_authenticator(non_neg_integer(), non_neg_integer(), non_neg_integer(), binary(), non_neg_integer(), binary(), authenticator(), authenticator() | 'undefined') -> ok. validate_packet_authenticator(Cmd, ReqId, Len, Body, Pos, Secret, PacketAuthenticator, undefined) -> validate_packet_authenticator(Cmd, ReqId, Len, PacketAuthenticator, Body, Pos, Secret); validate_packet_authenticator(Cmd, ReqId, Len, Body, Pos, Secret, _PacketAuthenticator, RequestAuthenticator) -> validate_packet_authenticator(Cmd, ReqId, Len, RequestAuthenticator, Body, Pos, Secret). --spec validate_packet_authenticator(non_neg_integer(), non_neg_integer(), non_neg_integer(), authenticator(), non_neg_integer(), binary(), binary()) -> ok. +-spec validate_packet_authenticator(non_neg_integer(), non_neg_integer(), non_neg_integer(), authenticator(), binary(), non_neg_integer(), binary()) -> ok. validate_packet_authenticator(Cmd, ReqId, Len, Auth, Body, Pos, Secret) -> case Body of <> -> @@ -321,7 +321,7 @@ decode_command(_) -> error({bad_pdu, "unknown request type"} append_attr(Attr, State) -> State#decoder_state{attrs = [Attr | State#decoder_state.attrs]}. --spec decode_attributes(#radius_request{}, binary(), binary()) -> #decoder_state{}. +-spec decode_attributes(#radius_request{}, undefined | binary(), binary()) -> #decoder_state{}. decode_attributes(Req, RequestAuthenticator, As) -> decode_attributes(Req, As, 0, #decoder_state{request_authenticator = RequestAuthenticator}). @@ -508,7 +508,7 @@ pad_to(Width, Binary) -> N -> <> end. --spec timestamp() -> erlang:timestamp(). +-spec timestamp() -> integer(). timestamp() -> erlang:system_time(milli_seconds). From e55cf62995e702e33edaa6d57e818470ee5eb48a Mon Sep 17 00:00:00 2001 From: riccardo manfrin Date: Thu, 26 Sep 2024 12:50:47 +0200 Subject: [PATCH 2/3] CI to check dialyzer --- .github/workflows/main.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7fd1e840..644bef09 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,6 +16,11 @@ jobs: uses: actions/checkout@v3 - name: Build run: rebar3 compile + - name: Dialyzer + run: | + rebar3 dialyzer || true + WARNINGS=$(cat _build/default/*.dialyzer_warnings | grep -e '^$' | wc -l) + if [ ${WARNINGS} -gt 89 ]; then exit -1; fi - name: Run tests run: | rebar3 do xref, ct From 32ec4c4bdde5d8170c54872774d2e723e343b906 Mon Sep 17 00:00:00 2001 From: riccardo manfrin Date: Thu, 26 Sep 2024 14:42:56 +0200 Subject: [PATCH 3/3] Adapt to github CI --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 644bef09..2ee08180 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,7 @@ jobs: run: | rebar3 dialyzer || true WARNINGS=$(cat _build/default/*.dialyzer_warnings | grep -e '^$' | wc -l) - if [ ${WARNINGS} -gt 89 ]; then exit -1; fi + if [ ${WARNINGS} -gt 103 ]; then exit -1; fi - name: Run tests run: | rebar3 do xref, ct