bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: arpg-help: Warning with NetBSD and amd64.


From: Paul Eggert
Subject: Re: arpg-help: Warning with NetBSD and amd64.
Date: Sat, 03 Dec 2011 09:28:36 -0800
User-agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111124 Thunderbird/8.0

On 12/03/11 07:35, Mats Erik Andersson wrote:
> argp-help.c:467: warning: comparison is always true due to limited range of 
> data type

Thanks, but in general we ignore warnings like that,
since they're almost always (as in this case) false alarms
when they appear in gnulib code.

Come to think of it, we can simplify the code in question
(at the cost of possibly generating more of these bogus warnings,
which is OK) like this:

diff --git a/lib/argp-help.c b/lib/argp-help.c
index ec7fcda..97557ea 100644
--- a/lib/argp-help.c
+++ b/lib/argp-help.c
@@ -463,8 +463,7 @@ make_hol (const struct argp *argp, struct hol_cluster 
*cluster)
       hol->short_options = malloc (num_short_options + 1);
 
       assert (hol->entries && hol->short_options);
-      if (SIZE_MAX <= UINT_MAX)
-        assert (hol->num_entries <= SIZE_MAX / sizeof (struct hol_entry));
+      assert (hol->num_entries <= SIZE_MAX / sizeof (struct hol_entry));
 
       /* Fill in the entries.  */
       so = hol->short_options;
@@ -879,8 +878,7 @@ hol_append (struct hol *hol, struct hol *more)
             malloc (hol_so_len + strlen (more->short_options) + 1);
 
           assert (entries && short_options);
-          if (SIZE_MAX <= UINT_MAX)
-            assert (num_entries <= SIZE_MAX / sizeof (struct hol_entry));
+          assert (num_entries <= SIZE_MAX / sizeof (struct hol_entry));
 
           __mempcpy (__mempcpy (entries, hol->entries,
                                 hol->num_entries * sizeof (struct hol_entry)),



reply via email to

[Prev in Thread] Current Thread [Next in Thread]