[Spice-devel] [PATCH v2 2/2] Avoid clang warnings on casts with stricter alignment requirements

Christophe Fergeau cfergeau at redhat.com
Tue May 23 09:51:01 UTC 2017


On Thu, May 18, 2017 at 03:24:41PM +0200, Christophe de Dinechin wrote:
> > 
> >> @@ -140,6 +140,41 @@ size_t spice_strnlen(const char *str, size_t max_len);
> >> 
> >> #endif
> >> 
> >> +/* Cast to a type with stricter alignment constraints (to build with clang)
> >> */
> >> +extern void spice_alignment_warning(const char *loc, void *p, unsigned sz);
> >> +extern void spice_alignment_debug(const char *loc, void *p, unsigned sz);
> >> +
> >> +static inline  void *spice_alignment_check(const char *loc,
> >> +                                           void *ptr, unsigned sz)
> >> +{
> >> +#ifndef NDEBUG
> > 
> > I like the debug idea but I think that currently NDEBUG is never defined.
> 
> I read that package maintainers often build the released version by
> doing ./configure CFLAGS=-DNDEBUG, and that it’s considered “principle
> of least surprise” to use NDEBUG rather than something
> package-specific for that purpose.
> 
> That being said, I checked our .spec file, and I don’t see NDEBUG
> being set in there. That would be the logical next step.

I only see -DNDEBUG being defined for cmake builds in rpm --showrc, and
none of my 250 spec files have a -DNDEBUG in them, so I would not expect
this to be set. I think we have SPICE_DEBUG already which might make
sense, another alternative would be to have a --enable-alignment-debug,
or something like glib (SPICE_XXX_DEBUG=alignment:foo:bar)

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170523/f0205c7b/attachment.sig>


More information about the Spice-devel mailing list