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