nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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