]> Savannah Git Hosting - gnulib.git/commitdiff
vasnprintf, c-vasnprintf: Silence gcc warnings.
authorBruno Haible <bruno@clisp.org>
Thu, 18 May 2023 20:51:17 +0000 (22:51 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 18 May 2023 20:59:25 +0000 (22:59 +0200)
* lib/vasnprintf.c (scale10_round_decimal_decoded): Remove memory==NULL
test.
(scale10_round_decimal_long_double, scale10_round_decimal_double): Test
for memory==NULL here. Remove use of IF_LINT.

ChangeLog
lib/vasnprintf.c

index 1796c625ee65333752e6dd718426b919ac4dd609..ee9a35da35598b7fe0315a2db33fc140e312a63b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-05-18  Bruno Haible  <bruno@clisp.org>
+
+       vasnprintf, c-vasnprintf: Silence gcc warnings.
+       * lib/vasnprintf.c (scale10_round_decimal_decoded): Remove memory==NULL
+       test.
+       (scale10_round_decimal_long_double, scale10_round_decimal_double): Test
+       for memory==NULL here. Remove use of IF_LINT.
+
 2023-05-18  Bruno Haible  <bruno@clisp.org>
 
        bitset: Silence gcc warning.
index 802790e14e4734a80c4baf8f2ed93a5f0c73fca6..007d28098052d0dc17586baa6aaca0b89220d55e 100644 (file)
@@ -1177,8 +1177,6 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
   void *z_memory;
   char *digits;
 
-  if (memory == NULL)
-    return NULL;
   /* x = 2^e * m, hence
      y = round (2^e * 10^n * m) = round (2^(e+n) * 5^n * m)
        = round (2^s * 5^n * m).  */
@@ -1386,10 +1384,13 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
 static char *
 scale10_round_decimal_long_double (long double x, int n)
 {
-  int e IF_LINT(= 0);
+  int e;
   mpn_t m;
   void *memory = decode_long_double (x, &e, &m);
-  return scale10_round_decimal_decoded (e, m, memory, n);
+  if (memory != NULL)
+    return scale10_round_decimal_decoded (e, m, memory, n);
+  else
+    return NULL;
 }
 
 # endif
@@ -1404,10 +1405,13 @@ scale10_round_decimal_long_double (long double x, int n)
 static char *
 scale10_round_decimal_double (double x, int n)
 {
-  int e IF_LINT(= 0);
+  int e;
   mpn_t m;
   void *memory = decode_double (x, &e, &m);
-  return scale10_round_decimal_decoded (e, m, memory, n);
+  if (memory != NULL)
+    return scale10_round_decimal_decoded (e, m, memory, n);
+  else
+    return NULL;
 }
 
 # endif