Blame SOURCES/0245-Make-grub_strtoul-end-pointer-have-the-right-constif.patch

d9d99f
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
d9d99f
From: Peter Jones <pjones@redhat.com>
d9d99f
Date: Fri, 19 Oct 2018 13:41:48 -0400
d9d99f
Subject: [PATCH] Make grub_strtoul "end" pointer have the right
d9d99f
 constification.
d9d99f
d9d99f
Related: rhbz#1640979
d9d99f
Signed-off-by: Peter Jones <pjones@redhat.com>
d9d99f
---
d9d99f
 grub-core/kern/fs.c                | 2 +-
d9d99f
 grub-core/kern/misc.c              | 8 ++++----
d9d99f
 grub-core/kern/partition.c         | 2 +-
d9d99f
 grub-core/lib/legacy_parse.c       | 2 +-
d9d99f
 grub-core/lib/syslinux_parse.c     | 6 +++---
d9d99f
 grub-core/loader/i386/xen_fileXX.c | 2 +-
d9d99f
 grub-core/net/efi/ip4_config.c     | 2 +-
d9d99f
 grub-core/net/efi/ip6_config.c     | 2 +-
d9d99f
 grub-core/net/efi/net.c            | 4 ++--
d9d99f
 grub-core/net/efi/pxe.c            | 6 +++---
d9d99f
 grub-core/net/http.c               | 4 ++--
d9d99f
 grub-core/net/net.c                | 8 ++++----
d9d99f
 grub-core/net/url.c                | 2 +-
d9d99f
 grub-core/script/execute.c         | 6 +++---
d9d99f
 grub-core/term/serial.c            | 2 +-
d9d99f
 grub-core/term/terminfo.c          | 2 +-
d9d99f
 grub-core/tests/strtoull_test.c    | 2 +-
d9d99f
 include/grub/misc.h                | 6 +++---
d9d99f
 18 files changed, 34 insertions(+), 34 deletions(-)
d9d99f
d9d99f
diff --git a/grub-core/kern/fs.c b/grub-core/kern/fs.c
d9d99f
index 9085895b6fe..1bd748be83b 100644
d9d99f
--- a/grub-core/kern/fs.c
d9d99f
+++ b/grub-core/kern/fs.c
d9d99f
@@ -134,7 +134,7 @@ struct grub_fs_block
d9d99f
 static grub_err_t
d9d99f
 grub_fs_blocklist_open (grub_file_t file, const char *name)
d9d99f
 {
d9d99f
-  char *p = (char *) name;
d9d99f
+  const char *p = name;
d9d99f
   unsigned num = 0;
d9d99f
   unsigned i;
d9d99f
   grub_disk_t disk = file->device->disk;
d9d99f
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
d9d99f
index 5c3899f0e5b..aaae9aa0ab7 100644
d9d99f
--- a/grub-core/kern/misc.c
d9d99f
+++ b/grub-core/kern/misc.c
d9d99f
@@ -383,7 +383,7 @@ grub_isspace (int c)
d9d99f
 }
d9d99f
 
d9d99f
 unsigned long
d9d99f
-grub_strtoul (const char *str, char **end, int base)
d9d99f
+grub_strtoul (const char *str, const char ** const end, int base)
d9d99f
 {
d9d99f
   unsigned long long num;
d9d99f
 
d9d99f
@@ -400,7 +400,7 @@ grub_strtoul (const char *str, char **end, int base)
d9d99f
 }
d9d99f
 
d9d99f
 unsigned long long
d9d99f
-grub_strtoull (const char *str, char **end, int base)
d9d99f
+grub_strtoull (const char *str, const char ** const end, int base)
d9d99f
 {
d9d99f
   unsigned long long num = 0;
d9d99f
   int found = 0;
d9d99f
@@ -901,14 +901,14 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
d9d99f
 	{
d9d99f
 	  if (fmt[0] == '0')
d9d99f
 	    zerofill = '0';
d9d99f
-	  format1 = grub_strtoul (fmt, (char **) &fmt, 10);
d9d99f
+	  format1 = grub_strtoul (fmt, &fmt, 10);
d9d99f
 	}
d9d99f
 
d9d99f
       if (*fmt == '.')
d9d99f
 	fmt++;
d9d99f
 
d9d99f
       if (grub_isdigit (*fmt))
d9d99f
-	format2 = grub_strtoul (fmt, (char **) &fmt, 10);
d9d99f
+	format2 = grub_strtoul (fmt, &fmt, 10);
d9d99f
 
d9d99f
       if (*fmt == '$')
d9d99f
 	{
d9d99f
diff --git a/grub-core/kern/partition.c b/grub-core/kern/partition.c
d9d99f
index e499147cbcb..2c401b866c4 100644
d9d99f
--- a/grub-core/kern/partition.c
d9d99f
+++ b/grub-core/kern/partition.c
d9d99f
@@ -126,7 +126,7 @@ grub_partition_probe (struct grub_disk *disk, const char *str)
d9d99f
       while (*ptr && grub_isalpha (*ptr))
d9d99f
 	ptr++;
d9d99f
       partname_end = ptr; 
d9d99f
-      num = grub_strtoul (ptr, (char **) &ptr, 0) - 1;
d9d99f
+      num = grub_strtoul (ptr, &ptr, 0) - 1;
d9d99f
 
d9d99f
       curpart = 0;
d9d99f
       /* Use the first partition map type found.  */
d9d99f
diff --git a/grub-core/lib/legacy_parse.c b/grub-core/lib/legacy_parse.c
d9d99f
index ef56150ac77..05719ab2ccb 100644
d9d99f
--- a/grub-core/lib/legacy_parse.c
d9d99f
+++ b/grub-core/lib/legacy_parse.c
d9d99f
@@ -418,7 +418,7 @@ adjust_file (const char *in, grub_size_t len)
d9d99f
     }
d9d99f
   if (*comma != ',')
d9d99f
     return grub_legacy_escape (in, len);
d9d99f
-  part = grub_strtoull (comma + 1, (char **) &rest, 0);
d9d99f
+  part = grub_strtoull (comma + 1, &rest, 0);
d9d99f
   if (rest[0] == ',' && rest[1] >= 'a' && rest[1] <= 'z')
d9d99f
     {
d9d99f
       subpart = rest[1] - 'a';
d9d99f
diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c
d9d99f
index 28ba3aef0bb..21ca040ada7 100644
d9d99f
--- a/grub-core/lib/syslinux_parse.c
d9d99f
+++ b/grub-core/lib/syslinux_parse.c
d9d99f
@@ -1058,7 +1058,7 @@ write_entry (struct output_buffer *outbuf,
d9d99f
 		if (ptr[0] == 'h' && ptr[1] == 'd')
d9d99f
 		  {
d9d99f
 		    is_fd = 0;
d9d99f
-		    devn = grub_strtoul (ptr + 2, &ptr, 0);
d9d99f
+		    devn = grub_strtoul (ptr + 2, (const char **)&ptr, 0);
d9d99f
 		    continue;
d9d99f
 		  }
d9d99f
 		if (grub_strncasecmp (ptr, "file=", 5) == 0)
d9d99f
@@ -1082,12 +1082,12 @@ write_entry (struct output_buffer *outbuf,
d9d99f
 		if (ptr[0] == 'f' && ptr[1] == 'd')
d9d99f
 		  {
d9d99f
 		    is_fd = 1;
d9d99f
-		    devn = grub_strtoul (ptr + 2, &ptr, 0);
d9d99f
+		    devn = grub_strtoul (ptr + 2, (const char **)&ptr, 0);
d9d99f
 		    continue;
d9d99f
 		  }
d9d99f
 		if (grub_isdigit (ptr[0]))
d9d99f
 		  {
d9d99f
-		    part = grub_strtoul (ptr, &ptr, 0);
d9d99f
+		    part = grub_strtoul (ptr, (const char **)&ptr, 0);
d9d99f
 		    continue;
d9d99f
 		  }
d9d99f
 		/* FIXME: isolinux, ntldr, cmldr, *dos, seg, hide
d9d99f
diff --git a/grub-core/loader/i386/xen_fileXX.c b/grub-core/loader/i386/xen_fileXX.c
d9d99f
index fb66e66fe96..293f1ad5c3e 100644
d9d99f
--- a/grub-core/loader/i386/xen_fileXX.c
d9d99f
+++ b/grub-core/loader/i386/xen_fileXX.c
d9d99f
@@ -25,7 +25,7 @@ parse_xen_guest (grub_elf_t elf, struct grub_xen_file_info *xi,
d9d99f
 		 grub_off_t off, grub_size_t sz)
d9d99f
 {
d9d99f
   char *buf;
d9d99f
-  char *ptr;
d9d99f
+  const char *ptr;
d9d99f
   int has_paddr = 0;
d9d99f
 
d9d99f
   grub_errno = GRUB_ERR_NONE;
d9d99f
diff --git a/grub-core/net/efi/ip4_config.c b/grub-core/net/efi/ip4_config.c
d9d99f
index b711a5d9457..38e2a04747a 100644
d9d99f
--- a/grub-core/net/efi/ip4_config.c
d9d99f
+++ b/grub-core/net/efi/ip4_config.c
d9d99f
@@ -62,7 +62,7 @@ grub_efi_string_to_ip4_address (const char *val, grub_efi_ipv4_address_t *addres
d9d99f
   for (i = 0; i < 4; i++)
d9d99f
     {
d9d99f
       unsigned long t;
d9d99f
-      t = grub_strtoul (ptr, (char **) &ptr, 0);
d9d99f
+      t = grub_strtoul (ptr, &ptr, 0);
d9d99f
       if (grub_errno)
d9d99f
 	{
d9d99f
 	  grub_errno = GRUB_ERR_NONE;
d9d99f
diff --git a/grub-core/net/efi/ip6_config.c b/grub-core/net/efi/ip6_config.c
d9d99f
index 017c4d05bc7..e0e00c23d21 100644
d9d99f
--- a/grub-core/net/efi/ip6_config.c
d9d99f
+++ b/grub-core/net/efi/ip6_config.c
d9d99f
@@ -84,7 +84,7 @@ grub_efi_string_to_ip6_address (const char *val, grub_efi_ipv6_address_t *addres
d9d99f
 	  ptr++;
d9d99f
 	  continue;
d9d99f
 	}
d9d99f
-      t = grub_strtoul (ptr, (char **) &ptr, 16);
d9d99f
+      t = grub_strtoul (ptr, &ptr, 16);
d9d99f
       if (grub_errno)
d9d99f
 	{
d9d99f
 	  grub_errno = GRUB_ERR_NONE;
d9d99f
diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c
d9d99f
index f208d1b180c..4c70fc4da2a 100644
d9d99f
--- a/grub-core/net/efi/net.c
d9d99f
+++ b/grub-core/net/efi/net.c
d9d99f
@@ -729,7 +729,7 @@ grub_efi_net_parse_address (const char *address,
d9d99f
 	{
d9d99f
 	  grub_uint32_t subnet_mask_size;
d9d99f
 
d9d99f
-	  subnet_mask_size = grub_strtoul (rest + 1, (char **) &rest, 0);
d9d99f
+	  subnet_mask_size = grub_strtoul (rest + 1, &rest, 0);
d9d99f
 
d9d99f
 	  if (!grub_errno && subnet_mask_size <= 32 && *rest == 0)
d9d99f
 	    {
d9d99f
@@ -758,7 +758,7 @@ grub_efi_net_parse_address (const char *address,
d9d99f
 	{
d9d99f
 	  grub_efi_uint8_t prefix_length;
d9d99f
 
d9d99f
-	  prefix_length = grub_strtoul (rest + 1, (char **) &rest, 0);
d9d99f
+	  prefix_length = grub_strtoul (rest + 1, &rest, 0);
d9d99f
 	  if (!grub_errno && prefix_length <= 128 && *rest == 0)
d9d99f
 	    {
d9d99f
 	      ip6->prefix_length = prefix_length;
d9d99f
diff --git a/grub-core/net/efi/pxe.c b/grub-core/net/efi/pxe.c
d9d99f
index 531949cba5c..73e2bb01c1b 100644
d9d99f
--- a/grub-core/net/efi/pxe.c
d9d99f
+++ b/grub-core/net/efi/pxe.c
d9d99f
@@ -187,7 +187,7 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest)
d9d99f
 	  ptr++;
d9d99f
 	  continue;
d9d99f
 	}
d9d99f
-      t = grub_strtoul (ptr, (char **) &ptr, 16);
d9d99f
+      t = grub_strtoul (ptr, &ptr, 16);
d9d99f
       if (grub_errno)
d9d99f
 	{
d9d99f
 	  grub_errno = GRUB_ERR_NONE;
d9d99f
@@ -225,7 +225,7 @@ pxe_open (struct grub_efi_net_device *dev,
d9d99f
 	  int type __attribute__((unused)))
d9d99f
 {
d9d99f
   int i;
d9d99f
-  char *p;
d9d99f
+  const char *p;
d9d99f
   grub_efi_status_t status;
d9d99f
   grub_efi_pxe_ip_address_t server_ip;
d9d99f
   grub_efi_uint64_t file_size = 0;
d9d99f
@@ -313,7 +313,7 @@ pxe_read (struct grub_efi_net_device *dev,
d9d99f
 	  grub_size_t len)
d9d99f
 {
d9d99f
   int i;
d9d99f
-  char *p;
d9d99f
+  const char *p;
d9d99f
   grub_efi_status_t status;
d9d99f
   grub_efi_pxe_t *pxe = (prefer_ip6) ? dev->ip6_pxe : dev->ip4_pxe;
d9d99f
   grub_efi_uint64_t bufsz = len;
d9d99f
diff --git a/grub-core/net/http.c b/grub-core/net/http.c
d9d99f
index c9c59690a98..b52b558d631 100644
d9d99f
--- a/grub-core/net/http.c
d9d99f
+++ b/grub-core/net/http.c
d9d99f
@@ -110,7 +110,7 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len)
d9d99f
 	  return GRUB_ERR_NONE;
d9d99f
 	}
d9d99f
       ptr += sizeof ("HTTP/1.1 ") - 1;
d9d99f
-      code = grub_strtoul (ptr, &ptr, 10);
d9d99f
+      code = grub_strtoul (ptr, (const char **)&ptr, 10);
d9d99f
       if (grub_errno)
d9d99f
 	return grub_errno;
d9d99f
       switch (code)
d9d99f
@@ -137,7 +137,7 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len)
d9d99f
       == 0 && !data->size_recv)
d9d99f
     {
d9d99f
       ptr += sizeof ("Content-Length: ") - 1;
d9d99f
-      file->size = grub_strtoull (ptr, &ptr, 10);
d9d99f
+      file->size = grub_strtoull (ptr, (const char **)&ptr, 10);
d9d99f
       data->size_recv = 1;
d9d99f
       return GRUB_ERR_NONE;
d9d99f
     }
d9d99f
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
d9d99f
index a571ee92efa..a011b940100 100644
d9d99f
--- a/grub-core/net/net.c
d9d99f
+++ b/grub-core/net/net.c
d9d99f
@@ -411,7 +411,7 @@ parse_ip (const char *val, grub_uint32_t *ip, const char **rest)
d9d99f
   for (i = 0; i < 4; i++)
d9d99f
     {
d9d99f
       unsigned long t;
d9d99f
-      t = grub_strtoul (ptr, (char **) &ptr, 0);
d9d99f
+      t = grub_strtoul (ptr, &ptr, 0);
d9d99f
       if (grub_errno)
d9d99f
 	{
d9d99f
 	  grub_errno = GRUB_ERR_NONE;
d9d99f
@@ -465,7 +465,7 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest)
d9d99f
 	  ptr++;
d9d99f
 	  continue;
d9d99f
 	}
d9d99f
-      t = grub_strtoul (ptr, (char **) &ptr, 16);
d9d99f
+      t = grub_strtoul (ptr, &ptr, 16);
d9d99f
       if (grub_errno)
d9d99f
 	{
d9d99f
 	  grub_errno = GRUB_ERR_NONE;
d9d99f
@@ -577,7 +577,7 @@ grub_net_resolve_net_address (const char *name,
d9d99f
       addr->type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
d9d99f
       if (*rest == '/')
d9d99f
 	{
d9d99f
-	  addr->ipv4.masksize = grub_strtoul (rest + 1, (char **) &rest, 0);
d9d99f
+	  addr->ipv4.masksize = grub_strtoul (rest + 1, &rest, 0);
d9d99f
 	  if (!grub_errno && *rest == 0)
d9d99f
 	    return GRUB_ERR_NONE;
d9d99f
 	  grub_errno = GRUB_ERR_NONE;
d9d99f
@@ -593,7 +593,7 @@ grub_net_resolve_net_address (const char *name,
d9d99f
       addr->type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
d9d99f
       if (*rest == '/')
d9d99f
 	{
d9d99f
-	  addr->ipv6.masksize = grub_strtoul (rest + 1, (char **) &rest, 0);
d9d99f
+	  addr->ipv6.masksize = grub_strtoul (rest + 1, &rest, 0);
d9d99f
 	  if (!grub_errno && *rest == 0)
d9d99f
 	    return GRUB_ERR_NONE;
d9d99f
 	  grub_errno = GRUB_ERR_NONE;
d9d99f
diff --git a/grub-core/net/url.c b/grub-core/net/url.c
d9d99f
index 146858284cd..d9d2fc9a9dc 100644
d9d99f
--- a/grub-core/net/url.c
d9d99f
+++ b/grub-core/net/url.c
d9d99f
@@ -235,7 +235,7 @@ extract_http_url_info (char *url, int ssl,
d9d99f
       c = *port_end;
d9d99f
       *port_end = '\0';
d9d99f
 
d9d99f
-      portul = grub_strtoul (port_off, &separator, 10);
d9d99f
+      portul = grub_strtoul (port_off, (const char **)&separator, 10);
d9d99f
       *port_end = c;
d9d99f
 #ifdef URL_TEST
d9d99f
       if (portul == ULONG_MAX && errno == ERANGE)
d9d99f
diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c
d9d99f
index 93965777138..7d327f59d92 100644
d9d99f
--- a/grub-core/script/execute.c
d9d99f
+++ b/grub-core/script/execute.c
d9d99f
@@ -146,7 +146,7 @@ replace_scope (struct grub_script_scope *new_scope)
d9d99f
 grub_err_t
d9d99f
 grub_script_break (grub_command_t cmd, int argc, char *argv[])
d9d99f
 {
d9d99f
-  char *p = 0;
d9d99f
+  const char *p = NULL;
d9d99f
   unsigned long count;
d9d99f
 
d9d99f
   if (argc == 0)
d9d99f
@@ -178,7 +178,7 @@ grub_err_t
d9d99f
 grub_script_shift (grub_command_t cmd __attribute__((unused)),
d9d99f
 		   int argc, char *argv[])
d9d99f
 {
d9d99f
-  char *p = 0;
d9d99f
+  const char *p = NULL;
d9d99f
   unsigned long n = 0;
d9d99f
 
d9d99f
   if (! scope)
d9d99f
@@ -239,7 +239,7 @@ grub_err_t
d9d99f
 grub_script_return (grub_command_t cmd __attribute__((unused)),
d9d99f
 		    int argc, char *argv[])
d9d99f
 {
d9d99f
-  char *p;
d9d99f
+  const char *p = NULL;
d9d99f
   unsigned long n;
d9d99f
 
d9d99f
   if (! scope || argc > 1)
d9d99f
diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c
d9d99f
index db80b3ba0fb..f9271b09239 100644
d9d99f
--- a/grub-core/term/serial.c
d9d99f
+++ b/grub-core/term/serial.c
d9d99f
@@ -269,7 +269,7 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args)
d9d99f
 
d9d99f
   if (state[OPTION_BASE_CLOCK].set)
d9d99f
     {
d9d99f
-      char *ptr;
d9d99f
+      const char *ptr;
d9d99f
       config.base_clock = grub_strtoull (state[OPTION_BASE_CLOCK].arg, &ptr, 0);
d9d99f
       if (grub_errno)
d9d99f
 	return grub_errno;
d9d99f
diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c
d9d99f
index 29df35e6d20..537a5c0cb0b 100644
d9d99f
--- a/grub-core/term/terminfo.c
d9d99f
+++ b/grub-core/term/terminfo.c
d9d99f
@@ -737,7 +737,7 @@ grub_cmd_terminfo (grub_extcmd_context_t ctxt, int argc, char **args)
d9d99f
 
d9d99f
   if (state[OPTION_GEOMETRY].set)
d9d99f
     {
d9d99f
-      char *ptr = state[OPTION_GEOMETRY].arg;
d9d99f
+      const char *ptr = state[OPTION_GEOMETRY].arg;
d9d99f
       w = grub_strtoul (ptr, &ptr, 0);
d9d99f
       if (grub_errno)
d9d99f
 	return grub_errno;
d9d99f
diff --git a/grub-core/tests/strtoull_test.c b/grub-core/tests/strtoull_test.c
d9d99f
index 7da615ff33e..5488ab26b43 100644
d9d99f
--- a/grub-core/tests/strtoull_test.c
d9d99f
+++ b/grub-core/tests/strtoull_test.c
d9d99f
@@ -25,7 +25,7 @@ static void
d9d99f
 strtoull_testcase (const char *input, int base, unsigned long long expected,
d9d99f
 		   int num_digits, grub_err_t error)
d9d99f
 {
d9d99f
-  char *output;
d9d99f
+  const char *output;
d9d99f
   unsigned long long value;
d9d99f
   grub_errno = 0;
d9d99f
   value = grub_strtoull(input, &output, base);
d9d99f
diff --git a/include/grub/misc.h b/include/grub/misc.h
d9d99f
index de9016ab709..1258ec6bbf3 100644
d9d99f
--- a/include/grub/misc.h
d9d99f
+++ b/include/grub/misc.h
d9d99f
@@ -288,11 +288,11 @@ grub_strncasecmp (const char *s1, const char *s2, grub_size_t n)
d9d99f
     - (int) grub_tolower ((grub_uint8_t) *s2);
d9d99f
 }
d9d99f
 
d9d99f
-unsigned long EXPORT_FUNC(grub_strtoul) (const char *str, char **end, int base);
d9d99f
-unsigned long long EXPORT_FUNC(grub_strtoull) (const char *str, char **end, int base);
d9d99f
+unsigned long EXPORT_FUNC(grub_strtoul) (const char *str, const char ** const end, int base);
d9d99f
+unsigned long long EXPORT_FUNC(grub_strtoull) (const char *str, const char ** const end, int base);
d9d99f
 
d9d99f
 static inline long
d9d99f
-grub_strtol (const char *str, char **end, int base)
d9d99f
+grub_strtol (const char *str, const char ** const end, int base)
d9d99f
 {
d9d99f
   int negative = 0;
d9d99f
   unsigned long long magnitude;