bug-gnulib
[Top][All Lists]
Advanced

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

Re: Warnings to be fixed


From: Jim Meyering
Subject: Re: Warnings to be fixed
Date: Thu, 16 Oct 2008 21:50:12 +0200

Paul Eggert <address@hidden> wrote:

> Jim Meyering <address@hidden> writes:
>
>>       mode = (sizeof (mode_t) < sizeof (int)
>>            ? va_arg (ap, int)
>>            : va_arg (ap, mode_t));    <<<============ line 43
>>
>> IMHO, adding casts here just to avoid that warning would be
>> counterproductive.
>
> I agree.  But would it turn your stomach to rewrite it this way?
> (I assume this would silence the warning.)  In general I don't like
> this kind of rewrite, but in this particular case it might be OK.
>
>   if (sizeof (mode_t) < sizeof (int))
>     mode = va_arg (ap, int);
>   else
>     mode = va_arg (ap, mode_t);

Nice work-around.
Ok for me to push this in your name?

>From 1b71c50d5a227649f1bcc11cf79e2be7ef68fff8 Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Thu, 16 Oct 2008 21:48:54 +0200
Subject: [PATCH] open-safer.c: avoid 'signed and unsigned in conditional...' 
warning

* lib/open-safer.c (open_safer): Use an "if/else" statement in place
of the ternary operator.  Reported by Reuben Thomas <address@hidden>.
---
 ChangeLog        |    6 ++++++
 lib/open-safer.c |    9 +++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0394202..5bd8819 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-10-16  Paul Eggert  <address@hidden>
+
+       open-safer.c: avoid 'signed and unsigned in conditional...' warning
+       * lib/open-safer.c (open_safer): Use an "if/else" statement in place
+       of the ternary operator.  Reported by Reuben Thomas <address@hidden>.
+
 2008-10-16  Jim Meyering  <address@hidden>

        openat-die.c: avoid 'no previous prototype' warning
diff --git a/lib/open-safer.c b/lib/open-safer.c
index ce493d5..15bf6a6 100644
--- a/lib/open-safer.c
+++ b/lib/open-safer.c
@@ -1,6 +1,6 @@
 /* Invoke open, but avoid some glitches.

-   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -38,9 +38,10 @@ open_safer (char const *file, int flags, ...)
       /* Assume mode_t promotes to int if and only if it is smaller.
         This assumption isn't guaranteed by the C standard, but we
         don't know of any real-world counterexamples.  */
-      mode = (sizeof (mode_t) < sizeof (int)
-             ? va_arg (ap, int)
-             : va_arg (ap, mode_t));
+      if (sizeof (mode_t) < sizeof (int))
+       mode = va_arg (ap, int);
+      else
+       mode = va_arg (ap, mode_t);

       va_end (ap);
     }
--
1.6.0.2.532.g84ed4c




reply via email to

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