From a86d63b3940c19dedb6ebcf0f684fa9641a9833e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 16 Apr 2014 09:36:06 +0200 Subject: BER: Suppress dialyzer warnings for encode_bit_string/4 We don't want to touch the code used for encoding BIT STRINGs when 'legacy_erl_types' is active, since it will be removed within two or three major releases. But we do want to suppress the dialyzer warnings in the meantime. The easiest way is to call encode_bit_string/4 with unknown types from an exported function that is never actually called like this: -export(['dialyzer-suppressions'/0]). 'dialyzer-suppressions'(Arg) -> {A,B,C,D} = Arg, encode_bit_string(A, B, C, D), ok. --- lib/asn1/src/asn1ct_gen.erl | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/asn1/src/asn1ct_gen.erl') diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl index bfe7df9713..af1301eb42 100644 --- a/lib/asn1/src/asn1ct_gen.erl +++ b/lib/asn1/src/asn1ct_gen.erl @@ -43,6 +43,8 @@ -export([gen_encode_constructed/4, gen_decode_constructed/4]). +-define(SUPPRESSION_FUNC, 'dialyzer-suppressions'). + %% pgen(Outfile, Erules, Module, TypeOrVal, Options) %% Generate Erlang module (.erl) and (.hrl) file corresponding to an ASN.1 module %% .hrl file is only generated if necessary @@ -85,12 +87,18 @@ pgen_module(OutFile,Erules,Module, "%%%",nl, "%%% Run-time functions.",nl, "%%%",nl]), + dialyzer_suppressions(Erules), Fd = get(gen_file_out), asn1ct_func:generate(Fd), close_output_file(), _ = erase(outfile), asn1ct:verbose("--~p--~n",[{generated,ErlFile}],Options). +dialyzer_suppressions(Erules) -> + emit([nl, + {asis,?SUPPRESSION_FUNC},"(Arg) ->",nl]), + Rtmod = ct_gen_module(Erules), + Rtmod:dialyzer_suppressions(Erules). pgen_typeorval(Erules,Module,N2nConvEnums,{Types,Values,_Ptypes,_Classes,Objects,ObjectSets}) -> Rtmod = ct_gen_module(Erules), @@ -791,6 +799,7 @@ gen_decode_constructed(Erules,Typename,InnerType,D) when is_record(D,typedef) -> pgen_exports(Erules,_Module,{Types,Values,_,_,Objects,ObjectSets}) -> emit(["-export([encoding_rule/0,bit_string_format/0,",nl, " legacy_erlang_types/0]).",nl]), + emit(["-export([",{asis,?SUPPRESSION_FUNC},"/1]).",nl]), case Types of [] -> ok; _ -> -- cgit v1.2.3