Blame SOURCES/0019-detect_kernels-tighten-try-scope.patch

1359b8
From e7aa456e26e59bfa5cca1299ef2cb5299592d9da Mon Sep 17 00:00:00 2001
1359b8
From: Laszlo Ersek <lersek@redhat.com>
1359b8
Date: Wed, 5 Apr 2023 17:08:28 +0200
1359b8
Subject: [PATCH] detect_kernels: tighten "try" scope
1359b8
1359b8
We want to catch Not_found from (our own implementation of)
1359b8
"List.find_map". There's no need (and it makes no sense) to push the
1359b8
"prefix_len" calculation down into the "try" scope. Keep the "try" scope
1359b8
as narrow as possible.
1359b8
1359b8
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2175703
1359b8
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
1359b8
Tested-by: Vera Wu <vwu@redhat.com>
1359b8
(ported from libguestfs-common commit 4003815a994944cab38d48cfc96f16382de62987)
1359b8
Message-Id: <20230405150829.171720-2-lersek@redhat.com>
1359b8
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
1359b8
---
1359b8
 convert/linux_kernels.ml | 2 +-
1359b8
 1 file changed, 1 insertion(+), 1 deletion(-)
1359b8
1359b8
diff --git a/convert/linux_kernels.ml b/convert/linux_kernels.ml
1359b8
index 6e9d2bdd..75ab94c4 100644
1359b8
--- a/convert/linux_kernels.ml
1359b8
+++ b/convert/linux_kernels.ml
1359b8
@@ -122,8 +122,8 @@ let detect_kernels (g : G.guestfs) inspect family bootloader =
1359b8
             *)
1359b8
            let modpath, version =
1359b8
              let prefix = "/lib/modules/" in
1359b8
+             let prefix_len = String.length prefix in
1359b8
              try
1359b8
-               let prefix_len = String.length prefix in
1359b8
                List.find_map (
1359b8
                  fun filename ->
1359b8
                    let filename_len = String.length filename in