From patchwork Tue Oct 9 17:24:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 981423 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42V3zK5NHDz9s9J for ; Wed, 10 Oct 2018 04:25:48 +1100 (AEDT) Received: from localhost ([::1]:53053 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g9vlR-0004fm-1U for incoming@patchwork.ozlabs.org; Tue, 09 Oct 2018 13:25:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g9vkp-0004cf-Pg for qemu-devel@nongnu.org; Tue, 09 Oct 2018 13:25:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g9vkp-00054x-34 for qemu-devel@nongnu.org; Tue, 09 Oct 2018 13:25:07 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:51720) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g9vko-00053d-QM; Tue, 09 Oct 2018 13:25:06 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1g9vkm-00053i-Bf; Tue, 09 Oct 2018 18:25:04 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 9 Oct 2018 18:24:58 +0100 Message-Id: <20181009172501.17353-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH 0/3] block/qcow*: Don't take address of fields in packed structs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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. There are a few places in the affected files where the in-place swap function is used on something other than a packed struct field; we convert those anyway, for consistency. Patches produced mechanically using spatch; in one case I also did a little hand-editing to wrap overlong lines that checkpatch would otherwise complain about. (clang also complains about other files in block: vdi.c, vpc.c, vhdx.h, vhdx.c, vhdx-endian.c, vhdx-log.c -- I may produce patches for those later if nobody else gets there first.) thanks -- PMM Peter Maydell (3): block/qcow2: Don't take address of fields in packed structs block/qcow: Don't take address of fields in packed structs block/qcow2-bitmap: Don't take address of fields in packed structs block/qcow.c | 18 ++++++------- block/qcow2-bitmap.c | 24 ++++++++--------- block/qcow2.c | 64 +++++++++++++++++++++++--------------------- 3 files changed, 55 insertions(+), 51 deletions(-) Reviewed-by: Richard Henderson Tested-by: John Snow Reviewed-by: John Snow