Consistently use 'Result' rather than a mix of 'Rc' and 'Result'

This commit is contained in:
Gregory Burd 2011-12-01 16:24:53 -05:00
parent b70d9b8afa
commit 5e0c4ff384

View file

@ -195,8 +195,8 @@ open(Name, Type, Opts) ->
end, end,
Flags = process_flags(lists:umerge(Opts, [auto_commit, threaded])), Flags = process_flags(lists:umerge(Opts, [auto_commit, threaded])),
Cmd = <<Flags:32/native, TypeCode:8/signed-native, (list_to_binary(Name))/bytes, 0:8/native>>, Cmd = <<Flags:32/native, TypeCode:8/signed-native, (list_to_binary(Name))/bytes, 0:8/native>>,
<<Rc:32/signed-native>> = erlang:port_control(get_port(), ?CMD_OPEN_DB, Cmd), <<Result:32/signed-native>> = erlang:port_control(get_port(), ?CMD_OPEN_DB, Cmd),
recv_val(Rc). recv_val(Result).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
@ -257,8 +257,8 @@ close(Db) ->
close(Db, Opts) -> close(Db, Opts) ->
Flags = process_flags(Opts), Flags = process_flags(Opts),
Cmd = <<Db:32/signed-native, Flags:32/native>>, Cmd = <<Db:32/signed-native, Flags:32/native>>,
<<Rc:32/signed-native>> = erlang:port_control(get_port(), ?CMD_CLOSE_DB, Cmd), <<Result:32/signed-native>> = erlang:port_control(get_port(), ?CMD_CLOSE_DB, Cmd),
recv_ok(Rc). recv_ok(Result).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @doc %% @doc
@ -365,8 +365,8 @@ txn_begin() ->
txn_begin(Opts) -> txn_begin(Opts) ->
Flags = process_flags(Opts), Flags = process_flags(Opts),
Cmd = <<Flags:32/native>>, Cmd = <<Flags:32/native>>,
<<Rc:32/signed-native>> = erlang:port_control(get_port(), ?CMD_TXN_BEGIN, Cmd), <<Result:32/signed-native>> = erlang:port_control(get_port(), ?CMD_TXN_BEGIN, Cmd),
recv_ok(Rc). recv_ok(Result).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @doc %% @doc
@ -428,8 +428,8 @@ txn_commit() ->
txn_commit(Opts) -> txn_commit(Opts) ->
Flags = process_flags(Opts), Flags = process_flags(Opts),
Cmd = <<Flags:32/native>>, Cmd = <<Flags:32/native>>,
<<Rc:32/signed-native>> = erlang:port_control(get_port(), ?CMD_TXN_COMMIT, Cmd), <<Result:32/signed-native>> = erlang:port_control(get_port(), ?CMD_TXN_COMMIT, Cmd),
recv_ok(Rc). recv_ok(Result).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @doc %% @doc
@ -1174,8 +1174,8 @@ truncate() ->
truncate(Db) -> truncate(Db) ->
Cmd = <<Db:32/signed-native>>, Cmd = <<Db:32/signed-native>>,
<<Rc:32/signed-native>> = erlang:port_control(get_port(), ?CMD_TRUNCATE, Cmd), <<Result:32/signed-native>> = erlang:port_control(get_port(), ?CMD_TRUNCATE, Cmd),
recv_ok(Rc). recv_ok(Result).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @doc %% @doc
@ -1195,8 +1195,8 @@ truncate(Db) ->
cursor_open(Db) -> cursor_open(Db) ->
Cmd = <<Db:32/signed-native, 0:32/native>>, Cmd = <<Db:32/signed-native, 0:32/native>>,
<<Rc:32/signed-native>> = erlang:port_control(get_port(), ?CMD_CURSOR_OPEN, Cmd), <<Result:32/signed-native>> = erlang:port_control(get_port(), ?CMD_CURSOR_OPEN, Cmd),
recv_ok(Rc). recv_ok(Result).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @doc %% @doc
@ -1438,8 +1438,8 @@ cursor_count() ->
-spec cursor_close() -> ok | db_error(). -spec cursor_close() -> ok | db_error().
cursor_close() -> cursor_close() ->
<<Rc:32/signed-native>> = erlang:port_control(get_port(), ?CMD_CURSOR_CLOSE, <<>>), <<Result:32/signed-native>> = erlang:port_control(get_port(), ?CMD_CURSOR_CLOSE, <<>>),
recv_ok(Rc). recv_ok(Result).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @doc %% @doc
@ -1465,8 +1465,8 @@ cursor_close() ->
delete_database(Filename) -> delete_database(Filename) ->
Cmd = <<(list_to_binary(Filename))/binary, 0:8>>, Cmd = <<(list_to_binary(Filename))/binary, 0:8>>,
<<Rc:32/signed-native>> = erlang:port_control(get_port(), ?CMD_REMOVE_DB, Cmd), <<Result:32/signed-native>> = erlang:port_control(get_port(), ?CMD_REMOVE_DB, Cmd),
recv_ok(Rc). recv_ok(Result).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @doc %% @doc
@ -1654,8 +1654,8 @@ get_txn_timeout() ->
stat(Db, Opts) -> stat(Db, Opts) ->
Flags = process_flags(Opts), Flags = process_flags(Opts),
Cmd = <<Db:32/signed-native, Flags:32/native>>, Cmd = <<Db:32/signed-native, Flags:32/native>>,
<<Rc:32/signed-native>> = erlang:port_control(get_port(), ?CMD_DB_STAT, Cmd), <<Result:32/signed-native>> = erlang:port_control(get_port(), ?CMD_DB_STAT, Cmd),
recv_val(Rc). recv_val(Result).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @doc %% @doc
@ -1759,8 +1759,8 @@ stat_print(Db) ->
lock_stat(Opts) -> lock_stat(Opts) ->
Flags = process_flags(Opts), Flags = process_flags(Opts),
Cmd = <<Flags:32/native>>, Cmd = <<Flags:32/native>>,
<<Rc:32/signed-native>> = erlang:port_control(get_port(), ?CMD_LOCK_STAT, Cmd), <<Result:32/signed-native>> = erlang:port_control(get_port(), ?CMD_LOCK_STAT, Cmd),
recv_val(Rc). recv_val(Result).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @doc %% @doc
@ -1855,8 +1855,8 @@ lock_stat_print() ->
log_stat(Opts) -> log_stat(Opts) ->
Flags = process_flags(Opts), Flags = process_flags(Opts),
Cmd = <<Flags:32/native>>, Cmd = <<Flags:32/native>>,
<<Rc:32/signed-native>> = erlang:port_control(get_port(), ?CMD_LOG_STAT, Cmd), <<Result:32/signed-native>> = erlang:port_control(get_port(), ?CMD_LOG_STAT, Cmd),
recv_val(Rc). recv_val(Result).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @doc %% @doc
@ -2036,8 +2036,8 @@ memp_stat_print() ->
mutex_stat(Opts) -> mutex_stat(Opts) ->
Flags = process_flags(Opts), Flags = process_flags(Opts),
Cmd = <<Flags:32/native>>, Cmd = <<Flags:32/native>>,
<<Rc:32/signed-native>> = erlang:port_control(get_port(), ?CMD_MUTEX_STAT, Cmd), <<Result:32/signed-native>> = erlang:port_control(get_port(), ?CMD_MUTEX_STAT, Cmd),
recv_val(Rc). recv_val(Result).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @doc %% @doc
@ -2252,8 +2252,8 @@ env_stat_print() ->
{ok, [{atom(), number()}]} | db_error(). {ok, [{atom(), number()}]} | db_error().
driver_info() -> driver_info() ->
<<Rc:32/signed-native>> = erlang:port_control(get_port(), ?CMD_DRIVER_INFO, <<>>), <<Result:32/signed-native>> = erlang:port_control(get_port(), ?CMD_DRIVER_INFO, <<>>),
recv_val(Rc). recv_val(Result).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
@ -2444,15 +2444,15 @@ do_put(Action, Db, Key, Value, Opts) ->
Flags = process_flags(Opts), Flags = process_flags(Opts),
Cmd = <<Db:32/signed-native, Flags:32/native, KeyLen:32/native, KeyBin/bytes, Cmd = <<Db:32/signed-native, Flags:32/native, KeyLen:32/native, KeyBin/bytes,
FinalValBinLen:32/native, FinalValBin/bytes>>, FinalValBinLen:32/native, FinalValBin/bytes>>,
<<Rc:32/signed-native>> = erlang:port_control(get_port(), Action, Cmd), <<Result:32/signed-native>> = erlang:port_control(get_port(), Action, Cmd),
recv_ok(Rc). recv_ok(Result).
%% %%
%% Move the cursor in a given direction. Invoked by cursor_next/prev/current. %% Move the cursor in a given direction. Invoked by cursor_next/prev/current.
%% %%
do_cursor_move(Direction) -> do_cursor_move(Direction) ->
<<Rc:32/signed-native>> = erlang:port_control(get_port(), Direction, <<>>), <<Result:32/signed-native>> = erlang:port_control(get_port(), Direction, <<>>),
case decode_rc(Rc) of case decode_rc(Result) of
ok -> ok ->
receive receive
{ok, KeyBin, ValueBin} -> {ok, KeyBin, ValueBin} ->