0014-fs-jfs-Inconsistent-signed-unsigned-types-usage-in-r.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. From 32f319d100c3b8f9b04e6a175f599c7411a54555 Mon Sep 17 00:00:00 2001
  2. From: Lidong Chen <lidong.chen@oracle.com>
  3. Date: Mon, 16 Dec 2024 20:22:40 +0000
  4. Subject: [PATCH] fs/jfs: Inconsistent signed/unsigned types usage in return
  5. values
  6. The getblk() returns a value of type grub_int64_t which is assigned to
  7. iagblk and inoblk, both of type grub_uint64_t, in grub_jfs_read_inode()
  8. via grub_jfs_blkno(). This patch fixes the type mismatch in the
  9. functions. Additionally, the getblk() will return 0 instead of -1 on
  10. failure cases. This change is safe because grub_errno is always set in
  11. getblk() to indicate errors and it is later checked in the callers.
  12. Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
  13. Reviewed-by: Alec Brown <alec.r.brown@oracle.com>
  14. Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
  15. Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
  16. Upstream: edd995a26ec98654d907a9436a296c2d82bc4b28
  17. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  18. ---
  19. grub-core/fs/jfs.c | 15 +++++++++------
  20. 1 file changed, 9 insertions(+), 6 deletions(-)
  21. diff --git a/grub-core/fs/jfs.c b/grub-core/fs/jfs.c
  22. index 2bde48d45..70a2f4947 100644
  23. --- a/grub-core/fs/jfs.c
  24. +++ b/grub-core/fs/jfs.c
  25. @@ -279,7 +279,7 @@ get_ext_offset (grub_uint8_t offset1, grub_uint32_t offset2)
  26. return (((grub_uint64_t) offset1 << 32) | grub_le_to_cpu32 (offset2));
  27. }
  28. -static grub_int64_t
  29. +static grub_uint64_t
  30. getblk (struct grub_jfs_treehead *treehead,
  31. struct grub_jfs_tree_extent *extents,
  32. int max_extents,
  33. @@ -290,6 +290,8 @@ getblk (struct grub_jfs_treehead *treehead,
  34. int i;
  35. grub_uint64_t ext_offset, ext_blk;
  36. + grub_errno = GRUB_ERR_NONE;
  37. +
  38. for (i = 0; i < grub_le_to_cpu16 (treehead->count) - 2 &&
  39. i < max_extents; i++)
  40. {
  41. @@ -312,7 +314,7 @@ getblk (struct grub_jfs_treehead *treehead,
  42. if (found != -1)
  43. {
  44. - grub_int64_t ret = -1;
  45. + grub_uint64_t ret = 0;
  46. struct
  47. {
  48. struct grub_jfs_treehead treehead;
  49. @@ -321,7 +323,7 @@ getblk (struct grub_jfs_treehead *treehead,
  50. tree = grub_zalloc (sizeof (*tree));
  51. if (!tree)
  52. - return -1;
  53. + return 0;
  54. if (!grub_disk_read (data->disk,
  55. (grub_disk_addr_t) ext_blk
  56. @@ -334,19 +336,20 @@ getblk (struct grub_jfs_treehead *treehead,
  57. else
  58. {
  59. grub_error (GRUB_ERR_BAD_FS, "jfs: infinite recursion detected");
  60. - ret = -1;
  61. + ret = 0;
  62. }
  63. }
  64. grub_free (tree);
  65. return ret;
  66. }
  67. - return -1;
  68. + grub_error (GRUB_ERR_READ_ERROR, "jfs: block %" PRIuGRUB_UINT64_T " not found", blk);
  69. + return 0;
  70. }
  71. /* Get the block number for the block BLK in the node INODE in the
  72. mounted filesystem DATA. */
  73. -static grub_int64_t
  74. +static grub_uint64_t
  75. grub_jfs_blkno (struct grub_jfs_data *data, struct grub_jfs_inode *inode,
  76. grub_uint64_t blk)
  77. {
  78. --
  79. 2.50.1