travelping / pfcplib

Erlang library for encoding and decoding Packet Forwarding Control Protocol (PFCP) frames.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

issue with dialyzer on elixir

jbdamiano opened this issue · comments

Example to reproduce the issue with dialyzer:
pfcpdialyzer.tar.gz

When I call the :pfcp_packet.decode dialyzer believes that an exception will always be lifted by module pfcp_packet
with gtp_packet I don't have this behaviour

To verify that test is working correctly:

  • mix deps.get
  • iex -S mix
  • Pfcpdialyzer.test()

to see the dialyzer error
mix dialyzer
lib/pfcpdialyzer.ex:42:unused_fun
Function dump_pfcp_data/1 will never be called.


Hi @jbdamiano. Many thanks for your report! Current library is not focused on dialyzer. Used only xref. Maybe in some future will be changed something but not sure that it will happen quickly. As a workaround, I would recommend adding a dialyzer tag to ignore the behavior in your source code - no_behaviours and/or functions call.

Hi @vkatsuba.
Do you have plan to support dialyzer ? I tried to start dialyzer on it with rebar3 dialyzer and the report is:

$ rebar3 dialyzer
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling pfcplib
===> Dialyzer starting, this may take a while...
===> Updating plt...
===> Resolving files...
===> Checking 205 files in _build/default/rebar3_24.1_plt...
===> Doing success typing analysis...
===> Resolving files...
===> Analyzing 1 files with _build/default/rebar3_24.1_plt...

src/pfcp_packet.erl
Line 32 Column 1: Function decode/1 has no local return
Line 35 Column 1: Function decode/2 has no local return
Line 146 Column 1: Function decode_header/1 has no local return
Line 150 Column 1: Function decode_v1_msg/4 has no local return
Line 151 Column 89: Record construction #pfcp{version::'v1',type::atom() | 1..255,seid::non_neg_integer(),seq_no::non_neg_integer(),ie::binary()} violates the declared type of field ie::[any()] | map()
Line 153 Column 94: Record construction #pfcp{version::'v1',type::atom() | 1..255,seq_no::non_neg_integer(),ie::binary()} violates the declared type of field ie::[any()] | map()
Line 225 Column 1: Function maybe/4 will never be called
Line 234 Column 1: Function bin/4 will never be called
Line 238 Column 1: Function float/4 will never be called
Line 243 Column 1: Function int/4 will never be called
Line 251 Column 1: Function spare/3 will never be called
Line 294 Column 1: Function maybe_atom/2 will never be called
Line 299 Column 1: Function maybe_bin/5 will never be called
Line 311 Column 1: Function maybe_len_bin/5 will never be called
Line 322 Column 1: Function maybe_unsigned_integer/5 will never be called
Line 333 Column 1: The pattern <<<0:1,Type:15,Length:16,_/binary>>, IEs> can never match the type <<<>> | [any()] | map(),map()>
Line 338 Column 1: The pattern <<<1:1,Type:15,Length:16,EnterpriseId:16,Rest0/binary>>, IEs> can never match the type <<<>> | [any()] | map(),map()>
Line 348 Column 1: Function decode_v1_grouped/1 will never be called
Line 417 Column 1: Function decode_mcc/1 will never be called
Line 420 Column 1: Function decode_mnc/1 will never be called
Line 434 Column 1: Function decode_f_teid/2 will never be called
Line 460 Column 1: Function decode_fqdn/1 will never be called
Line 466 Column 1: Function decode_sdf_filter/2 will never be called
Line 488 Column 1: Function decode_volume_measurement/2 will never be called
Line 515 Column 1: Function decode_volume_threshold/2 will never be called
Line 529 Column 1: Function decode_downlink_data_service_information/2 will never be called
Line 544 Column 1: Function decode_dl_buffering_suggested_packet_count/2 will never be called
Line 556 Column 1: Function decode_f_seid/2 will never be called
Line 567 Column 1: Function decode_node_id/2 will never be called
Line 574 Column 1: Function encode_node_id/1 has no local return
Line 575 Column 8: Guard test is_binary(IPv4::{'fqdn',binary()} | {'ipv4',binary()} | {'ipv6',binary()}) can never succeed
Line 578 Column 8: Guard test is_binary(IPv6::{'fqdn',binary()} | {'ipv4',binary()} | {'ipv6',binary()}) can never succeed
Line 581 Column 8: Guard test is_list(FQDN::{'fqdn',binary()} | {'ipv4',binary()} | {'ipv6',binary()}) can never succeed
Line 584 Column 1: Function decode_pfd_contents/2 will never be called
Line 614 Column 1: Function decode_fq_csid/2 will never be called
Line 636 Column 22: The call erlang:'*'(MCC::'integer', 1000) will never return since it differs in the 1st argument from the success typing arguments: (number(), number())
Line 640 Column 1: Function decode_dropped_dl_traffic_threshold/2 will never be called
Line 654 Column 1: Function decode_outer_header_creation/2 will never be called
Line 709 Column 39: The call pfcp_packet:bin(IPv4::'undefined' | {byte(),byte(),byte(),byte()}, 4, __cut_16::any()) will never return since it differs in the 1st argument from the success typing arguments: (<<_:24,_:_*8>>, 3 | 4 | 6 | 16, binary())
Line 710 Column 39: The call pfcp_packet:bin(IPv6::'undefined' | {char(),char(),char(),char(),char(),char(),char(),char()}, 16, __cut_17::any()) will never return since it differs in the 1st argument from the success typing arguments: (<<_:24,_:_*8>>, 3 | 4 | 6 | 16, binary())
Line 715 Column 1: Function decode_ue_ip_address/2 will never be called
Line 760 Column 1: Function decode_packet_rate/2 will never be called
Line 802 Column 1: Function decode_dl_flow_level_marking/2 will never be called
Line 815 Column 1: Function decode_remote_peer/2 will never be called
Line 833 Column 1: Function decode_failed_rule_id/2 will never be called
Line 855 Column 1: Function decode_user_plane_ip_resource_information/2 will never be called
Line 897 Column 1: Function decode_mac_address/2 will never be called
Line 913 Column 1: Function decode_vlan_tag/2 will never be called
Line 927 Column 1: Function decode_user_id/2 will never be called
Line 947 Column 1: Function decode_mac_addresses/2 will never be called
Line 962 Column 1: Function decode_alternative_smf_ip_address/2 will never be called
Line 976 Column 1: Function decode_cp_pfcp_entity_ip_address/2 will never be called
Line 990 Column 1: Function decode_ip_multicast_address/2 will never be called
Line 1026 Column 1: Function decode_source_ip_address/3 will never be called
Line 1031 Column 1: Function decode_source_ip_address/2 will never be called
Line 1049 Column 1: Function decode_packet_rate_status/2 will never be called
Line 1085 Column 1: Function decode_tsn_bridge_id/2 will never be called
Line 1096 Column 1: Function decode_mptcp_address_information/2 will never be called
Line 1112 Column 1: Function decode_ue_link_specific_ip_address/2 will never be called
Line 1135 Column 1: Function decode_pmf_address_information/2 will never be called
Line 1161 Column 1: Function decode_packet_delay_thresholds/2 will never be called
Line 1187 Column 1: Function decode_qos_monitoring_measurement/2 will never be called
Line 1215 Column 1: Function decode_number_of_ue_ip_addresses/2 will never be called
Line 1229 Column 1: Function decode_ppp_protocol/2 will never be called
Line 1240 Column 1: Function decode_l2tp_tunnel_endpoint/2 will never be called
Line 1260 Column 1: Function decode_bbf_nat_external_port_range/2 will never be called
Line 1267 Column 1: Function decode_bbf_nat_port_forward/2 will never be called
Line 1622 Column 1: Function decode_v1_element/2 will never be called
===> Warnings written to _build/default/24.1.dialyzer_warnings
===> Warnings occurred running dialyzer: 68

this is explain the dialyzer error.

@jbdamiano as you already mention - current library have a lot of dialyzer warnings which do not quite correspond to one or another logic, which complicates support dialyzer in current project. We will keep this issue open for some time and will try to fix it, but this will be not asap, by this reason I proposed to you some workaround to add the ignore warnings option of dialyzer.

@vkatsuba attached a diff on .hlr to fix a lot of issue raised by dialyzer
change.zip

with this change the only remaining error with dialyzer are
src/pfcp_packet.erl
Line 709 Column 39: The call pfcp_packet:bin(IPv4::'undefined' | {byte(),byte(),byte(),byte()}, 4, __cut_16::any()) will never return since it differs in the 1st argument from the success typing arguments: (<<:24,:*8>>, 3 | 4 | 6 | 16, binary())
Line 710 Column 39: The call pfcp_packet:bin(IPv6::'undefined' | {char(),char(),char(),char(),char(),char(),char(),char()}, 16, __cut_17::any()) will never return since it differs in the 1st argument from the success typing arguments: (<<
:24,:*8>>, 3 | 4 | 6 | 16, binary())

@jbdamiano many thanks. You can always provide a PR for fix it 🙃 if you will have a time for it.

@jbdamiano new release https://github.com/travelping/pfcplib/releases/tag/2.1.2 with your fixes/refactoring is created and able in https://hex.pm/packages/pfcplib too. Thanks again for your contribution.