Re: [PATCH] Fix warnings from gcc 4.1.1

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

 




On Sat, 8 Jul 2006, Pavel Roskin wrote:
> 
> These warnings are reported for every file:
> lib.h: In function 'add_symbol':
> lib.h:171: warning: value computed is not used

Please send a bug-report to the gcc people instead.

The code is correct, and the warning is bogus.

> That's the way new versions of gcc warn about values that are cast to a
> type but not used.

Yeah, and it's crap. The cast exists because we don't want to lose the 
type knowledge. Removing the cast would be wrong.

The fact that gcc warns about 

	(cast) a;

but does not warn about

	a;

is a sign of a gcc _bug_, and total insanity. The value is equally ignored 
in both cases.

> The cast in add_ptr_list_tag() is not really needed.  Its return value
> is used only in one place (add_pseudo) where it's converted to (void *)
> anyway.

Actually, _that_ is a bug.

The whole point of the cast is to not use a "void *", when we actually 
know exactly what kind of pointer the result is, and we want to do proper 
type-checking.

For example, when you do an "add_pseudo()", the return value should be a 
pointer to a pseudo_t.

So the declaration for "add_pseudo()" should be

	static inline pseudo_t *add_pseudo(struct pseudo_list **list, pseudo_t pseudo)

and we should never have cast it to "void *" since we know damn well what 
the result should be.

		Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux