From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: Disable -Werror when error attribute generates warnings
Date: Sat, 02 Jan 2010 19:21:21 +0100 [thread overview]
Message-ID: <4B3F8EA1.7020106@gmail.com> (raw)
In-Reply-To: <20100102153738.GX5847@riva.ucam.org>
[-- Attachment #1: Type: text/plain, Size: 2714 bytes --]
> =20
>> With an older version of gcc that does not understand the error =20
>> attribute, gcc generates warnings when compiling files that include =20
>> include/grub/list.h. Since TARGET_CFLAGS contains -Werror by default,=
=20
>> the build of modules fails.
>>
>> The following patch checks whether the C compiler supports the error =
>> attribute without warning, and disables -Werror if that is not the cas=
e =20
>> (as otherwise the build will fail).
>> =20
>
> Instead of this, why not only use the attribute if it's available? I
> couldn't find an entry about it in GCC's human-readable change
> summaries, but support was committed on 2007-09-23 so I think it's
> available from GCC 4.3.
>
> =20
Why not have configure.ac check specifically if this attribute is
available and use it only if it is?
> I use this GNUC_PREREQ approach in other projects and rather like it. I=
t
> could be extended to cover our other uses of attributes quite easily.
>
> 2010-01-02 Colin Watson <cjwatson@ubuntu.com>
>
> * include/grub/misc.h (GNUC_PREREQ): New macro.
> (ATTRIBUTE_ERROR): New macro.
> * include/grub/list.h (grub_bad_type_cast_real): Use
> ATTRIBUTE_ERROR.
>
> =3D=3D=3D modified file 'include/grub/list.h'
> --- include/grub/list.h 2009-12-31 14:03:09 +0000
> +++ include/grub/list.h 2010-01-02 15:31:44 +0000
> @@ -42,7 +42,7 @@ void EXPORT_FUNC(grub_list_insert) (grub
> =20
> static inline void *
> grub_bad_type_cast_real (int line, const char *file)
> - __attribute__ ((error ("bad type cast between incompatible grub t=
ypes")));
> + ATTRIBUTE_ERROR ("bad type cast between incompatible grub types")=
;
> =20
> static inline void *
> grub_bad_type_cast_real (int line, const char *file)
>
> =3D=3D=3D modified file 'include/grub/misc.h'
> --- include/grub/misc.h 2009-12-18 02:57:32 +0000
> +++ include/grub/misc.h 2010-01-02 15:31:31 +0000
> @@ -25,6 +25,22 @@
> #include <grub/symbol.h>
> #include <grub/err.h>
> =20
> +/* GCC version checking borrowed from glibc. */
> +#if defined(__GNUC__) && defined(__GNUC_MINOR__)
> +# define GNUC_PREREQ(maj,min) \
> + ((__GNUC__ << 16) + __GNUC_MINOR__ >=3D ((maj) << 16) + (min))
> +#else
> +# define GNUC_PREREQ(maj,min) 0
> +#endif
> +
> +/* Does this compiler support compile-time error attributes? */
> +#if GNUC_PREREQ(4,3)
> +# define ATTRIBUTE_ERROR(msg) \
> + __attribute__ ((__error__ (msg)))
> +#else
> +# define ATTRIBUTE_ERROR(msg)
> +#endif
> +
> #define ALIGN_UP(addr, align) \
> ((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1))
> #define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
>
> =20
--=20
Regards
Vladimir '=CF=86-coder/phcoder' Serbinenko
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 293 bytes --]
next prev parent reply other threads:[~2010-01-02 18:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-02 12:58 Disable -Werror when error attribute generates warnings Grégoire Sutre
2010-01-02 15:37 ` Colin Watson
2010-01-02 18:05 ` Grégoire Sutre
2010-01-02 18:21 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2010-01-03 16:47 ` Robert Millan
2010-01-03 21:48 ` Colin Watson
2010-01-03 16:46 ` Robert Millan
2010-01-03 21:55 ` Colin Watson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B3F8EA1.7020106@gmail.com \
--to=phcoder@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.