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

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