Inviso

Kostis Sagonas kostis@REDACTED
Sat May 29 14:35:59 CEST 2010


Ulf Wiger suggested a cleanup of the 'inviso' application by tidier and 
I've already done that.  I'll submit a patch via github early next week.

Before starting, I've already noticed that dialyzer complains that:

inviso_tool.erl:586: The pattern {'error', Reason} can never match the 
type {'ok',#ld{...}}

which refers to the init/1 function:

init(Config) ->
     case fetch_configuration(Config) of     % From conf-file and Config.
	{ok,#ld{}=LD} ->
	    case start_inviso_at_c_node(LD) of
		...
	    end;
	{error,Reason} ->
	    {stop,{error,{start_up,Reason}}}
     end.

due to the fact that fetch_configuration/1 returns {ok,...} in all its 
branches -- even in the error case:

fetch_configuration(Config) ->
     case fetch_config_filename(Config) of
	{ok,FName} ->              % We are supposed to use a conf-file.
	    case read_config_file(FName) of
		{ok,LD} ->         % Managed to open a file.
		    NewLD=read_config_list(LD,Config),
		    {ok,NewLD};
		{error,_Reason} -> % Problem finding/opening file.
		    LD=read_config_list(#ld{},Config),
		    {ok,LD}
	    end;
	false ->                   % No filename specified.
	    LD=read_config_list(#ld{},Config),
	    {ok,LD}
     end.

Dialyzer is right, but the question is how should this one be fixed? 
Simply by taking the {error,Reason} case from init/1 or by returning 
{error,Reason} in the {error,Reason} case of fetch_configuration/1?

Kostis


More information about the erlang-bugs mailing list