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>
---
 mldrivers/linux_kernels.ml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mldrivers/linux_kernels.ml b/mldrivers/linux_kernels.ml
index a46146a132d7..5b8bdee9923d 100644
--- a/mldrivers/linux_kernels.ml
+++ b/mldrivers/linux_kernels.ml
@@ -125,8 +125,8 @@ let detect_kernels (g : G.guestfs) root bootloader apps =
             *)
            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