Re: Where are the specific WARNS=n defined?

2011-08-23 Thread Iain Hibbert
On Tue, 23 Aug 2011, Mouse wrote:

  [...] gcc errors due to comparison of signed and unsigned values.

  It is best to fix the errors.

 What errors?

 It is not necessarily an error to compare signed and unsigned values.
 In my experience, that warning produces so many more false positives
 than useful warnings that I normally shut it off entirely.

and that one time that using it might have warned you about a serious
vulnerability?

the compiler is producing a warning that something you did may be unsafe..
since you are cleverer than the compiler, it is simple for you to examine
it and tell the compiler that it is ok, by using a cast or the appropriate
type.

iain


Re: Where are the specific WARNS=n defined?

2011-08-23 Thread Christos Zoulas
In article 201108230521.baa12...@sparkle.rodents-montreal.org,
Mouse  mo...@rodents-montreal.org wrote:
 [...] gcc errors due to comparison of signed and unsigned values.

 It is best to fix the errors.

What errors?

It is not necessarily an error to compare signed and unsigned values.
In my experience, that warning produces so many more false positives
than useful warnings that I normally shut it off entirely.

And it is not an error to put assignments in conditionals, or not
place parentheses to clarify operator precedence, etc. It is a
warning; the compiler is telling you that it is unclear what you
are trying to do, and you should check to make sure that this is
what you want to do (and let the compiler know by making your
intentions clear). For some of us this is helpful. The compiler
writers try to help protect programmers against common mistakes.
If you don't like the warnings you are free to turn them off.

christos



Re: Where are the specific WARNS=n defined?

2011-08-23 Thread Mouse
 [...] gcc errors due to comparison of signed and unsigned values.
 It is best to fix the errors.
 In my experience, that warning produces so many more false positives
 than useful warnings that I normally shut it off entirely.
 and that one time that using it might have warned you about a serious
 vulnerability?

When was that?

Except for a few that also provoked, or would have provoked, the
warning about how a conditional's value is constant due to limited
range of data type, I can't recall ever finding a bug that
-Wsign-compare warned about (or would have warned about).

Ever.

In anyone's code.

Yes, it's possible there is such an occasion lurking in my future.
It's also possible I've forgotten about one in the past.  But I judge
the expected cost of possibly having to track down such a bug directly
to be well below the expected cost (both immediate and in down-the-road
maintenance) of pervasive manual uglification of code to fix
non-errors.

/~\ The ASCII Mouse
\ / Ribbon Campaign
 X  Against HTMLmo...@rodents-montreal.org
/ \ Email!   7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Re: Where are the specific WARNS=n defined?

2011-08-23 Thread Mouse
 It is not necessarily an error to compare signed and unsigned
 values.  [...]
 And it is not an error to put assignments in conditionals, or not
 place parentheses to clarify operator precedence, etc.  It is a
 warning [...].  For some of us this is helpful.  The compiler writers
 try to help protect programmers against common mistakes.  If you
 don't like the warnings you are free to turn them off.

That's what I do - along with a handful of other such warnings.

The question asked what the appropriate action was, whether to turn the
warnings off (the way real kernel compiles apparently do anyway) or
uglify the code to work around the warning [ok, my phrasing].  I
believe the former is better, because in my experience the mistake the
warning warns about is anything but common.

/~\ The ASCII Mouse
\ / Ribbon Campaign
 X  Against HTMLmo...@rodents-montreal.org
/ \ Email!   7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Re: Where are the specific WARNS=n defined?

2011-08-23 Thread David Holland
On Tue, Aug 23, 2011 at 03:11:27AM -0400, Mouse wrote:
   [...] gcc errors due to comparison of signed and unsigned values.
   It is best to fix the errors.
   In my experience, that warning produces so many more false positives
   than useful warnings that I normally shut it off entirely.
   and that one time that using it might have warned you about a serious
   vulnerability?
  
  When was that?
  
  Except for a few that also provoked, or would have provoked, the
  warning about how a conditional's value is constant due to limited
  range of data type, I can't recall ever finding a bug that
  -Wsign-compare warned about (or would have warned about).
  
  Ever.
  
  In anyone's code.

The most recent one I ran into (that's easily documentable and had
clear adverse consequences) was PR 43413.

Just FWIW.

-- 
David A. Holland
dholl...@netbsd.org


Re: Where are the specific WARNS=n defined?

2011-08-23 Thread Paul Goyette

On Tue, 23 Aug 2011, Christos Zoulas wrote:


I'm trying to modularize a couple of drivers, and one of them is
generating some gcc errors due to comparison of signed and unsigned
values.

The driver module is currently being compiled with WARNS=4 (just picked
that up from another Makefile).  Is there a more appropriate WARNS=n to
use to permit the comparison?  Or should I simply add

CCOPTS+= -Wno-sign-compare

(which is used when the driver is being compiled as part of a kernel)?


It is best to fix the errors.


Yeah, OK!   :)

Fixing, will commit shortly.



-
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:   |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com|
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |  | pgoyette at netbsd.org  |
-


Where are the specific WARNS=n defined?

2011-08-22 Thread Paul Goyette
I'm trying to modularize a couple of drivers, and one of them is 
generating some gcc errors due to comparison of signed and unsigned 
values.


The driver module is currently being compiled with WARNS=4 (just picked 
that up from another Makefile).  Is there a more appropriate WARNS=n to 
use to permit the comparison?  Or should I simply add


CCOPTS+= -Wno-sign-compare

(which is used when the driver is being compiled as part of a kernel)?



-
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:   |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com|
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |  | pgoyette at netbsd.org  |
-


Re: Where are the specific WARNS=n defined?

2011-08-22 Thread Christos Zoulas
In article pine.neb.4.64.1108222146340.22...@screamer.whooppee.com,
Paul Goyette  p...@whooppee.com wrote:
I'm trying to modularize a couple of drivers, and one of them is 
generating some gcc errors due to comparison of signed and unsigned 
values.

The driver module is currently being compiled with WARNS=4 (just picked 
that up from another Makefile).  Is there a more appropriate WARNS=n to 
use to permit the comparison?  Or should I simply add

   CCOPTS+= -Wno-sign-compare

(which is used when the driver is being compiled as part of a kernel)?

It is best to fix the errors.

christos



Re: Where are the specific WARNS=n defined?

2011-08-22 Thread Mouse
 [...] gcc errors due to comparison of signed and unsigned values.

 It is best to fix the errors.

What errors?

It is not necessarily an error to compare signed and unsigned values.
In my experience, that warning produces so many more false positives
than useful warnings that I normally shut it off entirely.

/~\ The ASCII Mouse
\ / Ribbon Campaign
 X  Against HTMLmo...@rodents-montreal.org
/ \ Email!   7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B