qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] hw/scsi/mptendian: Avoid taking address of fiel


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] hw/scsi/mptendian: Avoid taking address of fields in packed structs
Date: Fri, 28 Sep 2018 13:38:25 +0100

On 28 September 2018 at 13:04, Philippe Mathieu-Daudé <address@hidden> wrote:
> Hi Peter,
>
> On 27/09/2018 15:48, Peter Maydell wrote:
>> Taking the address of a field in a packed struct is a bad idea, because
>> it might not be actually aligned enough for that pointer type (and
>> thus cause a crash on dereference on some host architectures). Newer
>> versions of clang warn about this. Avoid the bug by not using the
>> "modify in place" byte swapping functions.
>
> The goal of this cleanup is to eventually get rid of the X_to_cpus() and
> cpu_to_Xs()? Or uniquely when the field belong to a packed struct?

The goal of the cleanup is to fix the warnings. I suspect when
we've finished doing that we'll find there are very few
uses of the in-place conversion functions remaining, so maybe
we'll want to get rid of the rest just to reduce the number
of byte-swapping APIs we'll have -- but that's something we
can think about when we get there.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]