From 18ae158f45be67d93a8f3123a357b250cc685ddc Mon Sep 17 00:00:00 2001 From: "ayodele.akingbule" Date: Fri, 13 Nov 2020 00:33:49 +0100 Subject: [PATCH] fix(emqx_plugins, emqx_sys, emqx_sys_mon, emqx_ws_connection): Dialyzer warnings --- src/emqx_plugins.erl | 8 ++++---- src/emqx_sys.erl | 14 +++++++------- src/emqx_sys_mon.erl | 4 ++-- src/emqx_ws_connection.erl | 28 ++++++++++++++-------------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/emqx_plugins.erl b/src/emqx_plugins.erl index b62e9eb85..37bfcf7ba 100644 --- a/src/emqx_plugins.erl +++ b/src/emqx_plugins.erl @@ -65,7 +65,7 @@ load() -> case emqx:get_env(plugins_loaded_file) of undefined -> ignore; %% No plugins available File -> - ensure_file(File), + _ = ensure_file(File), with_loaded_file(File, fun(Names) -> load_plugins(Names, false) end) end. @@ -165,7 +165,7 @@ load_expand_plugins() -> load_expand_plugin(PluginDir) -> init_expand_plugin_config(PluginDir), Ebin = filename:join([PluginDir, "ebin"]), - code:add_patha(Ebin), + _ = code:add_patha(Ebin), Modules = filelib:wildcard(filename:join([Ebin, "*.beam"])), lists:foreach(fun(Mod) -> Module = list_to_atom(filename:basename(Mod, ".beam")), @@ -246,7 +246,7 @@ apply_configs([{App, Config} | More]) -> %% Stop plugins stop_plugins(Names) -> - [stop_app(App) || App <- Names], + _ = [stop_app(App) || App <- Names], ok. plugin(AppName, Type) -> @@ -297,7 +297,7 @@ start_app(App, SuccFun) -> unload_plugin(App, Persistent) -> case stop_app(App) of ok -> - plugin_unloaded(App, Persistent), ok; + _ = plugin_unloaded(App, Persistent), ok; {error, Reason} -> {error, Reason} end. diff --git a/src/emqx_sys.erl b/src/emqx_sys.erl index 38387b3ce..c77c23c49 100644 --- a/src/emqx_sys.erl +++ b/src/emqx_sys.erl @@ -151,16 +151,16 @@ handle_cast(Msg, State) -> {noreply, State}. handle_info({timeout, TRef, heartbeat}, State = #state{heartbeat = TRef}) -> - publish(uptime, iolist_to_binary(uptime(State))), - publish(datetime, iolist_to_binary(datetime())), + _ = publish(uptime, iolist_to_binary(uptime(State))), + _ = publish(datetime, iolist_to_binary(datetime())), {noreply, heartbeat(State)}; handle_info({timeout, TRef, tick}, State = #state{ticker = TRef, version = Version, sysdescr = Descr}) -> - publish(version, Version), - publish(sysdescr, Descr), - publish(brokers, ekka_mnesia:running_nodes()), - publish(stats, emqx_stats:getstats()), - publish(metrics, emqx_metrics:all()), + _ = publish(version, Version), + _ = publish(sysdescr, Descr), + _ = publish(brokers, ekka_mnesia:running_nodes()), + _ = publish(stats, emqx_stats:getstats()), + _ = publish(metrics, emqx_metrics:all()), {noreply, tick(State), hibernate}; handle_info(Info, State) -> diff --git a/src/emqx_sys_mon.erl b/src/emqx_sys_mon.erl index 5ee22c563..632dcf579 100644 --- a/src/emqx_sys_mon.erl +++ b/src/emqx_sys_mon.erl @@ -55,7 +55,7 @@ start_link(Opts) -> %%-------------------------------------------------------------------- init([Opts]) -> - erlang:system_monitor(self(), parse_opt(Opts)), + _ = erlang:system_monitor(self(), parse_opt(Opts)), emqx_logger:set_proc_metadata(#{sysmon => true}), %% Monitor cluster partition event @@ -174,7 +174,7 @@ suppress(Key, SuccFun, State = #{events := Events}) -> true -> {noreply, State}; false -> - SuccFun(), + _ = SuccFun(), {noreply, State#{events := [Key|Events]}} end. diff --git a/src/emqx_ws_connection.erl b/src/emqx_ws_connection.erl index 33b882768..b87251640 100644 --- a/src/emqx_ws_connection.erl +++ b/src/emqx_ws_connection.erl @@ -63,7 +63,7 @@ %% Simulate the active_n opt active_n :: pos_integer(), %% MQTT Piggyback - mqtt_piggyback :: single | multiple, + mqtt_piggyback :: single | multiple, %% Limiter limiter :: maybe(emqx_limiter:limiter()), %% Limit Timer @@ -535,7 +535,7 @@ handle_outgoing(Packets, State = #state{active_n = ActiveN, mqtt_piggyback = MQT postpone({check_gc, Stats}, State); false -> State end, - + {case MQTTPiggyback of single -> [{binary, IoData}]; multiple -> lists:map(fun(Bin) -> {binary, Bin} end, IoData) @@ -568,33 +568,33 @@ serialize_and_inc_stats_fun(#state{serialize = Serialize}) -> ]}). inc_recv_stats(Cnt, Oct) -> - emqx_pd:inc_counter(incoming_bytes, Oct), - emqx_pd:inc_counter(recv_cnt, Cnt), - emqx_pd:inc_counter(recv_oct, Oct), + _ = emqx_pd:inc_counter(incoming_bytes, Oct), + _ = emqx_pd:inc_counter(recv_cnt, Cnt), + _ = emqx_pd:inc_counter(recv_oct, Oct), emqx_metrics:inc('bytes.received', Oct). inc_incoming_stats(Packet = ?PACKET(Type)) -> - emqx_pd:inc_counter(recv_pkt, 1), + _ = emqx_pd:inc_counter(recv_pkt, 1), if Type == ?PUBLISH -> - emqx_pd:inc_counter(recv_msg, 1), - emqx_pd:inc_counter(incoming_pubs, 1); + _ = emqx_pd:inc_counter(recv_msg, 1), + _ = emqx_pd:inc_counter(incoming_pubs, 1); true -> ok end, emqx_metrics:inc_recv(Packet). inc_outgoing_stats(Packet = ?PACKET(Type)) -> - emqx_pd:inc_counter(send_pkt, 1), + _ = emqx_pd:inc_counter(send_pkt, 1), if Type == ?PUBLISH -> - emqx_pd:inc_counter(send_msg, 1), - emqx_pd:inc_counter(outgoing_pubs, 1); + _ = emqx_pd:inc_counter(send_msg, 1), + _ = emqx_pd:inc_counter(outgoing_pubs, 1); true -> ok end, emqx_metrics:inc_sent(Packet). inc_sent_stats(Cnt, Oct) -> - emqx_pd:inc_counter(outgoing_bytes, Oct), - emqx_pd:inc_counter(send_cnt, Cnt), - emqx_pd:inc_counter(send_oct, Oct), + _ = emqx_pd:inc_counter(outgoing_bytes, Oct), + _ = emqx_pd:inc_counter(send_cnt, Cnt), + _ = emqx_pd:inc_counter(send_oct, Oct), emqx_metrics:inc('bytes.sent', Oct). %%--------------------------------------------------------------------