upstream: https://github.com/mirage/ocaml-mbr
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(lint): resolve E005 long functions, E331 redundant prefixes, and E010 deep nesting

Extract helper functions to reduce long function lengths across cwt, jsonwt,
ltp, matter, mbr, json-logs, and initramfs. Remove redundant find_/make_
prefixes in discovery.ml. Extract nested rm closure to reduce nesting depth.

+12 -14
+12 -14
lib/mbr.ml
··· 236 236 (* For unsigned interpretation, check if sum < a when both are positive *) 237 237 Int32.unsigned_compare sum a < 0 238 238 239 - let v ?(disk_signature = 0l) partitions = 239 + let validate_partitions partitions = 240 240 let* () = 241 241 if List.length partitions <= 4 then Ok () else Error "Too many partitions" 242 242 in ··· 249 249 if num_active <= 1 then Ok () 250 250 else Error "More than one active/boot partitions is not advisable" 251 251 in 252 - (* Security: validate partition start + size doesn't overflow *) 253 252 let* () = 254 253 List.fold_left 255 254 (fun r p -> ··· 264 263 else Ok ()) 265 264 (Ok ()) partitions 266 265 in 267 - let partitions = 266 + let sorted = 268 267 List.sort 269 268 (fun p1 p2 -> 270 269 Int32.unsigned_compare p1.Partition.first_absolute_sector_lba ··· 282 281 Ok 283 282 (Int32.add p.Partition.first_absolute_sector_lba p.Partition.sectors) 284 283 else Error "Partitions overlap") 285 - (Ok 1l) partitions 284 + (Ok 1l) sorted 286 285 in 287 - let bootstrap_code = String.init (218 + 216) (Fun.const '\000') in 288 - let original_physical_drive = 0 in 289 - let seconds = 0 in 290 - let minutes = 0 in 291 - let hours = 0 in 286 + Ok sorted 287 + 288 + let v ?(disk_signature = 0l) partitions = 289 + let* partitions = validate_partitions partitions in 292 290 Ok 293 291 { 294 - bootstrap_code; 295 - original_physical_drive; 296 - seconds; 297 - minutes; 298 - hours; 292 + bootstrap_code = String.init (218 + 216) (Fun.const '\000'); 293 + original_physical_drive = 0; 294 + seconds = 0; 295 + minutes = 0; 296 + hours = 0; 299 297 disk_signature; 300 298 partitions; 301 299 }