Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
0422-megaco-example-meas-Fixed-various-dialyzer...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0422-megaco-example-meas-Fixed-various-dialyzer-issues.patch of Package erlang
From 5a7ccb29acdb18f8c59b97a0a37838154e7efa23 Mon Sep 17 00:00:00 2001 From: Micael Karlberg <bmk@erlang.org> Date: Wed, 13 Jul 2022 16:30:15 +0200 Subject: [PATCH 2/7] [megaco|example|meas] Fixed various dialyzer issues OTP-18179 --- .../examples/meas/megaco_codec_meas.erl | 22 +++++++----- .../examples/meas/megaco_codec_mstone1.erl | 7 ++-- .../examples/meas/megaco_codec_mstone2.erl | 36 +++++++++---------- .../examples/meas/megaco_codec_mstone_lib.erl | 16 +++------ 4 files changed, 37 insertions(+), 44 deletions(-) diff --git a/lib/megaco/examples/meas/megaco_codec_meas.erl b/lib/megaco/examples/meas/megaco_codec_meas.erl index 06983e4dd5..a11d07aaea 100644 --- a/lib/megaco/examples/meas/megaco_codec_meas.erl +++ b/lib/megaco/examples/meas/megaco_codec_meas.erl @@ -144,12 +144,8 @@ display_os_info() -> Str -> Str end, - case os:type() of - {OsFam, OsName} -> - io:format("OS: ~p-~p: ~s~n", [OsFam, OsName, V]); - OsFam -> - io:format("OS: ~p: ~s~n", [OsFam, V]) - end. + {OsFam, OsName} = os:type(), + io:format("OS: ~p-~p: ~s~n", [OsFam, OsName, V]). display_system_info() -> SysArch = string:strip(erlang:system_info(system_architecture),right,$\n), @@ -163,6 +159,16 @@ display_app_info() -> display_megaco_info(), display_asn1_info(). +%% The instruction, nowarn_function, is because I can't figure out +%% how to suppress the warnings about +%% megaco_flex_scanner:is_enabled/0 and +%% megaco_flex_scanner:is_reentrant_enabled/0: +%% +%% "The pattern 'false' can never match the type 'true'" +%% +%% This is because the result of calling these function(s) is +%% basically decided at compile time (true or false). +-dialyzer({nowarn_function, display_megaco_info/0}). display_megaco_info() -> MI = megaco:module_info(), {value, {attributes, Attr}} = lists:keysearch(attributes, 1, MI), @@ -303,9 +309,7 @@ expand_codec(Codec) -> {Codec, megaco_erl_dist_encoder, [compressed], 400}, {Codec, megaco_erl_dist_encoder, [megaco_compressed], 10000}, {Codec, megaco_erl_dist_encoder, [], 10000} - ]; - Else -> - exit({error, {invalid_codec, Else}}) + ] end. diff --git a/lib/megaco/examples/meas/megaco_codec_mstone1.erl b/lib/megaco/examples/meas/megaco_codec_mstone1.erl index 0d3615e7a3..9ed253dd0f 100644 --- a/lib/megaco/examples/meas/megaco_codec_mstone1.erl +++ b/lib/megaco/examples/meas/megaco_codec_mstone1.erl @@ -229,7 +229,7 @@ do_mstone(MessagePackage, RunTime, Factor, Codecs, DrvInclude) -> ?LIB:display_system_info(), ?LIB:display_app_info(), io:format("~n", []), - case ?LIB:start_flex_scanner() of + try ?LIB:start_flex_scanner() of {Pid, Conf} when is_pid(Pid) -> put(flex_scanner_conf, Conf), EMessages = ?LIB:expanded_messages(MessagePackage, Codecs, DrvInclude), @@ -238,8 +238,9 @@ do_mstone(MessagePackage, RunTime, Factor, Codecs, DrvInclude) -> ?LIB:stop_flex_scanner(Pid), io:format("~n", []), io:format("MStone: ~p~n", [MStone]), - done; - {error, Reason} = ERROR -> + done + catch + throw:{error, Reason} = ERROR -> io:format("<ERROR> Failed starting flex scanner: " "~n ~p", [Reason]), ERROR diff --git a/lib/megaco/examples/meas/megaco_codec_mstone2.erl b/lib/megaco/examples/meas/megaco_codec_mstone2.erl index 3a8c1e6916..0368ecc38e 100644 --- a/lib/megaco/examples/meas/megaco_codec_mstone2.erl +++ b/lib/megaco/examples/meas/megaco_codec_mstone2.erl @@ -113,7 +113,7 @@ start([RunTimeAtom, Mode, MessagePackage]) ?LIB:parse_runtime(RunTimeAtom), Mode, MessagePackage); start(RunTime) when is_integer(RunTime) andalso (RunTime > 0) -> do_start(?DEFAULT_FACTOR, - time:minutes(RunTime), ?DEFAULT_MODE, ?DEFAULT_MESSAGE_PACKAGE); + timer:minutes(RunTime), ?DEFAULT_MODE, ?DEFAULT_MESSAGE_PACKAGE); start(MessagePackage) -> do_start(?DEFAULT_FACTOR, ?DEFAULT_RUN_TIME, ?DEFAULT_MODE, MessagePackage). @@ -304,30 +304,26 @@ loader(Factor, RunTime, Mode, Codecs, MessagePackage) -> case (catch init(Factor, RunTime, Mode, Codecs, MessagePackage)) of {ok, State} -> loader_loop(running, State); - Error -> + {error, Reason} = Error -> + io:format("<ERROR> Failed starting loader: " + "~n ~p", [Reason]), exit(Error) end. init(Factor, RunTime, Mode, Codecs, MessagePackage) -> ets:new(mstone, [set, private, named_table, {keypos, 1}]), ets:insert(mstone, {worker_cnt, 0}), - case ?LIB:start_flex_scanner() of - {Pid, FlexConf} when is_pid(Pid) -> - io:format("prepare messages", []), - EMessages = ?LIB:expanded_messages(MessagePackage, Codecs, Mode), - io:format("~ninit codec data", []), - CodecData = init_codec_data(Factor, EMessages, FlexConf), - Timer = erlang:send_after(RunTime, self(), mstone_finished), - io:format(" => ~w concurrent workers~n", [length(CodecData)]), - {ok, #state{timer = Timer, - idle = CodecData, - flex_handler = Pid, - flex_conf = FlexConf}}; - {error, Reason} = ERROR -> - io:format("<ERROR> Failed starting flex scanner: " - "~n ~p", [Reason]), - ERROR - end. + {Pid, FlexConf} = ?LIB:start_flex_scanner(), + io:format("prepare messages", []), + EMessages = ?LIB:expanded_messages(MessagePackage, Codecs, Mode), + io:format("~ninit codec data", []), + CodecData = init_codec_data(Factor, EMessages, FlexConf), + Timer = erlang:send_after(RunTime, self(), mstone_finished), + io:format(" => ~w concurrent workers~n", [length(CodecData)]), + {ok, #state{timer = Timer, + idle = CodecData, + flex_handler = Pid, + flex_conf = FlexConf}}. init_codec_data(Factor, EMsgs, FlexConf) -> init_codec_data_expand(Factor, init_codec_data(EMsgs, FlexConf)). @@ -345,7 +341,7 @@ init_codec_data(Codec, Mod, Conf0, Msgs0, FlexConf) when is_atom(Codec) andalso is_atom(Mod) andalso is_list(Conf0) andalso - is_list(Msgs0) -> + is_list(Msgs0) -> io:format(".", []), Conf = [{version3,?VERSION3}|init_codec_conf(FlexConf, Conf0)], Msgs = [?LIB:detect_version(Mod, Conf, Bin) || {_, Bin} <- Msgs0], diff --git a/lib/megaco/examples/meas/megaco_codec_mstone_lib.erl b/lib/megaco/examples/meas/megaco_codec_mstone_lib.erl index 4ab230c65b..7044a17430 100644 --- a/lib/megaco/examples/meas/megaco_codec_mstone_lib.erl +++ b/lib/megaco/examples/meas/megaco_codec_mstone_lib.erl @@ -83,12 +83,8 @@ display_os_info() -> Str -> Str end, - case os:type() of - {OsFam, OsName} -> - io:format("OS: ~p-~p: ~s~n", [OsFam, OsName, V]); - OsFam -> - io:format("OS: ~p: ~s~n", [OsFam, V]) - end. + {OsFam, OsName} = os:type(), + io:format("OS: ~p-~p: ~s~n", [OsFam, OsName, V]). %%---------------------------------------------------------------------- @@ -191,12 +187,8 @@ display_alloc_info([{Alloc, Mem}|AllocInfo]) -> display_alloc_info(AllocInfo). alloc_info() -> - case erlang:system_info(allocator) of - {_Allocator, _Version, Features, _Settings} -> - alloc_info(Features); - _ -> - [] - end. + {_Allocator, _Version, Features, _Settings} = erlang:system_info(allocator), + alloc_info(Features). alloc_info(Allocators) -> Allocs = [temp_alloc, sl_alloc, std_alloc, ll_alloc, eheap_alloc, -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor