Skip to content

Commit 33b05b6

Browse files
authored
Merge pull request #259 from Julow/annotate-ignored-values
Add type annotation to ignored values
2 parents da9ee6e + 8774eba commit 33b05b6

14 files changed

+46
-37
lines changed

src/baselib/ocsigen_cache.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ end = struct
291291
| Some n when node == n -> ()
292292
| _ ->
293293
remove' node l;
294-
ignore (add_node node l))
294+
ignore (add_node node l : _ node option))
295295

296296
(* assertion: = None *)
297297
(* we must not change the physical address => use add_node *)
@@ -440,7 +440,7 @@ functor
440440

441441
let remove cache k =
442442
try
443-
let _v, node = H.find cache.table k in
443+
let (_v : A.value), node = H.find cache.table k in
444444
assert (
445445
match Dlist.list_of node with
446446
| None -> false
@@ -451,7 +451,7 @@ functor
451451
(* Add in a cache, under the hypothesis that the value is
452452
not already in the cache *)
453453
let add_no_remove cache k v =
454-
ignore (Dlist.add k cache.pointers);
454+
ignore (Dlist.add k cache.pointers : A.key option);
455455
match Dlist.newest cache.pointers with
456456
| None -> assert false
457457
| Some n -> H.add cache.table k (v, n)
@@ -465,7 +465,7 @@ functor
465465
cache.finder k >>= fun r ->
466466
(try
467467
(* it may have been added during cache.finder *)
468-
ignore (find_in_cache cache k)
468+
ignore (find_in_cache cache k : A.value)
469469
with Not_found -> add_no_remove cache k r);
470470
Lwt.return r
471471

src/baselib/ocsigen_lib.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ module Netstring_pcre = struct
130130

131131
let matched_group result n _ =
132132
if n < 0 || n >= Re.Group.nb_groups result then raise Not_found;
133-
ignore (Pcre.get_substring_ofs result n);
133+
ignore (Pcre.get_substring_ofs result n : int * int);
134134
Pcre.get_substring result n
135135

136136
let matched_string result _ =
137-
ignore (Pcre.get_substring_ofs result 0);
137+
ignore (Pcre.get_substring_ofs result 0 : int * int);
138138
Pcre.get_substring result 0
139139

140140
let global_replace pat templ s = Re.replace pat ~f:(tr_templ templ) s
@@ -427,7 +427,9 @@ module Url = struct
427427
https, host, port, uri_string, path, query, get_params
428428

429429
let prefix_and_path_of_t url =
430-
let https, host, port, _, path, _, _ = parse url in
430+
let https, host, port, (_ : uri), path, (_ : uri option), (_ : _ Lazy.t) =
431+
parse url
432+
in
431433
let https_str =
432434
match https with
433435
| None -> ""

src/baselib/ocsigen_stream.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ let substream delim s =
189189
then enlarge_stream stre >>= aux
190190
else
191191
try
192-
let p, _ = Ocsigen_lib.Netstring_pcre.search_forward rdelim s 0 in
192+
let p, (_ : 'groups) =
193+
Ocsigen_lib.Netstring_pcre.search_forward rdelim s 0
194+
in
193195
cont (String.sub s 0 p) (fun () ->
194196
empty
195197
(Some

src/baselib/tests/test_wrapping.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(* ocamlfind ocamlopt -linkpkg -package react -g -I ../ ../wrapping.cmxa test_wrapping.ml -o test_wrapping *)
2-
let _ = Printexc.record_backtrace true
2+
let () = Printexc.record_backtrace true
33

44
(*** simple wrap test ***)
55

src/extensions/accesscontrol.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ let parse_config parse_fun = function
280280
| Element ("then", [], ithen) :: q -> parse_fun ithen, q
281281
| _ -> Ocsigen_extensions.badconfig "Bad <then> branch in <if>"
282282
in
283-
let ielse, _sub =
283+
let ielse, (_sub : _ list) =
284284
match sub with
285285
| Element ("else", [], ielse) :: ([] as q) -> parse_fun ielse, q
286286
| [] -> parse_fun [], []

src/extensions/authbasic.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let register_basic_authentication_method, get_basic_authentication_method =
4242
fun config -> !fun_auth config )
4343

4444
(* Basic authentication with a predefined login/password (example) *)
45-
let _ =
45+
let () =
4646
let open Xml in
4747
register_basic_authentication_method @@ function
4848
| Element ("plain", [("login", login); ("password", password)], _) ->

src/extensions/deflatemod.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ let rec output oz f buf pos len =
8686
else if len = 0
8787
then next_cont oz f
8888
else
89-
let _, used_in, used_out =
89+
let (_ : bool), used_in, used_out =
9090
try
9191
Zlib.deflate oz.stream
9292
(Bytes.unsafe_of_string buf)
@@ -133,7 +133,7 @@ and next_cont oz stream =
133133
else
134134
(* no more input, deflates only what were left because output buffer
135135
* was full *)
136-
let finished, _, used_out =
136+
let finished, (_ : int), used_out =
137137
Zlib.deflate oz.stream oz.buf 0 0 oz.buf oz.pos oz.avail
138138
Zlib.Z_FINISH
139139
in

src/extensions/extendconfiguration.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ let check_regexp_list =
5959
try Hashtbl.find hashtbl r
6060
with Not_found -> (
6161
try
62-
ignore (Ocsigen_lib.Netstring_pcre.regexp r);
62+
ignore (Ocsigen_lib.Netstring_pcre.regexp r : Re.re);
6363
Hashtbl.add hashtbl r ()
6464
with _ -> raise (Bad_regexp r))
6565

src/extensions/staticmod.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ let correct_user_local_file =
5959
let regexp = Ocsigen_lib.Netstring_pcre.regexp "(/\\.\\./)|(/\\.\\.$)" in
6060
fun path ->
6161
try
62-
ignore (Ocsigen_lib.Netstring_pcre.search_forward regexp path 0);
62+
ignore
63+
(Ocsigen_lib.Netstring_pcre.search_forward regexp path 0
64+
: int * 'groups);
6365
false
6466
with Not_found -> true
6567

src/server/ocsigen_cohttp.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ let shutdown timeout =
204204
| Some f -> fun () -> Lwt_unix.sleep f
205205
| None -> fun () -> Lwt.return ()
206206
in
207-
ignore (Lwt.pick [process (); stop] >>= fun () -> exit 0)
207+
ignore (Lwt.pick [process (); stop] >>= fun () -> exit 0 : unit Lwt.t)
208208

209209
let service ?ssl ~address ~port ~connector () =
210210
let tls_own_key =

src/server/ocsigen_extensions.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -636,12 +636,12 @@ module Configuration = struct
636636
raise (Error_in_user_config_file ("No PCDATA allowed in tag " ^ in_tag))
637637

638638
let check_attribute_occurrence ~in_tag attributes = function
639-
| name, {attribute_obligatory = true; _} -> (
640-
try ignore (List.assoc name attributes)
641-
with Not_found ->
642-
raise
643-
(Error_in_user_config_file
644-
("Obligatory attribute " ^ name ^ " not in tag " ^ in_tag)))
639+
| name, {attribute_obligatory = true; _} ->
640+
if not (List.mem_assoc name attributes)
641+
then
642+
raise
643+
(Error_in_user_config_file
644+
("Obligatory attribute " ^ name ^ " not in tag " ^ in_tag))
645645
| _ -> ()
646646

647647
let check_element_occurrence ~in_tag elements = function

src/server/ocsigen_local_files.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ let check_dotdot =
100100
In URLs, .. have already been removed by the server,
101101
but the filename may come from somewhere else than URLs ... *)
102102
try
103-
ignore (Ocsigen_lib.Netstring_pcre.search_forward regexp filename 0);
103+
ignore
104+
(Ocsigen_lib.Netstring_pcre.search_forward regexp filename 0
105+
: int * 'groups);
104106
false
105107
with Not_found -> true
106108

src/server/ocsigen_multipart.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ let read_header ?downcase ?unfold ?strip s =
8686
in
8787
find_end_of_header s >>= fun (s, end_pos) ->
8888
let b = Ocsigen_stream.current_buffer s in
89-
let h, _ = scan_header ?downcase ?unfold ?strip b ~start_pos:0 ~end_pos in
89+
let h, (_ : int) =
90+
scan_header ?downcase ?unfold ?strip b ~start_pos:0 ~end_pos
91+
in
9092
Ocsigen_stream.skip s (Int64.of_int end_pos) >>= fun s -> Lwt.return (s, h)
9193

9294
let lf_re = S.regexp "[\n]"
@@ -239,7 +241,7 @@ let counter =
239241
!c
240242

241243
let field field content_disp =
242-
let _, res =
244+
let (_ : int), res =
243245
S.search_forward (S.regexp (field ^ "=.([^\"]*).;?")) content_disp 0
244246
in
245247
S.matched_group res 1 content_disp

src/server/ocsigen_server.ml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ let () = Random.self_init ()
2424

2525
(* Without the following line, it stops with "Broken Pipe" without
2626
raising an exception ... *)
27-
let _ = Sys.set_signal Sys.sigpipe Sys.Signal_ignore
27+
let () = Sys.set_signal Sys.sigpipe Sys.Signal_ignore
2828

2929
(* Exit gracefully on SIGINT so that profiling will work *)
30-
let _ = Sys.set_signal Sys.sigint (Sys.Signal_handle (fun _ -> exit 0))
30+
let () = Sys.set_signal Sys.sigint (Sys.Signal_handle (fun _ -> exit 0))
3131
let section = Lwt_log.Section.make "ocsigen:main"
3232

3333
(* Initialize exception handler for Lwt timeouts: *)
34-
let _ =
34+
let () =
3535
Lwt_timeout.set_exn_handler (fun e ->
3636
Lwt_log.ign_error ~section ~exn:e "Uncaught Exception after lwt timeout")
3737

@@ -97,7 +97,7 @@ let reload ?file () =
9797
with e -> Lwt_log.ign_error ~section (fst (errmsg e)));
9898
Lwt_log.ign_warning ~section "Config file reloaded"
9999

100-
let _ =
100+
let () =
101101
let f _s = function
102102
| ["reopen_logs"] ->
103103
Ocsigen_messages.open_files () >>= fun () ->
@@ -248,13 +248,13 @@ let main config =
248248
let commandpipe = Ocsigen_config.get_command_pipe () in
249249
let with_commandpipe =
250250
try
251-
ignore (Unix.stat commandpipe);
251+
ignore (Unix.stat commandpipe : Unix.stats);
252252
true
253253
with Unix.Unix_error _ -> (
254254
try
255255
let umask = Unix.umask 0 in
256256
Unix.mkfifo commandpipe 0o660;
257-
ignore (Unix.umask umask);
257+
ignore (Unix.umask umask : int);
258258
Lwt_log.ign_warning ~section "Command pipe created";
259259
true
260260
with e ->
@@ -270,9 +270,8 @@ let main config =
270270
raise
271271
(Ocsigen_config.Config_file_error
272272
"maxthreads should be greater than minthreads");
273-
ignore
274-
(Lwt_preemptive.init minthreads maxthreads (fun s ->
275-
Lwt_log.ign_error ~section s));
273+
Lwt_preemptive.init minthreads maxthreads (fun s ->
274+
Lwt_log.ign_error ~section s);
276275
(Lwt.async_exception_hook :=
277276
fun e ->
278277
(* replace the default "exit 2" behaviour *)
@@ -291,7 +290,7 @@ let main config =
291290
Unix.close devnull;
292291
Unix.close Unix.stdin);
293292
(* detach from the terminal *)
294-
if Ocsigen_config.get_daemon () then ignore (Unix.setsid ());
293+
if Ocsigen_config.get_daemon () then ignore (Unix.setsid () : int);
295294
Ocsigen_extensions.end_initialisation ();
296295
(if with_commandpipe
297296
then
@@ -325,7 +324,7 @@ let main config =
325324
Lwt.fail e)
326325
>>= f
327326
in
328-
ignore (f ()));
327+
ignore (f () : 'a Lwt.t));
329328
Lwt_main.run
330329
@@ Lwt.join
331330
(List.map
@@ -369,7 +368,7 @@ let main config =
369368
let f =
370369
Unix.openfile p [Unix.O_WRONLY; Unix.O_CREAT; Unix.O_TRUNC] 0o640
371370
in
372-
ignore (Unix.write_substring f spid 0 len);
371+
ignore (Unix.write_substring f spid 0 len : int);
373372
Unix.close f
374373
in
375374
(* set_passwd_if_needed sslinfo; *)

0 commit comments

Comments
 (0)