|
| 1 | +From 9386516acb680406f6a299895e90316241b1b8f4 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Rudi Heitbaum <rudi@heitbaum.com> |
| 3 | +Date: Mon, 26 Jan 2026 22:35:29 +0000 |
| 4 | +Subject: [PATCH] build: fix initialization discards 'const' qualifier from |
| 5 | + pointer target type |
| 6 | + |
| 7 | +Since glibc-2.43: |
| 8 | + |
| 9 | +For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr, |
| 10 | +strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return |
| 11 | +pointers into their input arrays now have definitions as macros that |
| 12 | +return a pointer to a const-qualified type when the input argument is |
| 13 | +a pointer to a const-qualified type. |
| 14 | + |
| 15 | +https://lists.gnu.org/archive/html/info-gnu/2026-01/msg00005.html |
| 16 | + |
| 17 | +Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com> |
| 18 | +--- |
| 19 | + grub-core/osdep/linux/ofpath.c | 15 +++-- |
| 20 | + util/probe.c | 117 +++++++++++++++++++++++---------- |
| 21 | + util/resolve.c | 10 +-- |
| 22 | + 3 files changed, 94 insertions(+), 48 deletions(-) |
| 23 | + |
| 24 | +diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c |
| 25 | +index 24a4d5c8d..c2d1e8c14 100644 |
| 26 | +--- a/grub-core/osdep/linux/ofpath.c |
| 27 | ++++ b/grub-core/osdep/linux/ofpath.c |
| 28 | +@@ -488,7 +488,8 @@ check_hba_identifiers (const char *sysfs_path, int *vendor, int *device_id) |
| 29 | + static void |
| 30 | + check_sas (const char *sysfs_path, int *tgt, unsigned long int *sas_address) |
| 31 | + { |
| 32 | +- char *ed = strstr (sysfs_path, "end_device"); |
| 33 | ++ const char *ed = strstr (sysfs_path, "end_device"); |
| 34 | ++ char *ed2; |
| 35 | + char *p, *q, *path; |
| 36 | + char phy[21]; |
| 37 | + int fd; |
| 38 | +@@ -499,19 +500,19 @@ check_sas (const char *sysfs_path, int *tgt, unsigned long int *sas_address) |
| 39 | + |
| 40 | + /* SAS devices are identified using disk@$PHY_ID */ |
| 41 | + p = xstrdup (sysfs_path); |
| 42 | +- ed = strstr(p, "end_device"); |
| 43 | +- if (!ed) |
| 44 | ++ ed2 = strstr(p, "end_device"); |
| 45 | ++ if (!ed2) |
| 46 | + return; |
| 47 | + |
| 48 | +- q = ed; |
| 49 | ++ q = ed2; |
| 50 | + while (*q && *q != '/') |
| 51 | + q++; |
| 52 | + *q = '\0'; |
| 53 | + |
| 54 | +- path_size = (strlen (p) + strlen (ed) |
| 55 | ++ path_size = (strlen (p) + strlen (ed2) |
| 56 | + + sizeof ("%s/sas_device/%s/phy_identifier")); |
| 57 | + path = xmalloc (path_size); |
| 58 | +- snprintf (path, path_size, "%s/sas_device/%s/phy_identifier", p, ed); |
| 59 | ++ snprintf (path, path_size, "%s/sas_device/%s/phy_identifier", p, ed2); |
| 60 | + fd = open (path, O_RDONLY); |
| 61 | + if (fd < 0) |
| 62 | + grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); |
| 63 | +@@ -524,7 +525,7 @@ check_sas (const char *sysfs_path, int *tgt, unsigned long int *sas_address) |
| 64 | + |
| 65 | + sscanf (phy, "%d", tgt); |
| 66 | + |
| 67 | +- snprintf (path, path_size, "%s/sas_device/%s/sas_address", p, ed); |
| 68 | ++ snprintf (path, path_size, "%s/sas_device/%s/sas_address", p, ed2); |
| 69 | + fd = open (path, O_RDONLY); |
| 70 | + if (fd < 0) |
| 71 | + grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); |
| 72 | +diff --git a/util/probe.c b/util/probe.c |
| 73 | +index 81d91cf59..5d1858cf2 100644 |
| 74 | +--- a/util/probe.c |
| 75 | ++++ b/util/probe.c |
| 76 | +@@ -70,26 +70,41 @@ char * |
| 77 | + grub_util_guess_bios_drive (const char *orig_path) |
| 78 | + { |
| 79 | + char *canon; |
| 80 | +- char *ptr; |
| 81 | ++ const char *ptr; |
| 82 | + canon = grub_canonicalize_file_name (orig_path); |
| 83 | + if (!canon) |
| 84 | + return NULL; |
| 85 | + ptr = strrchr (orig_path, '/'); |
| 86 | + if (ptr) |
| 87 | +- ptr++; |
| 88 | +- else |
| 89 | +- ptr = canon; |
| 90 | +- if ((ptr[0] == 's' || ptr[0] == 'h') && ptr[1] == 'd') |
| 91 | + { |
| 92 | +- int num = ptr[2] - 'a'; |
| 93 | +- free (canon); |
| 94 | +- return xasprintf ("hd%d", num); |
| 95 | ++ ptr++; |
| 96 | ++ if ((ptr[0] == 's' || ptr[0] == 'h') && ptr[1] == 'd') |
| 97 | ++ { |
| 98 | ++ int num = ptr[2] - 'a'; |
| 99 | ++ free (canon); |
| 100 | ++ return xasprintf ("hd%d", num); |
| 101 | ++ } |
| 102 | ++ if (ptr[0] == 'f' && ptr[1] == 'd') |
| 103 | ++ { |
| 104 | ++ int num = atoi (ptr + 2); |
| 105 | ++ free (canon); |
| 106 | ++ return xasprintf ("fd%d", num); |
| 107 | ++ } |
| 108 | + } |
| 109 | +- if (ptr[0] == 'f' && ptr[1] == 'd') |
| 110 | ++ else |
| 111 | + { |
| 112 | +- int num = atoi (ptr + 2); |
| 113 | +- free (canon); |
| 114 | +- return xasprintf ("fd%d", num); |
| 115 | ++ if ((canon[0] == 's' || canon[0] == 'h') && canon[1] == 'd') |
| 116 | ++ { |
| 117 | ++ int num = canon[2] - 'a'; |
| 118 | ++ free (canon); |
| 119 | ++ return xasprintf ("hd%d", num); |
| 120 | ++ } |
| 121 | ++ if (canon[0] == 'f' && canon[1] == 'd') |
| 122 | ++ { |
| 123 | ++ int num = atoi (canon + 2); |
| 124 | ++ free (canon); |
| 125 | ++ return xasprintf ("fd%d", num); |
| 126 | ++ } |
| 127 | + } |
| 128 | + free (canon); |
| 129 | + return NULL; |
| 130 | +@@ -99,26 +114,41 @@ char * |
| 131 | + grub_util_guess_efi_drive (const char *orig_path) |
| 132 | + { |
| 133 | + char *canon; |
| 134 | +- char *ptr; |
| 135 | ++ const char *ptr; |
| 136 | + canon = grub_canonicalize_file_name (orig_path); |
| 137 | + if (!canon) |
| 138 | + return NULL; |
| 139 | + ptr = strrchr (orig_path, '/'); |
| 140 | + if (ptr) |
| 141 | +- ptr++; |
| 142 | +- else |
| 143 | +- ptr = canon; |
| 144 | +- if ((ptr[0] == 's' || ptr[0] == 'h') && ptr[1] == 'd') |
| 145 | + { |
| 146 | +- int num = ptr[2] - 'a'; |
| 147 | +- free (canon); |
| 148 | +- return xasprintf ("hd%d", num); |
| 149 | ++ ptr++; |
| 150 | ++ if ((ptr[0] == 's' || ptr[0] == 'h') && ptr[1] == 'd') |
| 151 | ++ { |
| 152 | ++ int num = ptr[2] - 'a'; |
| 153 | ++ free (canon); |
| 154 | ++ return xasprintf ("hd%d", num); |
| 155 | ++ } |
| 156 | ++ if (ptr[0] == 'f' && ptr[1] == 'd') |
| 157 | ++ { |
| 158 | ++ int num = atoi (ptr + 2); |
| 159 | ++ free (canon); |
| 160 | ++ return xasprintf ("fd%d", num); |
| 161 | ++ } |
| 162 | + } |
| 163 | +- if (ptr[0] == 'f' && ptr[1] == 'd') |
| 164 | ++ else |
| 165 | + { |
| 166 | +- int num = atoi (ptr + 2); |
| 167 | +- free (canon); |
| 168 | +- return xasprintf ("fd%d", num); |
| 169 | ++ if ((canon[0] == 's' || canon[0] == 'h') && canon[1] == 'd') |
| 170 | ++ { |
| 171 | ++ int num = canon[2] - 'a'; |
| 172 | ++ free (canon); |
| 173 | ++ return xasprintf ("hd%d", num); |
| 174 | ++ } |
| 175 | ++ if (canon[0] == 'f' && canon[1] == 'd') |
| 176 | ++ { |
| 177 | ++ int num = atoi (canon + 2); |
| 178 | ++ free (canon); |
| 179 | ++ return xasprintf ("fd%d", num); |
| 180 | ++ } |
| 181 | + } |
| 182 | + free (canon); |
| 183 | + return NULL; |
| 184 | +@@ -128,26 +158,41 @@ char * |
| 185 | + grub_util_guess_baremetal_drive (const char *orig_path) |
| 186 | + { |
| 187 | + char *canon; |
| 188 | +- char *ptr; |
| 189 | ++ const char *ptr; |
| 190 | + canon = grub_canonicalize_file_name (orig_path); |
| 191 | + if (!canon) |
| 192 | + return NULL; |
| 193 | + ptr = strrchr (orig_path, '/'); |
| 194 | + if (ptr) |
| 195 | +- ptr++; |
| 196 | +- else |
| 197 | +- ptr = canon; |
| 198 | +- if (ptr[0] == 'h' && ptr[1] == 'd') |
| 199 | + { |
| 200 | +- int num = ptr[2] - 'a'; |
| 201 | +- free (canon); |
| 202 | +- return xasprintf ("ata%d", num); |
| 203 | ++ ptr++; |
| 204 | ++ if (ptr[0] == 'h' && ptr[1] == 'd') |
| 205 | ++ { |
| 206 | ++ int num = ptr[2] - 'a'; |
| 207 | ++ free (canon); |
| 208 | ++ return xasprintf ("ata%d", num); |
| 209 | ++ } |
| 210 | ++ if (ptr[0] == 's' && ptr[1] == 'd') |
| 211 | ++ { |
| 212 | ++ int num = ptr[2] - 'a'; |
| 213 | ++ free (canon); |
| 214 | ++ return xasprintf ("ahci%d", num); |
| 215 | ++ } |
| 216 | + } |
| 217 | +- if (ptr[0] == 's' && ptr[1] == 'd') |
| 218 | ++ else |
| 219 | + { |
| 220 | +- int num = ptr[2] - 'a'; |
| 221 | +- free (canon); |
| 222 | +- return xasprintf ("ahci%d", num); |
| 223 | ++ if (canon[0] == 'h' && canon[1] == 'd') |
| 224 | ++ { |
| 225 | ++ int num = canon[2] - 'a'; |
| 226 | ++ free (canon); |
| 227 | ++ return xasprintf ("ata%d", num); |
| 228 | ++ } |
| 229 | ++ if (canon[0] == 's' && canon[1] == 'd') |
| 230 | ++ { |
| 231 | ++ int num = canon[2] - 'a'; |
| 232 | ++ free (canon); |
| 233 | ++ return xasprintf ("ahci%d", num); |
| 234 | ++ } |
| 235 | + } |
| 236 | + free (canon); |
| 237 | + return NULL; |
| 238 | +diff --git a/util/resolve.c b/util/resolve.c |
| 239 | +index b6e26312f..254379195 100644 |
| 240 | +--- a/util/resolve.c |
| 241 | ++++ b/util/resolve.c |
| 242 | +@@ -138,12 +138,12 @@ read_dep_list (FILE *fp) |
| 243 | + static char * |
| 244 | + get_module_name (const char *str) |
| 245 | + { |
| 246 | +- char *base; |
| 247 | +- char *ext; |
| 248 | ++ const char *base; |
| 249 | ++ const char *ext; |
| 250 | + |
| 251 | + base = strrchr (str, '/'); |
| 252 | + if (! base) |
| 253 | +- base = (char *) str; |
| 254 | ++ base = str; |
| 255 | + else |
| 256 | + base++; |
| 257 | + |
| 258 | +@@ -164,9 +164,9 @@ get_module_name (const char *str) |
| 259 | + static char * |
| 260 | + get_module_path (const char *prefix, const char *str) |
| 261 | + { |
| 262 | +- char *dir; |
| 263 | ++ const char *dir; |
| 264 | + char *base; |
| 265 | +- char *ext; |
| 266 | ++ const char *ext; |
| 267 | + char *ret; |
| 268 | + |
| 269 | + ext = strrchr (str, '.'); |
| 270 | +-- |
| 271 | +2.51.0 |
| 272 | + |
0 commit comments