[Committed] : scratch_buffer: Suppress truncation warning on 32-bit
diff mbox

Message ID 5526978F.60300@redhat.com
State New
Headers show

Commit Message

Florian Weimer April 9, 2015, 3:15 p.m. UTC
Committed as obvious.

Comments

Paul Eggert April 9, 2015, 3:39 p.m. UTC | #1
Florian Weimer wrote:
>   	      && unchanged_array_size (&buf, 1ULL << 16, 0)
>   	      && unchanged_array_size (&buf, 0, 1ULL << 16)
> -	      && unchanged_array_size (&buf, 1ULL << 32, 0)
> -	      && unchanged_array_size (&buf, 0, 1ULL << 32)))
> +	      && unchanged_array_size (&buf, (size_t) (1ULL << 32), 0)
> +	      && unchanged_array_size (&buf, 0, (size_t) (1ULL << 32))))

A small point: it's better to avoid suffixes like "ULL" when it's easy, which is 
the case here.  The above can be written as:

               && unchanged_array_size (&buf, 1 << 16, 0)
               && unchanged_array_size (&buf, 0, 1 << 16)
               && unchanged_array_size (&buf, (size_t) 1 << 31 << 1, 0)
               && unchanged_array_size (&buf, 0, (size_t) 1 << 31 << 1)))

Patch
diff mbox

From 2902af1631c0c74c2f0c0edd7a85a523370e5027 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Thu, 9 Apr 2015 17:12:42 +0200
Subject: [PATCH] scratch_buffer: Suppress truncation warning on 32-bit

---
 ChangeLog                   | 5 +++++
 malloc/tst-scratch_buffer.c | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d84b3db..30dc4da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@ 
+2015-04-09  Florian Weimer  <fweimer@redhat.com>
+
+	* malloc/tst-scratch_buffer.c (do_test): Suppress truncation
+	warning on 32-bit.
+
 2015-04-08  David S. Miller  <davem@davemloft.net>
 
 	* sysdeps/sparc/fpu/libm-test-ulps: Update.
diff --git a/malloc/tst-scratch_buffer.c b/malloc/tst-scratch_buffer.c
index dcae512..614b9b8 100644
--- a/malloc/tst-scratch_buffer.c
+++ b/malloc/tst-scratch_buffer.c
@@ -130,8 +130,8 @@  do_test (void)
 	      && unchanged_array_size (&buf, 0, -1)
 	      && unchanged_array_size (&buf, 1ULL << 16, 0)
 	      && unchanged_array_size (&buf, 0, 1ULL << 16)
-	      && unchanged_array_size (&buf, 1ULL << 32, 0)
-	      && unchanged_array_size (&buf, 0, 1ULL << 32)))
+	      && unchanged_array_size (&buf, (size_t) (1ULL << 32), 0)
+	      && unchanged_array_size (&buf, 0, (size_t) (1ULL << 32))))
 	  return 1;
 	if (!scratch_buffer_grow (&buf))
 	  {
-- 
2.1.0