Skip to content

C23 string func() handling updates

Nicholas Vinson grub-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 1 replyIn review
  2. v13 patches 4 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4grub-core/osdep/linux/ofpath.c: Update strstr() callsgrub-core/osdep/linux/ofpath.c+12 -130 replies
2/4grub-core/osdep/linux/ofpath.c: correct path_size calculationgrub-core/osdep/linux/ofpath.c+1 -10 replies
3/4util/probe.c: save strrchr() ret val to const data ptr.util/probe.c+3 -30 replies
4/4util/resolve.c: Save str[r]chr() ret val to const data ptrutil/resolve.c+5 -50 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/4] C23 string func() handling updates

With C23, the following 12 functions were updated to have 'const-aware' return types:

bsearch(), bsearch_s(), memchr(), strchr(), strpbrk(), strrchr(), strstr(), wcschr(), wcspbrk(), wcsrchr(), wcsstr(), and wmemchr().

Of these functions, strchr(), strpbrk(), strrchr(), and strstr(), are used within GRUB, and for 3 of these functions, strchr(), strrchr(), and strstr(), some of their calls within GRUB are now resulting in compile-time errors due to the C23 changes and 'discarding qualifier' errors. The errors are generated by elevating 'discarding qualifier' warnings to error-level. A promotion GRUB's build system defaults to doing.

Most of the changes this patch series makes to fix these errors are simple and only requiring changing a variable's type from 'char *' to 'const char *'. However, the changes in ofpath.c are more involved as they also update the way lengths are calculated and *printf() functions are called as a result of these C23 changes.

Furthermore, the changes are needed as C runtime libraries, notably glbc starting with version 2.43, are implementing the changes the C23 standard requires.

Nicholas Vinson (4):
grub-core/osdep/linux/ofpath.c: Update strstr() calls grub-core/osdep/linux/ofpath.c: correct path_size calculation util/probe.c: save strrchr() ret val to const data ptr. util/resolve.c: Save str[r]chr() ret val to const data ptr

 grub-core/osdep/linux/ofpath.c | 25 ++++++++++++-------------
 util/probe.c                   |  6 +++---
 util/resolve.c                 | 10 +++++-----
 3 files changed, 20 insertions(+), 21 deletions(-)
Signature · 7 lines
2.53.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel