From 56bfbe484d0c5b97d7b1f08677def3cc388787be Mon Sep 17 00:00:00 2001 From: Alexey Romanov Date: Thu, 14 Oct 2010 12:40:47 +0400 Subject: [PATCH] Got rid of Dialyzer warnings --- Makefile | 13 ++++++------ src/sqlite3.erl | 54 +++++++++++++++++++++++++++---------------------- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index dcdce97..ea822b3 100644 --- a/Makefile +++ b/Makefile @@ -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 \ No newline at end of file diff --git a/src/sqlite3.erl b/src/sqlite3.erl index 83c8d1e..8aaf012 100644 --- a/src/sqlite3.erl +++ b/src/sqlite3.erl @@ -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().