Tidy bfd_scan_vma

Message ID ZZdqNRx6arVCTHTD@squeak.grove.modra.org
State New
Headers
Series Tidy bfd_scan_vma |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm warning Patch is already merged
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 warning Patch is already merged

Commit Message

Alan Modra Jan. 5, 2024, 2:32 a.m. UTC
  In commit 83c79df86bf4 I removed configure tests for strtoull among
other library functions part of C99, but didn't remove what is now
dead code.

	* bfd.c (bfd_scan_vma): Delete fall-back for strtoull.
  

Patch

diff --git a/bfd/bfd.c b/bfd/bfd.c
index c8e38b05c72..0776145af52 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -2257,86 +2257,21 @@  SYNOPSIS
 	bfd_vma bfd_scan_vma (const char *string, const char **end, int base);
 
 DESCRIPTION
-	Convert, like <<strtoul>>, a numerical expression
-	@var{string} into a <<bfd_vma>> integer, and return that integer.
-	(Though without as many bells and whistles as <<strtoul>>.)
-	The expression is assumed to be unsigned (i.e., positive).
-	If given a @var{base}, it is used as the base for conversion.
-	A base of 0 causes the function to interpret the string
-	in hex if a leading "0x" or "0X" is found, otherwise
-	in octal if a leading zero is found, otherwise in decimal.
-
-	If the value would overflow, the maximum <<bfd_vma>> value is
-	returned.
+	Convert, like <<strtoul>> or <<stdtoull> depending on the size
+	of a <<bfd_vma>>, a numerical expression @var{string} into a
+	<<bfd_vma>> integer, and return that integer.
 */
 
 bfd_vma
 bfd_scan_vma (const char *string, const char **end, int base)
 {
-  bfd_vma value;
-  bfd_vma cutoff;
-  unsigned int cutlim;
-  int overflow;
-
-  /* Let the host do it if possible.  */
   if (sizeof (bfd_vma) <= sizeof (unsigned long))
     return strtoul (string, (char **) end, base);
 
   if (sizeof (bfd_vma) <= sizeof (unsigned long long))
     return strtoull (string, (char **) end, base);
 
-  if (base == 0)
-    {
-      if (string[0] == '0')
-	{
-	  if ((string[1] == 'x') || (string[1] == 'X'))
-	    base = 16;
-	  else
-	    base = 8;
-	}
-    }
-
-  if ((base < 2) || (base > 36))
-    base = 10;
-
-  if (base == 16
-      && string[0] == '0'
-      && (string[1] == 'x' || string[1] == 'X')
-      && ISXDIGIT (string[2]))
-    {
-      string += 2;
-    }
-
-  cutoff = (~ (bfd_vma) 0) / (bfd_vma) base;
-  cutlim = (~ (bfd_vma) 0) % (bfd_vma) base;
-  value = 0;
-  overflow = 0;
-  while (1)
-    {
-      unsigned int digit;
-
-      digit = *string;
-      if (ISDIGIT (digit))
-	digit = digit - '0';
-      else if (ISALPHA (digit))
-	digit = TOUPPER (digit) - 'A' + 10;
-      else
-	break;
-      if (digit >= (unsigned int) base)
-	break;
-      if (value > cutoff || (value == cutoff && digit > cutlim))
-	overflow = 1;
-      value = value * base + digit;
-      ++string;
-    }
-
-  if (overflow)
-    value = ~ (bfd_vma) 0;
-
-  if (end != NULL)
-    *end = string;
-
-  return value;
+  abort ();
 }
 
 /*