Parcourir la source

Code clean-up: fix some warning of the compiler

 + Use or mark as unsed some variable (fixes warning 32). Some remains
 though, especially in Rc module and atdgen-generated code.
 + Remove spy1_rc from tools, since it needs to be be independant from
 Rc module. Add corresponding code in rc module.
Leo il y a 8 ans
Parent
commit
d042fc9401
7 fichiers modifiés avec 15 ajouts et 11 suppressions
  1. 1 1
      src/command_def.ml
  2. 4 1
      src/lock.ml
  3. 8 4
      src/rc.ml
  4. 1 0
      src/rc.mli
  5. 1 1
      src/test/unify_t.ml
  6. 0 3
      src/tools.ml
  7. 0 1
      src/tools.mli

+ 1 - 1
src/command_def.ml

@@ -166,7 +166,7 @@ let reset_all =
       empty
       +> shared_params
     )
-    (fun { rc } () ->
+    (fun _ () ->
        Tmp_file.reset_all ()
     )
 ;;

+ 4 - 1
src/lock.ml

@@ -51,7 +51,10 @@ let lock_name = "/tmp/.ocl.lock";;
 (* Create lock file *)
 let lock () =
   try Out_channel.write_all lock_name ~data:"OcLaunch is running and did not finish."
-  with Sys_error msg -> Messages.debug "Couldn't write in lock file."
+  with Sys_error msg ->
+    Messages.debug "Couldn't write in lock file.";
+    Messages.debug "Due to";
+    Messages.debug msg
 ;;
 
 (* To know if we are locked, return None if there is no locker,  *)

+ 8 - 4
src/rc.ml

@@ -114,7 +114,7 @@ let create_basic name =
   |> Messages.warning;
   Messages.tips welcome_msg;
   Licencing.print ~cecill:false;
-  Out_channel.write_all name basic_template
+  Out_channel.write_all name ~data:basic_template
 ;;
 
 let rec get_basic rc_name =
@@ -132,7 +132,7 @@ let rec get_basic rc_name =
 ;;
 
 (* From objects to types *)
-let tag_of_object tag  = failwith "Not implemented";;
+let tag_of_object tag = failwith "Not implemented";;
 let setting_of_object setting = failwith "Not implemented";;
 let entry_of_object entry =
   {
@@ -194,6 +194,7 @@ type t = <
   filter_map_entries : f:(int -> entry -> entry option) -> t;
   filter_map_settings : f:(setting -> setting option) -> t;
   get_name : string;
+  to_string : string;
   map_common_tags : f:(tag -> tag) -> t;
   map_entries : f:(int -> entry -> entry) -> t;
   map_settings : f:(setting -> setting) -> t;
@@ -268,6 +269,9 @@ let init ?(rc=(!Const.rc_file)) () =
     method remove_entry n =
       self#filter_map_entries ~f:(fun i e -> if i=n then None else Some e)
 
+    (* Get a string representing rc file, on debugging purpose *)
+    method to_string = failwith "Not implemented"
+
     (* Name of rc file when written to disk *)
     val name = Lazy.force rc
     method get_name = name
@@ -283,7 +287,7 @@ let init ?(rc=(!Const.rc_file)) () =
       in
       let data = String.concat [ rc_header ; "\n\n\n" ; body ; "\n" ] in
       Out_channel.write_all name ~data
-    (** Write rc file at instantiation. Entries should be changed in group, to
+    (* Write rc file at instantiation. Entries should be changed in group, to
      * avoid multiple writing. Although, there is some cache done by out_channels,
      * this is not very dangerous *)
     initializer self#write
@@ -307,7 +311,7 @@ let empty_entry () =
 let import ~from ~to_file =
   let imported_rc : t = init ~rc:to_file () in
   let to_import : File_com.t = File_com.init_rc ~rc:from () in
-  to_import.progs |> List.map ~f:(new entry)
+  to_import.progs |> List.map ~f:(fun command -> new entry command)
   |> imported_rc#change_entries
   |> fun rc -> rc#write;
   Messages.ok "Import successful!";

+ 1 - 0
src/rc.mli

@@ -85,6 +85,7 @@ type t = <
   map_entries : f:(int -> entry -> entry) -> t;
   map_settings : f:(setting -> setting) -> t;
   get_name : string;
+  to_string : string;
   read_common_tags : f:(tag -> unit) -> unit;
   read_settings : f:(setting -> unit) -> unit;
   remove_entry : int -> t;

+ 1 - 1
src/test/unify_t.ml

@@ -56,7 +56,7 @@ let big_unique length = (* Long list of unique elements *)
 let big_same length = (* Long list of unique elements *)
   let message = "all the same element" in
   let same_element = "cmd1" in
-  let test_case = List.init ~f:(fun i -> same_element) length in
+  let test_case = List.init ~f:(fun _ -> same_element) length in
   ( test_case, [ same_element ], message )
 ;;
 let big_periodic length = (* Long list of unique elements *)

+ 0 - 3
src/tools.ml

@@ -83,9 +83,6 @@ let spy1_log (log : (string * int) list) =
   |> printing;
   log
 ;;
-let spy1_rc rc =
-  failwith "Not implemented"
-;;
 
 (* It's simpler to define strings (for instance in the test) and convert it to
  * entry then *)

+ 0 - 1
src/tools.mli

@@ -43,5 +43,4 @@ val spy1_string : string -> string
 val spy1_float : float -> float
 val spy1_list : f:('a -> string)-> 'a list -> 'a list
 val spy1_log : (string * int) list -> (string * int) list
-val spy1_rc : 'a -> 'a
 val to_entry : string -> Rc.entry