-Wcast-qual Re: [PATCHES v4] Another round of FreeBSD developer build fixes

Volker Lendecke Volker.Lendecke at SerNet.DE
Sat Nov 25 13:24:30 UTC 2017


On Sat, Nov 25, 2017 at 02:02:43PM +0100, Volker Lendecke via samba-technical wrote:
> Genuine question: How do we deal with that properly? A
> standards-compliant way might be a memcpy to a variable on the stack,
> but this might be very inefficient for large structures. Also, for
> example in talloc.c we inevitably do some casting to structs. How is
> that possible in a portable manner that does not generate warnings?

Just because it's fun to try: http://orchistro.tistory.com/206 has

__asm__("pushf\norl $0x40000, (%rsp)\npopf");

which makes talloc_strdup on my 64-bit debian stretch immediately
sigbus in memcpy:

#0  __memmove_avx_unaligned_erms ()
    at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:306
#1  0x00007ffff5ceed16 in __talloc_strlendup (t=0x55555583a260,
    p=0x7ffff4adaaa0 "all", len=3) at ../lib/talloc/talloc.c:2372
#2  0x00007ffff5ceec89 in talloc_strdup (t=0x55555583a260,
    p=0x7ffff4adaaa0 "all") at ../lib/talloc/talloc.c:2385
#3  0x00007ffff4ad82f1 in debug_add_class (classname=0x7ffff4adaaa0 "all")
    at ../lib/util/debug.c:706
#4  0x00007ffff4ad838d in debug_init () at ../lib/util/debug.c:864
#5  0x00007ffff4ad9384 in setup_logging (
    prog_name=0x5555555dcb4f "smbtorture", new_logtype=DEBUG_STDOUT)
    at ../lib/util/debug.c:922
#6  0x0000555555574124 in main (argc=3, argv=0x7fffffffe478)
    at ../source3/torture/torture.c:11703

So there would be quite some work to fix the real problems that this
warning might point out :-)

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de



More information about the samba-technical mailing list