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

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