From e9d877a7a4f27649dba076b2410d79332634c6bf Mon Sep 17 00:00:00 2001 From: Andreas Pauley Date: Sat, 23 Nov 2013 17:48:33 +0200 Subject: [PATCH 1/8] Turn warnings into errors --- rebar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index 9cbcba9..4485a22 100644 --- a/rebar.config +++ b/rebar.config @@ -1,3 +1,3 @@ -{erl_opts, [debug_info, warn_unused_vars, nowarn_shadow_vars, warn_unused_import]}. +{erl_opts, [debug_info, warnings_as_errors, warn_unused_vars, nowarn_shadow_vars, warn_unused_import]}. {xref_checks, [undefined_function_calls, deprecated_function_calls]}. {eunit_opts, [verbose]}. From 08e6a4c165cefe014cf6d9109ae8bb6c7186c011 Mon Sep 17 00:00:00 2001 From: Andreas Pauley Date: Sat, 23 Nov 2013 17:50:28 +0200 Subject: [PATCH 2/8] Fix dialyzer warnings due to -Wunmatched_returns option. Below are the warnings that were fixed by this commit. [git: master]Iris:ibrowse andreas$ make dialyzer Building local plt at .dialyzer_plt dialyzer --output_plt .dialyzer_plt --build_plt \ --apps erts kernel stdlib ssl crypto public_key asn1 compiler hipe edoc gs syntax_tools inets xmerl runtime_tools mnesia Compiling some key modules to native code... done in 0m19.73s Creating PLT .dialyzer_plt ... done in 1m40.98s done (passed successfully) dialyzer --fullpath --plt .dialyzer_plt -Wrace_conditions -Wunmatched_returns -Werror_handling -r ./ebin Checking whether the PLT .dialyzer_plt is up-to-date... yes Proceeding with analysis... src/ibrowse_http_client.erl:197: Expression produces a value of type 'ok' | {'error',_}, but this value is unmatched src/ibrowse_http_client.erl:298: Expression produces a value of type 'ok' | {'error',_}, but this value is unmatched src/ibrowse_http_client.erl:322: Expression produces a value of type 'ok' | {'error',_}, but this value is unmatched src/ibrowse_http_client.erl:335: Expression produces a value of type 'ok' | {'error',_}, but this value is unmatched src/ibrowse_http_client.erl:352: Expression produces a value of type 'ok' | {'error',_}, but this value is unmatched src/ibrowse_http_client.erl:582: Expression produces a value of type 'ok' | {'error',_}, but this value is unmatched src/ibrowse_http_client.erl:587: Expression produces a value of type 'ok' | {'error',_}, but this value is unmatched src/ibrowse_http_client.erl:590: Expression produces a value of type 'ok' | {'error',_}, but this value is unmatched src/ibrowse_http_client.erl:706: Expression produces a value of type 'ok' | {'error',_}, but this value is unmatched src/ibrowse_http_client.erl:789: Expression produces a value of type 'ok' | {'error',_}, but this value is unmatched src/ibrowse_http_client.erl:797: Expression produces a value of type 'ok' | {'error',_}, but this value is unmatched src/ibrowse_http_client.erl:1402: Expression produces a value of type 'ok' | {'error',_}, but this value is unmatched src/ibrowse_http_client.erl:1859: Expression produces a value of type 'ok' | integer(), but this value is unmatched src/ibrowse_socks5.erl:25: Expression produces a value of type {'ok',<<_:16>>}, but this value is unmatched done in 0m8.07s done (warnings were emitted) make: *** [dialyzer] Error 2 --- src/ibrowse_http_client.erl | 24 ++++++++++++------------ src/ibrowse_socks5.erl | 1 + 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/ibrowse_http_client.erl b/src/ibrowse_http_client.erl index fd2c25d..84d3015 100644 --- a/src/ibrowse_http_client.erl +++ b/src/ibrowse_http_client.erl @@ -194,7 +194,7 @@ handle_info({ssl, _Sock, Data}, State) -> handle_info({stream_next, Req_id}, #state{socket = Socket, cur_req = #request{req_id = Req_id}} = State) -> - do_setopts(Socket, [{active, once}], State), + ok = do_setopts(Socket, [{active, once}], State), {noreply, set_inac_timer(State)}; handle_info({stream_next, _Req_id}, State) -> @@ -297,7 +297,7 @@ handle_sock_data(Data, #state{status = get_header}=State) -> #state{socket = Socket, status = Status, cur_req = CurReq} = State_1 -> case {Status, CurReq} of {get_header, #request{caller_controls_socket = true}} -> - do_setopts(Socket, [{active, once}], State_1); + ok = do_setopts(Socket, [{active, once}], State_1); _ -> active_once(State_1) end, @@ -336,7 +336,7 @@ handle_sock_data(Data, #state{status = get_body, true -> active_once(State_1); false when Ccs == true -> - do_setopts(Socket, [{active, once}], State); + ok = do_setopts(Socket, [{active, once}], State); false -> active_once(State_1) end, @@ -579,16 +579,15 @@ do_send_body1(Source, Resp, State, TE) -> {ok, Data} when Data == []; Data == <<>> -> do_send_body({Source}, State, TE); {ok, Data} -> - do_send(maybe_chunked_encode(Data, TE), State), + ok = do_send(maybe_chunked_encode(Data, TE), State), do_send_body({Source}, State, TE); {ok, Data, New_source_state} when Data == []; Data == <<>> -> do_send_body({Source, New_source_state}, State, TE); {ok, Data, New_source_state} -> - do_send(maybe_chunked_encode(Data, TE), State), + ok = do_send(maybe_chunked_encode(Data, TE), State), do_send_body({Source, New_source_state}, State, TE); eof when TE == true -> - do_send(<<"0\r\n\r\n">>, State), - ok; + ok = do_send(<<"0\r\n\r\n">>, State); eof -> ok; Err -> @@ -612,7 +611,7 @@ do_close(#state{socket = Sock, is_ssl = false}) -> catch gen_tcp:close(Sock). active_once(#state{cur_req = #request{caller_controls_socket = true}}) -> ok; active_once(#state{socket = Socket} = State) -> - do_setopts(Socket, [{active, once}], State). + ok = do_setopts(Socket, [{active, once}], State). do_setopts(_Sock, [], _) -> ok; do_setopts(Sock, Opts, #state{is_ssl = true, @@ -703,7 +702,7 @@ send_req_1(From, case do_send_body(Body_1, State_1, TE) of ok -> trace_request_body(Body_1), - active_once(State_1), + ok = active_once(State_1), State_1_1 = inc_pipeline_counter(State_1), State_2 = State_1_1#state{status = get_header, cur_req = NewReq, @@ -786,7 +785,7 @@ send_req_1(From, AbsPath, RelPath, Body, Options, State_1, ReqId), trace_request(Req), - do_setopts(Socket, Caller_socket_options, State_1), + ok = do_setopts(Socket, Caller_socket_options, State_1), TE = is_chunked_encoding_specified(Options), case do_send(Req, State_1) of ok -> @@ -1401,7 +1400,7 @@ set_cur_request(#state{reqs = Reqs, socket = Socket} = State) -> {value, #request{caller_controls_socket = Ccs} = NextReq} -> case Ccs of true -> - do_setopts(Socket, [{active, once}], State); + ok = do_setopts(Socket, [{active, once}], State); _ -> ok end, @@ -1858,7 +1857,8 @@ dec_pipeline_counter(#state{cur_pipeline_size = Pipe_sz, lb_ets_tid = Tid} = State) -> try update_counter(Tid, self(), {2,-1,0,0}), - update_counter(Tid, self(), {3,-1,0,0}) + update_counter(Tid, self(), {3,-1,0,0}), + ok catch _:_ -> ok diff --git a/src/ibrowse_socks5.erl b/src/ibrowse_socks5.erl index 10d88c1..e6d8913 100644 --- a/src/ibrowse_socks5.erl +++ b/src/ibrowse_socks5.erl @@ -22,6 +22,7 @@ connect(Host, Port, Options) -> {ok, Socket} = gen_tcp:connect(Socks5Host, Socks5Port, [binary, {packet, 0}, {keepalive, true}, {active, false}]), + {ok, _Bin} = case proplists:get_value(socks5_user, Options, undefined) of undefined -> ok = gen_tcp:send(Socket, <>), From 0d4ad9bcc4d61f623414de1bfff2ab1a27ba835d Mon Sep 17 00:00:00 2001 From: Andreas Pauley Date: Sat, 23 Nov 2013 17:58:54 +0200 Subject: [PATCH 3/8] Run dialyzer by default just after a compile --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index afa47df..ad21840 100644 --- a/Makefile +++ b/Makefile @@ -3,13 +3,15 @@ IBROWSE_VSN = $(shell sed -n 's/.*{vsn,.*"\(.*\)"}.*/\1/p' src/ibrowse.app.src) DIALYZER_PLT=$(CURDIR)/.dialyzer_plt DIALYZER_APPS=erts kernel stdlib ssl crypto public_key asn1 compiler hipe edoc gs syntax_tools inets xmerl runtime_tools mnesia -all: +all: compile dialyzer + +compile: ./rebar compile clean: ./rebar clean -install: all +install: compile mkdir -p $(DESTDIR)/lib/ibrowse-$(IBROWSE_VSN)/ cp -r ebin $(DESTDIR)/lib/ibrowse-$(IBROWSE_VSN)/ From 04137160063d5c1363adce73d9938773caf426a1 Mon Sep 17 00:00:00 2001 From: Andreas Pauley Date: Sat, 23 Nov 2013 18:16:06 +0200 Subject: [PATCH 4/8] Add R16B to travis versions --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index bf3bbfb..ecb8d6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: erlang otp_release: + - R16B - R14B04 - R14B03 - R14B02 From 70a44c5be0338c3894c31ac3777748a7e9dce488 Mon Sep 17 00:00:00 2001 From: Andreas Pauley Date: Sat, 23 Nov 2013 18:31:49 +0200 Subject: [PATCH 5/8] Remove OTP versions from that seem not to be supported by travis anymore --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ecb8d6e..f4a7843 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,4 @@ otp_release: - R14B04 - R14B03 - R14B02 - - R14A - - R13B04 - - R13B03 script: "make test" From 68ee17ff8747579884b76b53f0eba9935a41a227 Mon Sep 17 00:00:00 2001 From: Andreas Pauley Date: Sat, 23 Nov 2013 18:33:07 +0200 Subject: [PATCH 6/8] Generating a dialyzer PLT on travis with R14 takes more than 10 minutes, and then travis kills the build --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index f4a7843..4b98f46 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,4 @@ language: erlang otp_release: - R16B - - R14B04 - - R14B03 - - R14B02 script: "make test" From 394697226e915ef3dc4a97f1c3346ee4d73113d6 Mon Sep 17 00:00:00 2001 From: Andreas Pauley Date: Sat, 23 Nov 2013 18:34:03 +0200 Subject: [PATCH 7/8] Add R15B to travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4b98f46..56a13c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: erlang otp_release: - R16B + - R15B script: "make test" From a11f98756c7f06cb109ab6edab270d24e4b8a70c Mon Sep 17 00:00:00 2001 From: Andreas Pauley Date: Sat, 23 Nov 2013 18:52:26 +0200 Subject: [PATCH 8/8] Remove R15B from travis, it also takes more than 10 minutes to generate a dialyzer PLT file --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 56a13c5..4b98f46 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: erlang otp_release: - R16B - - R15B script: "make test"