Skip to content

Commit

Permalink
Merge pull request #5257 from psafont/reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
psafont authored Dec 19, 2023
2 parents d5f5b12 + 26a0f67 commit 4c167f7
Show file tree
Hide file tree
Showing 102 changed files with 614 additions and 665 deletions.
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ b020cf35a1f2c274f95a4118d4596043cba6113f
637d2b703e867bfdb018f228902f18ba26ff20bf
ff39018fd6d91985f9c893a56928771dfe9fa48d
cbb9edb17dfd122c591beb14d1275acc39492335
d6ab15362548b8fe270bd14d5153b8d94e1b15c0

# ocp-indent
d018d26d6acd4707a23288b327b49e44f732725e
Expand Down
27 changes: 14 additions & 13 deletions ocaml/database/db_cache_impl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ let spawn_db_flush_threads () =
( if dbconn.Parse_db_conf.mode <> Parse_db_conf.No_limit then
"Write limited with coallesce_time="
^ string_of_float coallesce_time
else
""
else
""
) ;
(* check if we are currently in a coallescing_period *)
let in_coallescing_period () =
Expand All @@ -417,17 +417,18 @@ let spawn_db_flush_threads () =
exceeded.
*)
( if
!Db_connections.exit_on_next_flush
(* always flush straight away; this request is urgent *)
|| (* otherwise, we only write if (i) "coalesscing period has come to an end"; and (ii) "write limiting requirements are met": *)
(not (in_coallescing_period ()))
(* see (i) above *)
&& (!my_writes_this_period
< dbconn.Parse_db_conf.write_limit_write_cycles
|| dbconn.Parse_db_conf.mode = Parse_db_conf.No_limit
(* (ii) above *)
)
then (* debug "[%s] considering flush" db_path; *)
!Db_connections.exit_on_next_flush
(* always flush straight away; this request is urgent *)
|| (* otherwise, we only write if (i) "coalesscing period has come to an end"; and (ii) "write limiting requirements are met": *)
(not (in_coallescing_period ()))
(* see (i) above *)
&& (!my_writes_this_period
< dbconn.Parse_db_conf.write_limit_write_cycles
|| dbconn.Parse_db_conf.mode
= Parse_db_conf.No_limit
(* (ii) above *)
)
then (* debug "[%s] considering flush" db_path; *)
let was_anything_flushed =
Xapi_stdext_threads.Threadext.Mutex.execute
Db_lock.global_flush_mutex (fun () ->
Expand Down
4 changes: 2 additions & 2 deletions ocaml/database/master_connection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ let do_db_xml_rpc_persistent_with_reopen ~host:_ ~path (req : string) :
time_sofar
( if !connection_timeout < 0. then
"never timeout"
else
Printf.sprintf "timeout after '%f'" !connection_timeout
else
Printf.sprintf "timeout after '%f'" !connection_timeout
) ;
if time_sofar > !connection_timeout && !connection_timeout >= 0. then
if !restart_on_connection_timeout then (
Expand Down
4 changes: 2 additions & 2 deletions ocaml/database/parse_db_conf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ let from_block r =
; ( if r.mode = Write_limit then
Printf.sprintf "write_limit_period:%d\nwrite_limit_write_cycles:%d\n"
r.write_limit_period r.write_limit_write_cycles
else
""
else
""
)
; String.concat ""
(List.map
Expand Down
4 changes: 2 additions & 2 deletions ocaml/idl/datamodel_schema.ml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ let of_datamodel () =
default=
( if issetref then
Some (Value.Set [])
else
Option.map Datamodel_values.to_db f.Datamodel_types.default_value
else
Option.map Datamodel_values.to_db f.Datamodel_types.default_value
)
; ty
; issetref
Expand Down
12 changes: 6 additions & 6 deletions ocaml/idl/json_backend/gen_json.ml
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ end = struct
, obj.name
, ( if doc = "" && transition = Lifecycle.Published then
obj.description
else
doc
else
doc
)
, "class"
)
Expand All @@ -445,8 +445,8 @@ end = struct
, obj.name ^ "." ^ m.msg_name
, ( if doc = "" && transition = Lifecycle.Published then
m.msg_doc
else
doc
else
doc
)
, "message"
)
Expand Down Expand Up @@ -474,8 +474,8 @@ end = struct
, obj.name ^ "." ^ field_name
, ( if doc = "" && transition = Lifecycle.Published then
f.field_description
else
doc
else
doc
)
, "field"
)
Expand Down
16 changes: 8 additions & 8 deletions ocaml/idl/markdown_backend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ let print_field_table_of_obj printer ~is_class_deprecated ~is_class_removed x =
let descr =
( if y.lifecycle.state = Removed_s || is_class_removed then
"**Removed**. "
else if y.lifecycle.state = Deprecated_s || is_class_deprecated then
"**Deprecated**. "
else
""
else if y.lifecycle.state = Deprecated_s || is_class_deprecated then
"**Deprecated**. "
else
""
)
^ escape description
in
Expand Down Expand Up @@ -401,10 +401,10 @@ let print_classes api io =
let get_descr obj =
( if obj.obj_lifecycle.state = Removed_s then
"**Removed**. "
else if obj.obj_lifecycle.state = Deprecated_s then
"**Deprecated**. "
else
""
else if obj.obj_lifecycle.state = Deprecated_s then
"**Deprecated**. "
else
""
)
^ escape obj.description
in
Expand Down
10 changes: 5 additions & 5 deletions ocaml/idl/ocaml_backend/gen_client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ let gen_module api : O.Module.t =
OU.alias_of_ty x
| _ ->
"unit"
else
OU.alias_of_ty (DT.Ref Datamodel_common._task)
else
OU.alias_of_ty (DT.Ref Datamodel_common._task)
)
~body:(x.msg_name :: "~rpc" :: all)
()
Expand Down Expand Up @@ -206,9 +206,9 @@ let gen_module api : O.Module.t =
"rpc_wrapper rpc %s [ %s ] >>= fun x -> return (%s x)"
( if sync then
Printf.sprintf "\"%s\"" wire_name
else
Printf.sprintf {|(Printf.sprintf "%%s%s" AQ.async_qualifier)|}
wire_name
else
Printf.sprintf {|(Printf.sprintf "%%s%s" AQ.async_qualifier)|}
wire_name
)
(String.concat "; " rpc_args)
(from_xmlrpc x.msg_result)
Expand Down
4 changes: 2 additions & 2 deletions ocaml/idl/ocaml_backend/gen_db_actions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ let db_action api : O.Module.t =
~elements:
( if obj.DT.in_database then
[O.Module.Let (register_get_record obj)]
else
[]
else
[]
)
()
in
Expand Down
30 changes: 15 additions & 15 deletions ocaml/idl/ocaml_backend/gen_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ let operation (obj : obj) (x : message) =
[
( if Gen_empty_custom.operation_requires_side_effect x then
["(* has side-effect (with locks and no automatic DB action) *)"]
else
["(* has no side-effect; should be handled by DB action *) "]
else
["(* has no side-effect; should be handled by DB action *) "]
)
; ( if has_async then
["(* has asynchronous mode *)"]
else
["(* has no asynchronous mode *)"]
else
["(* has no asynchronous mode *)"]
)
]
in
Expand Down Expand Up @@ -270,16 +270,16 @@ let operation (obj : obj) (x : message) =
because we know we don't need the arguments *)
let ignore = x.DT.msg_forward_to <> None in
( if
(* If we're a constructor then unmarshall all the fields from the constructor record, passed as a struct *)
is_ctor
then
(* If we're a constructor then unmarshall all the fields from the constructor record, passed as a struct *)
is_ctor
then
[from_rpc Client.session; from_ctor_record]
(* Otherwise, go read non-default fields from pattern match; if we have default fields then we need to
get those from the 'default_fields' arg *)
else
List.map
(fun a -> from_rpc ~ignore:(ignore && not (is_session_arg a)) a)
args_without_default_values
else
List.map
(fun a -> from_rpc ~ignore:(ignore && not (is_session_arg a)) a)
args_without_default_values
)
(* and for every default value we try to get this from default_args or default it *)
@ unmarshall_default_params
Expand Down Expand Up @@ -380,8 +380,8 @@ let operation (obj : obj) (x : message) =
Printf.sprintf "%s \"%s\";"
( if may_be_side_effecting x then
"ApiLogSideEffect.debug"
else
"ApiLogRead.debug"
else
"ApiLogRead.debug"
)
wire_name
]
Expand All @@ -395,8 +395,8 @@ let operation (obj : obj) (x : message) =
(if x.msg_session then "~session_id" else "")
( if Gen_empty_custom.operation_requires_side_effect x then
"~forward_op"
else
""
else
""
)
; (* "P.debug \"Server RPC response: %s\" (Rpc.to_string (resp.Rpc.contents));"; *)
"resp"
Expand Down
10 changes: 5 additions & 5 deletions ocaml/idl/ocaml_backend/ocaml_syntax.ml
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ module Module = struct
^ " = "
^ ( if x.args = [] then
""
else
String.concat " "
(List.map (fun x -> "functor(" ^ x ^ ") ->") x.args)
else
String.concat " "
(List.map (fun x -> "functor(" ^ x ^ ") ->") x.args)
)
^ "struct"
in
Expand Down Expand Up @@ -179,8 +179,8 @@ module Signature = struct
[
( if toplevel then
Line ("module type " ^ x.name ^ " = sig")
else
Line ("module " ^ x.name ^ " : sig")
else
Line ("module " ^ x.name ^ " : sig")
)
; Indent (List.concat (List.map e x.elements))
; Line "end"
Expand Down
4 changes: 2 additions & 2 deletions ocaml/libs/ezxenstore/watch/ez_xenstore_watch.ml
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ module Make (Debug : DEBUG) = struct
IntMap.find domid
( if IntMap.mem domid domains' then
domains'
else
!domains
else
!domains
)
in
let id = Uuidm.to_string (uuid_of_di di) in
Expand Down
8 changes: 4 additions & 4 deletions ocaml/libs/http-lib/http_svr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ let escape uri =
let aux h t =
( if List.mem_assoc h rules then
List.assoc h rules
else
Astring.String.of_char h
else
Astring.String.of_char h
)
:: t
in
Expand Down Expand Up @@ -761,8 +761,8 @@ let clean_addr_of_string ip =
let ipv4_affix = "::ffff:" in
( if Astring.String.is_prefix ~affix:ipv4_affix ip then
Astring.String.drop ~max:(String.length ipv4_affix) ip
else
ip
else
ip
)
|> Ipaddr.of_string
|> Stdlib.Result.to_option
Expand Down
8 changes: 4 additions & 4 deletions ocaml/libs/stunnel/stunnel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ let disconnect_with_pid ?(wait = true) ?(force = false) pid =
(fun () ->
( if wait then
Forkhelpers.waitpid
else
Forkhelpers.waitpid_nohang
else
Forkhelpers.waitpid_nohang
)
fpid
)
Expand All @@ -267,8 +267,8 @@ let disconnect_with_pid ?(wait = true) ?(force = false) pid =
(fun () ->
( if wait then
Unix.waitpid []
else
Unix.waitpid [Unix.WNOHANG]
else
Unix.waitpid [Unix.WNOHANG]
)
pid
)
Expand Down
8 changes: 4 additions & 4 deletions ocaml/libs/uuid/uuidx.mli
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ val to_string : 'a t -> string
(** Marshal a UUID to a string. *)

val uuid_of_string : string -> 'a t option
[@@deprecated "Use of_string"]
[@@deprecated "Use of_string"]
(** Deprecated alias for {! Uuidx.of_string} *)

val string_of_uuid : 'a t -> string
[@@deprecated "Use to_string"]
[@@deprecated "Use to_string"]
(** Deprecated alias for {! Uuidx.to_string} *)

val of_int_array : int array -> 'a t option
Expand All @@ -62,11 +62,11 @@ val to_int_array : 'a t -> int array
(** Convert a UUID to an array. *)

val uuid_of_int_array : int array -> 'a t option
[@@deprecated "Use Uuidx.of_int_array"]
[@@deprecated "Use Uuidx.of_int_array"]
(** Deprecated alias for {! Uuidx.of_int_array} *)

val int_array_of_uuid : 'a t -> int array
[@@deprecated "Use Uuidx.to_int_array"]
[@@deprecated "Use Uuidx.to_int_array"]
(** Deprecated alias for {! Uuidx.to_int_array} *)

val of_bytes : string -> 'a t option
Expand Down
Loading

0 comments on commit 4c167f7

Please sign in to comment.