Got rid of Dialyzer warnings

This commit is contained in:
Alexey Romanov
2010-10-14 12:40:47 +04:00
parent bab3014e1a
commit 56bfbe484d
2 changed files with 37 additions and 30 deletions

View File

@@ -1,23 +1,24 @@
REBAR=./rebar REBAR=./rebar
REBAR_COMPILE=$(REBAR) get-deps compile
all: compile all: compile
compile: compile:
$(REBAR) get-deps compile $(REBAR_COMPILE)
test: all test:
$(REBAR) skip_deps=true eunit $(REBAR_COMPILE) skip_deps=true eunit
clean: clean:
-rm -rf deps ebin priv doc/* -rm -rf deps ebin priv doc/*
docs: docs:
$(REBAR) doc $(REBAR_COMPILE) doc
ifeq ($(wildcard dialyzer/sqlite3.plt),) ifeq ($(wildcard dialyzer/sqlite3.plt),)
static: static:
$(REBAR) build_plt analyze $(REBAR_COMPILE) build_plt analyze
else else
static: static:
$(REBAR) analyze $(REBAR_COMPILE) analyze
endif endif

View File

@@ -437,15 +437,17 @@ value_to_sql(X) -> sqlite3_lib:value_to_sql(X).
%% @end %% @end
%% @hidden %% @hidden
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-type init_return() :: {'ok', tuple()} | {'ok', tuple(), integer()} | 'ignore' | {'stop', any()}.
-spec init([any()]) -> init_return(). % -type init_return() :: {'ok', tuple()} | {'ok', tuple(), integer()} | 'ignore' | {'stop', any()}.
-spec init([any()]) -> {'ok', #state{}} | {'stop', string()}.
init(Options) -> init(Options) ->
Dbase = proplists:get_value(db, Options), Dbase = proplists:get_value(db, Options),
{?MODULE, _, FileName} = code:get_object_code(?MODULE), {?MODULE, _, FileName} = code:get_object_code(?MODULE),
SearchDir = filename:join(filename:dirname(FileName), "../priv"), SearchDir = filename:join(filename:dirname(FileName), "../priv"),
case erl_ddll:load(SearchDir, atom_to_list(?DRIVER_NAME)) of case erl_ddll:load(SearchDir, atom_to_list(?DRIVER_NAME)) of
ok -> ok ->
Port = open_port({spawn, string:join([atom_to_list(?DRIVER_NAME), Dbase], " ")}, [binary]), Port = open_port({spawn, create_port_cmd(Dbase)}, [binary]),
{ok, #state{port = Port, ops = Options}}; {ok, #state{port = Port, ops = Options}};
{error, Error} -> {error, Error} ->
Msg = io_lib:format("Error loading ~p: ~p", [?DRIVER_NAME, erl_ddll:format_error(Error)]), Msg = io_lib:format("Error loading ~p: ~p", [?DRIVER_NAME, erl_ddll:format_error(Error)]),
@@ -463,10 +465,12 @@ init(Options) ->
%% @end %% @end
%% @hidden %% @hidden
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-type handle_call_return() :: {reply, any(), tuple()} | {reply, any(), tuple(), integer()} |
{noreply, tuple()} | {noreply, tuple(), integer()} | %% -type handle_call_return() :: {reply, any(), tuple()} | {reply, any(), tuple(), integer()} |
{stop, any(), any(), tuple()} | {stop, any(), tuple()}. %% {noreply, tuple()} | {noreply, tuple(), integer()} |
-spec handle_call(any(), pid(), tuple()) -> handle_call_return(). %% {stop, any(), any(), tuple()} | {stop, any(), tuple()}.
-spec handle_call(any(), pid(), #state{}) -> {'reply', any(), #state{}} | {'stop', 'normal', 'ok', #state{}}.
handle_call(close, _From, State) -> handle_call(close, _From, State) ->
Reply = ok, Reply = ok,
{stop, normal, Reply, State}; {stop, normal, Reply, State};
@@ -546,9 +550,11 @@ handle_call(_Request, _From, State) ->
%% @end %% @end
%% @hidden %% @hidden
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-type handle_cast_return() :: {noreply, tuple()} | {noreply, tuple(), integer()} |
{stop, any(), tuple()}. %% -type handle_cast_return() :: {noreply, tuple()} | {noreply, tuple(), integer()} |
-spec handle_cast(any(), tuple()) -> handle_cast_return(). %% {stop, any(), tuple()}.
-spec handle_cast(any(), #state{}) -> {'noreply', #state{}}.
handle_cast(_Msg, State) -> handle_cast(_Msg, State) ->
{noreply, State}. {noreply, State}.
@@ -560,7 +566,7 @@ handle_cast(_Msg, State) ->
%% @end %% @end
%% @hidden %% @hidden
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-spec handle_info(any(), tuple()) -> handle_cast_return(). -spec handle_info(any(), #state{}) -> {'noreply', #state{}}.
handle_info(_Info, State) -> handle_info(_Info, State) ->
{noreply, State}. {noreply, State}.
@@ -597,8 +603,8 @@ code_change(_OldVsn, State, _Extra) ->
-define(SQL_EXEC_COMMAND, 2). -define(SQL_EXEC_COMMAND, 2).
-define(SQL_CREATE_FUNCTION, 3). -define(SQL_CREATE_FUNCTION, 3).
create_cmd(Dbase) -> create_port_cmd(Dbase) ->
"sqlite3_port " ++ Dbase. atom_to_list(?DRIVER_NAME) ++ " " ++ Dbase.
wait_result(Port) -> wait_result(Port) ->
receive receive
@@ -663,17 +669,17 @@ build_primary_key_constraint(Tail, Acc) ->
{{primary_key, lists:reverse(Acc)}, Tail}. {{primary_key, lists:reverse(Acc)}, Tail}.
conflict_clause(["ON", "CONFLICT", ResolutionString | Tail]) -> %% conflict_clause(["ON", "CONFLICT", ResolutionString | Tail]) ->
Resolution = case ResolutionString of %% Resolution = case ResolutionString of
"ROLLBACK" -> rollback; %% "ROLLBACK" -> rollback;
"ABORT" -> abort; %% "ABORT" -> abort;
"FAIL" -> fail; %% "FAIL" -> fail;
"IGNORE" -> ignore; %% "IGNORE" -> ignore;
"REPLACE" -> replace %% "REPLACE" -> replace
end, %% end,
{{on_conflict, Resolution}, Tail}; %% {{on_conflict, Resolution}, Tail};
conflict_clause(NoOnConflictClause) -> %% conflict_clause(NoOnConflictClause) ->
{no_on_conflict, NoOnConflictClause}. %% {no_on_conflict, NoOnConflictClause}.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @type sql_value() = number() | 'null' | iodata(). %% @type sql_value() = number() | 'null' | iodata().