aboutsummaryrefslogtreecommitdiffstats
path: root/lib/percept/src
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2016-05-16 18:39:31 +0200
committerBjörn-Egil Dahlberg <[email protected]>2016-05-17 13:46:04 +0200
commita4217eeeda0092b66970edda7b585eb4c4796700 (patch)
tree165b8a5270564528540b4112bcbbcc1818d4e2d5 /lib/percept/src
parentf2924fe206b37766cc137f8dbeca746a035abfdb (diff)
downloadotp-a4217eeeda0092b66970edda7b585eb4c4796700.tar.gz
otp-a4217eeeda0092b66970edda7b585eb4c4796700.tar.bz2
otp-a4217eeeda0092b66970edda7b585eb4c4796700.zip
percept: Fix unmatched return warnings
Diffstat (limited to 'lib/percept/src')
-rw-r--r--lib/percept/src/percept.erl11
-rw-r--r--lib/percept/src/percept_db.erl22
-rw-r--r--lib/percept/src/percept_graph.erl20
-rw-r--r--lib/percept/src/percept_html.erl74
4 files changed, 67 insertions, 60 deletions
diff --git a/lib/percept/src/percept.erl b/lib/percept/src/percept.erl
index d53be5f9e2..046e0b7518 100644
--- a/lib/percept/src/percept.erl
+++ b/lib/percept/src/percept.erl
@@ -151,11 +151,11 @@ start_webserver() ->
{'started', string(), pos_integer()} | {'error', any()}.
start_webserver(Port) when is_integer(Port) ->
- application:load(percept),
+ ok = ensure_loaded(percept),
case whereis(percept_httpd) of
undefined ->
{ok, Config} = get_webserver_config("percept", Port),
- inets:start(),
+ ok = application:ensure_started(inets),
case inets:start(httpd, Config) of
{ok, Pid} ->
AssignedPort = find_service_port_from_pid(inets:services_info(), Pid),
@@ -328,3 +328,10 @@ get_webserver_config(Servername, Port) when is_list(Servername), is_integer(Port
{bind_address, any},
{port, Port}],
{ok, Config}.
+
+ensure_loaded(App) ->
+ case application:load(App) of
+ ok -> ok;
+ {error,{already_loaded,App}} -> ok;
+ Error -> Error
+ end.
diff --git a/lib/percept/src/percept_db.erl b/lib/percept/src/percept_db.erl
index 7599a1cd74..6cbe3ce022 100644
--- a/lib/percept/src/percept_db.erl
+++ b/lib/percept/src/percept_db.erl
@@ -94,7 +94,7 @@ restart(PerceptDB)->
-spec do_start()-> pid().
do_start()->
- Pid = spawn( fun() -> init_percept_db() end),
+ Pid = spawn(fun() -> init_percept_db() end),
erlang:register(percept_db, Pid),
Pid.
@@ -117,17 +117,17 @@ stop() ->
%% @private
%% @doc Stops the percept database, with a synchronous call.
--spec stop_sync(pid())-> true.
+-spec stop_sync(pid()) -> true.
-stop_sync(Pid)->
+stop_sync(Pid) ->
MonitorRef = erlang:monitor(process, Pid),
- stop(),
+ _ = stop(),
receive
{'DOWN', MonitorRef, _Type, Pid, _Info}->
true
after ?STOP_TIMEOUT->
- erlang:demonitor(MonitorRef, [flush]),
- exit(Pid, kill)
+ erlang:demonitor(MonitorRef, [flush]),
+ exit(Pid, kill)
end.
%% @spec insert(tuple()) -> ok
@@ -185,19 +185,19 @@ consolidate() ->
init_percept_db() ->
% Proc and Port information
- ets:new(pdb_info, [named_table, private, {keypos, #information.id}, set]),
+ pdb_info = ets:new(pdb_info, [named_table, private, {keypos, #information.id}, set]),
% Scheduler runnability
- ets:new(pdb_scheduler, [named_table, private, {keypos, #activity.timestamp}, ordered_set]),
+ pdb_scheduler = ets:new(pdb_scheduler, [named_table, private, {keypos, #activity.timestamp}, ordered_set]),
% Process and Port runnability
- ets:new(pdb_activity, [named_table, private, {keypos, #activity.timestamp}, ordered_set]),
+ pdb_activity = ets:new(pdb_activity, [named_table, private, {keypos, #activity.timestamp}, ordered_set]),
% System status
- ets:new(pdb_system, [named_table, private, {keypos, 1}, set]),
+ pdb_system = ets:new(pdb_system, [named_table, private, {keypos, 1}, set]),
% System warnings
- ets:new(pdb_warnings, [named_table, private, {keypos, 1}, ordered_set]),
+ pdb_warnings = ets:new(pdb_warnings, [named_table, private, {keypos, 1}, ordered_set]),
put(debug, 0),
loop_percept_db().
diff --git a/lib/percept/src/percept_graph.erl b/lib/percept/src/percept_graph.erl
index 1803e035ab..e5bbaca2b4 100644
--- a/lib/percept/src/percept_graph.erl
+++ b/lib/percept/src/percept_graph.erl
@@ -33,28 +33,28 @@
%%
graph(SessionID, Env, Input) ->
- mod_esi:deliver(SessionID, header()),
- mod_esi:deliver(SessionID, binary_to_list(graph(Env, Input))).
+ ok = mod_esi:deliver(SessionID, header()),
+ ok = mod_esi:deliver(SessionID, binary_to_list(graph(Env, Input))).
%% activity
%% @spec activity(SessionID, Env, Input) -> term()
%% @doc An ESI callback implementation used by the httpd server.
activity(SessionID, Env, Input) ->
- mod_esi:deliver(SessionID, header()),
- mod_esi:deliver(SessionID, binary_to_list(activity_bar(Env, Input))).
+ ok = mod_esi:deliver(SessionID, header()),
+ ok = mod_esi:deliver(SessionID, binary_to_list(activity_bar(Env, Input))).
proc_lifetime(SessionID, Env, Input) ->
- mod_esi:deliver(SessionID, header()),
- mod_esi:deliver(SessionID, binary_to_list(proc_lifetime(Env, Input))).
+ ok = mod_esi:deliver(SessionID, header()),
+ ok = mod_esi:deliver(SessionID, binary_to_list(proc_lifetime(Env, Input))).
percentage(SessionID, Env, Input) ->
- mod_esi:deliver(SessionID, header()),
- mod_esi:deliver(SessionID, binary_to_list(percentage(Env,Input))).
+ ok = mod_esi:deliver(SessionID, header()),
+ ok = mod_esi:deliver(SessionID, binary_to_list(percentage(Env,Input))).
scheduler_graph(SessionID, Env, Input) ->
- mod_esi:deliver(SessionID, header()),
- mod_esi:deliver(SessionID, binary_to_list(scheduler_graph(Env, Input))).
+ ok = mod_esi:deliver(SessionID, header()),
+ ok = mod_esi:deliver(SessionID, binary_to_list(scheduler_graph(Env, Input))).
graph(_Env, Input) ->
Query = httpd:parse_query(Input),
diff --git a/lib/percept/src/percept_html.erl b/lib/percept/src/percept_html.erl
index e0649e1451..a675227584 100644
--- a/lib/percept/src/percept_html.erl
+++ b/lib/percept/src/percept_html.erl
@@ -38,47 +38,47 @@
%% API
page(SessionID, Env, Input) ->
- mod_esi:deliver(SessionID, header()),
- mod_esi:deliver(SessionID, menu()),
- mod_esi:deliver(SessionID, overview_content(Env, Input)),
- mod_esi:deliver(SessionID, footer()).
+ ok = mod_esi:deliver(SessionID, header()),
+ ok = mod_esi:deliver(SessionID, menu()),
+ ok = mod_esi:deliver(SessionID, overview_content(Env, Input)),
+ ok = mod_esi:deliver(SessionID, footer()).
processes_page(SessionID, _, _) ->
- mod_esi:deliver(SessionID, header()),
- mod_esi:deliver(SessionID, menu()),
- mod_esi:deliver(SessionID, processes_content()),
- mod_esi:deliver(SessionID, footer()).
+ ok = mod_esi:deliver(SessionID, header()),
+ ok = mod_esi:deliver(SessionID, menu()),
+ ok = mod_esi:deliver(SessionID, processes_content()),
+ ok = mod_esi:deliver(SessionID, footer()).
concurrency_page(SessionID, Env, Input) ->
- mod_esi:deliver(SessionID, header()),
- mod_esi:deliver(SessionID, menu()),
- mod_esi:deliver(SessionID, concurrency_content(Env, Input)),
- mod_esi:deliver(SessionID, footer()).
+ ok = mod_esi:deliver(SessionID, header()),
+ ok = mod_esi:deliver(SessionID, menu()),
+ ok = mod_esi:deliver(SessionID, concurrency_content(Env, Input)),
+ ok = mod_esi:deliver(SessionID, footer()).
databases_page(SessionID, _, _) ->
- mod_esi:deliver(SessionID, header()),
- mod_esi:deliver(SessionID, menu()),
- mod_esi:deliver(SessionID, databases_content()),
- mod_esi:deliver(SessionID, footer()).
+ ok = mod_esi:deliver(SessionID, header()),
+ ok = mod_esi:deliver(SessionID, menu()),
+ ok = mod_esi:deliver(SessionID, databases_content()),
+ ok = mod_esi:deliver(SessionID, footer()).
codelocation_page(SessionID, Env, Input) ->
- mod_esi:deliver(SessionID, header()),
- mod_esi:deliver(SessionID, menu()),
- mod_esi:deliver(SessionID, codelocation_content(Env, Input)),
- mod_esi:deliver(SessionID, footer()).
+ ok = mod_esi:deliver(SessionID, header()),
+ ok = mod_esi:deliver(SessionID, menu()),
+ ok = mod_esi:deliver(SessionID, codelocation_content(Env, Input)),
+ ok = mod_esi:deliver(SessionID, footer()).
process_info_page(SessionID, Env, Input) ->
- mod_esi:deliver(SessionID, header()),
- mod_esi:deliver(SessionID, menu()),
- mod_esi:deliver(SessionID, process_info_content(Env, Input)),
- mod_esi:deliver(SessionID, footer()).
+ ok = mod_esi:deliver(SessionID, header()),
+ ok = mod_esi:deliver(SessionID, menu()),
+ ok = mod_esi:deliver(SessionID, process_info_content(Env, Input)),
+ ok = mod_esi:deliver(SessionID, footer()).
load_database_page(SessionID, Env, Input) ->
- mod_esi:deliver(SessionID, header()),
+ ok = mod_esi:deliver(SessionID, header()),
% Very dynamic page, handled differently
load_database_content(SessionID, Env, Input),
- mod_esi:deliver(SessionID, footer()).
+ ok = mod_esi:deliver(SessionID, footer()).
%%% --------------------------- %%%
@@ -442,24 +442,24 @@ load_database_content(SessionId, _Env, Input) ->
Filename = filename:join(Path, File),
% Check path/file/filename
- mod_esi:deliver(SessionId, "<div id=\"content\">"),
+ ok = mod_esi:deliver(SessionId, "<div id=\"content\">"),
case file:read_file_info(Filename) of
{ok, _} ->
Content = "<center>
Parsing: " ++ Filename ++ "<br>
</center>",
- mod_esi:deliver(SessionId, Content),
- case percept:analyze(Filename) of
- {error, Reason} ->
- mod_esi:deliver(SessionId, error_msg("Analyze" ++ term2html(Reason)));
- _ ->
- Complete = "<center><a href=\"/cgi-bin/percept_html/page\">View</a></center>",
- mod_esi:deliver(SessionId, Complete)
- end;
+ ok = mod_esi:deliver(SessionId, Content),
+ case percept:analyze(Filename) of
+ {error, Reason} ->
+ ok = mod_esi:deliver(SessionId, error_msg("Analyze" ++ term2html(Reason)));
+ _ ->
+ Complete = "<center><a href=\"/cgi-bin/percept_html/page\">View</a></center>",
+ ok = mod_esi:deliver(SessionId, Complete)
+ end;
{error, Reason} ->
- mod_esi:deliver(SessionId, error_msg("File" ++ term2html(Reason)))
+ ok = mod_esi:deliver(SessionId, error_msg("File" ++ term2html(Reason)))
end,
- mod_esi:deliver(SessionId, "</div>").
+ ok = mod_esi:deliver(SessionId, "</div>").
codelocation_content(_Env, Input) ->
Query = httpd:parse_query(Input),