We want to catch Not_found from (our own implementation of)
"List.find_map". There's no need (and it makes no sense) to push the
"prefix_len" calculation down into the "try" scope. Keep the "try" scope
as narrow as possible.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2175703
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
Tested-by: Vera Wu <v...@redhat.com>
(ported from libguestfs-common commit 4003815a994944cab38d48cfc96f16382de62987)
---
 convert/linux_kernels.ml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/convert/linux_kernels.ml b/convert/linux_kernels.ml
index 6e9d2bdd89cc..75ab94c45551 100644
--- a/convert/linux_kernels.ml
+++ b/convert/linux_kernels.ml
@@ -122,8 +122,8 @@ let detect_kernels (g : G.guestfs) inspect family 
bootloader =
             *)
            let modpath, version =
              let prefix = "/lib/modules/" in
+             let prefix_len = String.length prefix in
              try
-               let prefix_len = String.length prefix in
                List.find_map (
                  fun filename ->
                    let filename_len = String.length filename in

_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to