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_COMPILE=$(REBAR) get-deps compile
all: compile
compile:
$(REBAR) get-deps compile
$(REBAR_COMPILE)
test: all
$(REBAR) skip_deps=true eunit
test:
$(REBAR_COMPILE) skip_deps=true eunit
clean:
-rm -rf deps ebin priv doc/*
docs:
$(REBAR) doc
$(REBAR_COMPILE) doc
ifeq ($(wildcard dialyzer/sqlite3.plt),)
static:
$(REBAR) build_plt analyze
$(REBAR_COMPILE) build_plt analyze
else
static:
$(REBAR) analyze
$(REBAR_COMPILE) analyze
endif

View File

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