Blame SOURCES/0542-ReiserFS-switch-to-using-grub_min-grub_max.patch

b9d01e
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b9d01e
From: Peter Jones <pjones@redhat.com>
b9d01e
Date: Thu, 21 Apr 2022 16:31:17 -0400
b9d01e
Subject: [PATCH] ReiserFS: switch to using grub_min()/grub_max()
b9d01e
b9d01e
This is a minor cleanup patch to remove the bespoke MIN() and MAX()
b9d01e
definitions from the reiserfs driver, and uses grub_min() / grub_max()
b9d01e
instead.
b9d01e
b9d01e
Signed-off-by: Peter Jones <pjones@redhat.com>
b9d01e
(cherry picked from commit 5fc601574fce99b32fe4dfb55bd8f3ab0175fd6a)
b9d01e
(cherry picked from commit 31e581893c564582c729fd0c033d3ce021854be8)
b9d01e
---
b9d01e
 grub-core/fs/reiserfs.c | 28 +++++++++-------------------
b9d01e
 1 file changed, 9 insertions(+), 19 deletions(-)
b9d01e
b9d01e
diff --git a/grub-core/fs/reiserfs.c b/grub-core/fs/reiserfs.c
b9d01e
index 39736f63c6..9556c15ff0 100644
b9d01e
--- a/grub-core/fs/reiserfs.c
b9d01e
+++ b/grub-core/fs/reiserfs.c
b9d01e
@@ -42,16 +42,6 @@
b9d01e
 
b9d01e
 GRUB_MOD_LICENSE ("GPLv3+");
b9d01e
 
b9d01e
-#define MIN(a, b) \
b9d01e
-  ({ typeof (a) _a = (a); \
b9d01e
-     typeof (b) _b = (b); \
b9d01e
-     _a < _b ? _a : _b; })
b9d01e
-
b9d01e
-#define MAX(a, b) \
b9d01e
-  ({ typeof (a) _a = (a); \
b9d01e
-     typeof (b) _b = (b); \
b9d01e
-     _a > _b ? _a : _b; })
b9d01e
-
b9d01e
 #define REISERFS_SUPER_BLOCK_OFFSET 0x10000
b9d01e
 #define REISERFS_MAGIC_LEN 12
b9d01e
 #define REISERFS_MAGIC_STRING "ReIsEr"
b9d01e
@@ -1076,7 +1066,7 @@ grub_reiserfs_read_real (struct grub_fshelp_node *node,
b9d01e
   grub_reiserfs_set_key_type (&key, GRUB_REISERFS_ANY, 2);
b9d01e
   initial_position = off;
b9d01e
   current_position = 0;
b9d01e
-  final_position = MIN (len + initial_position, node->size);
b9d01e
+  final_position = grub_min (len + initial_position, node->size);
b9d01e
   grub_dprintf ("reiserfs",
b9d01e
 		"Reading from %lld to %lld (%lld instead of requested %ld)\n",
b9d01e
 		(unsigned long long) initial_position,
b9d01e
@@ -1115,8 +1105,8 @@ grub_reiserfs_read_real (struct grub_fshelp_node *node,
b9d01e
           grub_dprintf ("reiserfs_blocktype", "D: %u\n", (unsigned) block);
b9d01e
           if (initial_position < current_position + item_size)
b9d01e
             {
b9d01e
-              offset = MAX ((signed) (initial_position - current_position), 0);
b9d01e
-              length = (MIN (item_size, final_position - current_position)
b9d01e
+              offset = grub_max ((signed) (initial_position - current_position), 0);
b9d01e
+              length = (grub_min (item_size, final_position - current_position)
b9d01e
                         - offset);
b9d01e
               grub_dprintf ("reiserfs",
b9d01e
                             "Reading direct block %u from %u to %u...\n",
b9d01e
@@ -1161,9 +1151,9 @@ grub_reiserfs_read_real (struct grub_fshelp_node *node,
b9d01e
               grub_dprintf ("reiserfs_blocktype", "I: %u\n", (unsigned) block);
b9d01e
               if (current_position + block_size >= initial_position)
b9d01e
                 {
b9d01e
-                  offset = MAX ((signed) (initial_position - current_position),
b9d01e
-                                0);
b9d01e
-                  length = (MIN (block_size, final_position - current_position)
b9d01e
+                  offset = grub_max ((signed) (initial_position - current_position),
b9d01e
+				     0);
b9d01e
+                  length = (grub_min (block_size, final_position - current_position)
b9d01e
                             - offset);
b9d01e
                   grub_dprintf ("reiserfs",
b9d01e
                                 "Reading indirect block %u from %u to %u...\n",
b9d01e
@@ -1205,7 +1195,7 @@ grub_reiserfs_read_real (struct grub_fshelp_node *node,
b9d01e
   switch (found.type)
b9d01e
     {
b9d01e
       case GRUB_REISERFS_DIRECT:
b9d01e
-        read_length = MIN (len, item_size - file->offset);
b9d01e
+        read_length = grub_min (len, item_size - file->offset);
b9d01e
         grub_disk_read (found.data->disk,
b9d01e
                         (found.block_number * block_size) / GRUB_DISK_SECTOR_SIZE,
b9d01e
                         grub_le_to_cpu16 (found.header.item_location) + file->offset,
b9d01e
@@ -1224,12 +1214,12 @@ grub_reiserfs_read_real (struct grub_fshelp_node *node,
b9d01e
                         item_size, (char *) indirect_block_ptr);
b9d01e
         if (grub_errno)
b9d01e
           goto fail;
b9d01e
-        len = MIN (len, file->size - file->offset);
b9d01e
+        len = grub_min (len, file->size - file->offset);
b9d01e
         for (indirect_block = file->offset / block_size;
b9d01e
              indirect_block < indirect_block_count && read_length < len;
b9d01e
              indirect_block++)
b9d01e
           {
b9d01e
-            read = MIN (block_size, len - read_length);
b9d01e
+            read = grub_min (block_size, len - read_length);
b9d01e
             grub_disk_read (found.data->disk,
b9d01e
                             (grub_le_to_cpu32 (indirect_block_ptr[indirect_block]) * block_size) / GRUB_DISK_SECTOR_SIZE,
b9d01e
                             file->offset % block_size, read,