You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wo...@apache.org on 2020/01/13 18:01:39 UTC
[couchdb] 01/01: Eliminate multiple compiler warnings
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch compiler-warnings-1
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit d396a7c0eca4429c50a552d8f83a65527c8e2376
Author: Joan Touzet <jo...@atypical.net>
AuthorDate: Mon Jan 13 12:57:51 2020 -0500
Eliminate multiple compiler warnings
We now only support OTP 20+, with 19 at a stretch. erlang:now/0
was deprecated in OTP 18, so we can now suppress these warnings:
```
/home/joant/couchdb/src/dreyfus/src/dreyfus_index_updater.erl:62: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
/home/joant/couchdb/src/dreyfus/src/dreyfus_index_updater.erl:83: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
```
Also, some unused variables were removed:
```
/home/joant/couchdb/src/couch/src/couch_bt_engine.erl:997: Warning: variable 'NewSeq' is unused
/home/joant/couchdb/src/mem3/src/mem3_rep.erl:752: Warning: variable 'TMap' is unused
/home/joant/couchdb/src/dreyfus/src/dreyfus_httpd.erl:76: Warning: variable 'LimitValue' is unused
/home/joant/couchdb/src/dreyfus/src/dreyfus_util.erl:345: Warning: variable 'Db' is unused
```
PRs to follow in ets_lru, hyper, ibrowse to track the rest of `erlang:now/0`
deprecations.
---
src/couch/src/couch_bt_engine.erl | 2 +-
src/dreyfus/src/dreyfus_httpd.erl | 2 --
src/dreyfus/src/dreyfus_index_updater.erl | 4 ++--
src/dreyfus/src/dreyfus_util.erl | 2 +-
src/mem3/src/mem3_rep.erl | 1 -
5 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/couch/src/couch_bt_engine.erl b/src/couch/src/couch_bt_engine.erl
index b659719..48e751a 100644
--- a/src/couch/src/couch_bt_engine.erl
+++ b/src/couch/src/couch_bt_engine.erl
@@ -994,7 +994,7 @@ upgrade_purge_info(Fd, Header) ->
_ ->
{ok, PurgedIdsRevs} = couch_file:pread_term(Fd, Ptr),
- {Infos, NewSeq} = lists:foldl(fun({Id, Revs}, {InfoAcc, PSeq}) ->
+ {Infos, _} = lists:foldl(fun({Id, Revs}, {InfoAcc, PSeq}) ->
Info = {PSeq, couch_uuids:random(), Id, Revs},
{[Info | InfoAcc], PSeq + 1}
end, {[], PurgeSeq}, PurgedIdsRevs),
diff --git a/src/dreyfus/src/dreyfus_httpd.erl b/src/dreyfus/src/dreyfus_httpd.erl
index 5c9db80..e985163 100644
--- a/src/dreyfus/src/dreyfus_httpd.erl
+++ b/src/dreyfus/src/dreyfus_httpd.erl
@@ -73,8 +73,6 @@ handle_search_req(#httpd{method=Method, path_parts=[_, _, _, _, IndexName]}=Req
end;
_ ->
% ensure limit in group query >0
- LimitValue = parse_positive_int_param("limit", QueryArgs#index_query_args.limit,
- "max_limit", "200"),
UseNewApi = Grouping#grouping.new_api,
case dreyfus_fabric_group1:go(DbName, DDoc, IndexName, QueryArgs) of
{ok, []} ->
diff --git a/src/dreyfus/src/dreyfus_index_updater.erl b/src/dreyfus/src/dreyfus_index_updater.erl
index 3720cb6..87edef0 100644
--- a/src/dreyfus/src/dreyfus_index_updater.erl
+++ b/src/dreyfus/src/dreyfus_index_updater.erl
@@ -59,7 +59,7 @@ update(IndexPid, Index) ->
true = proc_prompt(Proc, [<<"add_fun">>, Index#index.def]),
EnumFun = fun ?MODULE:load_docs/2,
[Changes] = couch_task_status:get([changes_done]),
- Acc0 = {Changes, IndexPid, Db, Proc, TotalChanges, now(), ExcludeIdRevs},
+ Acc0 = {Changes, IndexPid, Db, Proc, TotalChanges, erlang:timestamp(), ExcludeIdRevs},
{ok, _} = couch_db:fold_changes(Db, CurSeq, EnumFun, Acc0, []),
ok = clouseau_rpc:commit(IndexPid, NewCurSeq)
after
@@ -80,7 +80,7 @@ load_docs(FDI, {I, IndexPid, Db, Proc, Total, LastCommitTime, ExcludeIdRevs}=Acc
false -> update_or_delete_index(IndexPid, Db, DI, Proc)
end,
%% Force a commit every minute
- case timer:now_diff(Now = now(), LastCommitTime) >= 60000000 of
+ case timer:now_diff(Now = erlang:timestamp(), LastCommitTime) >= 60000000 of
true ->
ok = clouseau_rpc:commit(IndexPid, Seq),
{ok, {I+1, IndexPid, Db, Proc, Total, Now, ExcludeIdRevs}};
diff --git a/src/dreyfus/src/dreyfus_util.erl b/src/dreyfus/src/dreyfus_util.erl
index 6832299..0a83e87 100644
--- a/src/dreyfus/src/dreyfus_util.erl
+++ b/src/dreyfus/src/dreyfus_util.erl
@@ -342,7 +342,7 @@ get_signature_from_idxdir(IdxDir) ->
false -> undefined
end.
-get_local_purge_doc_body(Db, LocalDocId, PurgeSeq, Index) ->
+get_local_purge_doc_body(_, LocalDocId, PurgeSeq, Index) ->
#index{
name = IdxName,
ddoc_id = DDocId,
diff --git a/src/mem3/src/mem3_rep.erl b/src/mem3/src/mem3_rep.erl
index 4b75846..7fa0fc0 100644
--- a/src/mem3/src/mem3_rep.erl
+++ b/src/mem3/src/mem3_rep.erl
@@ -749,7 +749,6 @@ targets_map(#shard{name = <<"shards/", _/binary>> = SrcName} = Src,
Shards0 = mem3:shards(mem3:dbname(SrcName)),
Shards1 = [S || S <- Shards0, not shard_eq(S, Src)],
Shards2 = [S || S <- Shards1, check_overlap(SrcRange, TgtNode, S)],
- TMap = maps:from_list([{R, S} || #shard{range = R} = S <- Shards2]),
case [{R, S} || #shard{range = R} = S <- Shards2] of
[] ->
% If target map is empty, create a target map with just