From: Michal Jaegermann <michal@ellpspace.math.ualberta.ca>
To: axp-list@redhat.com
Subject: Re: [PATCH] eliminate compile warnings
Date: Fri, 8 Nov 2002 17:42:29 -0700 [thread overview]
Message-ID: <20021108174229.B5518@ellpspace.math.ualberta.ca> (raw)
In-Reply-To: <20021108215056.C18411@Marvin.DL8BCU.ampr.org>; from dl8bcu@dl8bcu.de on Fri, Nov 08, 2002 at 09:50:56PM +0000
On Fri, Nov 08, 2002 at 09:50:56PM +0000, Thorsten Kranzkowski wrote: > > if you will try to _reduce_ number of casts by making sure that types of
> > objects agree, if only possible, instead of sprinkling code with extra
>
> I've actually done that.
You mean in a version you are working on now? There was quite
a few extra casts in what I have seen. Some of them appeared
"obviously correct" but this was not the case for others.
> > But if you want a unsigned constant with all bits on then ~0UL is surely
> > preferable over casting (-1) to unsigned long; even if just for clarity.
>
> ok, what do you suggest when there's a
> return ( x ? 0 : -ENOMEM )
> in a function declared as unsigned long ?
I noticed this in a patch for setup.c:
- if (bootmap_start == -1) {
+ if (bootmap_start == (unsigned long)-1L) {
What I meant that it seems that you really wanted here
if (bootmap_start == ~0UL) {
I did not check if there are other spots of that sort.
If you refer to what displeased Richard then if a return value from
arch_get_unmapped_area_1() is abused to return also an error code of
'int' type then a cast to (unsigned long), i.e. to what is returned but
not to (unsigned), on -ENOMEM could be the only sane way out. If
-ENOMEM is really an 'int' constant then likey you could get away with
'if ((int)addr != -ENOMEM)' but this is abusing what we know about
expected bit patters which can result from a call to
arch_get_unmapped_area_1() and I do not think that taking such risks is
a correct way to do it.
Michal
next prev parent reply other threads:[~2002-11-09 0:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-06 21:47 [PATCH] eliminate compile warnings Thorsten Kranzkowski
2002-11-07 14:22 ` George France
2002-11-07 17:17 ` Ted Goodridge
2002-11-07 19:59 ` George France
2002-11-07 20:28 ` Thorsten Kranzkowski
2002-11-07 20:55 ` George France
2002-11-08 1:33 ` Richard Henderson
2002-11-08 2:54 ` George France
2002-11-08 3:25 ` Richard Henderson
2002-11-08 4:04 ` George France
2002-11-08 7:38 ` Thorsten Kranzkowski
2002-11-08 17:28 ` Michal Jaegermann
2002-11-08 21:50 ` Thorsten Kranzkowski
2002-11-09 0:42 ` Michal Jaegermann [this message]
2002-11-09 1:32 ` Thorsten Kranzkowski
[not found] ` <3DCA9A88.4060109@pobox.com>
2002-11-07 21:43 ` Thorsten Kranzkowski
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox