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

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