upstream: https://github.com/mirage/mirage-crypto

fix(lint): resolve E205 in gen_tables.ml, replace open Format with Fmt

+15 -19
+15 -19
ec/gen_tables/gen_tables.ml
··· 1 - open Format 2 - 3 1 let print_header name = 4 - printf 2 + Fmt.pr 5 3 {| 6 4 /* 7 5 Pre-computed %d-bit multiples of the generator point G for the curve %s, ··· 12 10 Sys.word_size name Sys.argv.(0) 13 11 14 12 let pp_array elem_fmt fmt arr = 15 - let fout = fprintf fmt in 13 + let fout = Fmt.pf fmt in 16 14 let len = Array.length arr in 17 15 fout "@[<2>{@\n"; 18 16 for i = 0 to len - 1 do 19 17 elem_fmt fmt arr.(i); 20 - if i < len - 1 then printf ",@ " else printf "" 18 + if i < len - 1 then Fmt.pr ",@ " else Fmt.pr "" 21 19 done; 22 20 fout "@]@,}" 23 21 ··· 29 27 (* Truncate at the beginning (little-endian) *) 30 28 let bytes = Bytes.unsafe_of_string str in 31 29 (* let bytes = rev_str_bytes str in *) 32 - fprintf fmt "@[<2>{@\n"; 30 + Fmt.pf fmt "@[<2>{@\n"; 33 31 for i = 0 to limbs - 1 do 34 32 let index = i * (wordsize / 8) in 35 33 (if wordsize = 64 then 36 34 let w = Bytes.get_int64_le bytes index in 37 - fprintf fmt "%#016Lx" w 35 + Fmt.pf fmt "%#016Lx" w 38 36 else 39 37 let w = Bytes.get_int32_le bytes index in 40 - fprintf fmt "%#08lx" w); 41 - if i < limbs - 1 then printf ",@ " else printf "" 38 + Fmt.pf fmt "%#08lx" w); 39 + if i < limbs - 1 then Fmt.pr ",@ " else Fmt.pr "" 42 40 done; 43 - fprintf fmt "@]@,}" 41 + Fmt.pf fmt "@]@,}" 44 42 45 43 let check_shape tables = 46 44 let fe_len = String.length tables.(0).(0).(0) in ··· 58 56 59 57 let print_tables tables ~wordsize = 60 58 let fe_len = String.length tables.(0).(0).(0) in 61 - printf "@[<2>static WORD generator_table[%d][15][3][LIMBS] = @," (fe_len * 2); 59 + Fmt.pr "@[<2>static WORD generator_table[%d][15][3][LIMBS] = @," (fe_len * 2); 62 60 pp_array 63 61 (pp_array (pp_array (pp_string_words ~wordsize))) 64 - std_formatter tables; 65 - printf "@];@," 62 + Format.std_formatter tables; 63 + Fmt.pr "@];@," 66 64 67 65 let print_toplevel name wordsize (module P : Crypto_ec.Dh_dsa) = 68 66 let tables = P.Dsa.Precompute.generator_tables () in ··· 70 68 check_shape tables; 71 69 print_header name; 72 70 if wordsize = 64 then 73 - printf 71 + Fmt.pr 74 72 "@[<v>#ifndef ARCH_64BIT@,\ 75 73 #error \"Cannot use 64-bit tables on a 32-bit architecture\"@,\ 76 74 #endif@,\ 77 75 @]" 78 76 else 79 - printf 77 + Fmt.pr 80 78 "@[<v>#ifdef ARCH_64BIT@,\ 81 79 #error \"Cannot use 32-bit tables on a 64-bit architecture\"@,\ 82 80 #endif@,\ ··· 92 90 ] 93 91 94 92 let usage () = 95 - printf "Usage: gen_tables [%a] [64 | 32]@." 96 - (pp_print_list 97 - ~pp_sep:(fun fmt () -> pp_print_string fmt " | ") 98 - pp_print_string) 93 + Fmt.pr "Usage: gen_tables [%a] [64 | 32]@." 94 + (Fmt.list ~sep:(Fmt.any " | ") Fmt.string) 99 95 (List.map fst curves) 100 96 101 97 let go =