From nobody Mon Feb 9 12:11:14 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1629580390; cv=none; d=zohomail.com; s=zohoarc; b=XbwKmU0IOWIcqNapyxllk08vgpM5/3w+EYyF643IXstabIdh8D6yfuAOhwPH2f5T33ZlD1ZLIL23bvN2cYdNKLZznOW4FaPo3NkJsSgc4tYnoalov1efARQyIXR5SwrBLDz2dY2J56Z1jaiZrF0cdvNdMpoY/2syKJ3b7AjbukA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629580390; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=5ZVZyj3YzMwTNDGFgyv9k2EPVfxtHmOdwi1p8mZRfZ0=; b=AQLI94zfbO+wL3HqIGhYnBOqtakfe0VWID3at/bS+v/rMBdPoHy3lz5FcqU4GFTQcbcpM3KjvUcqKr7ceOl0kEBJU529Bn4TAUnkkvU6YbodTySi/6nAbkAjEnKZ8nqRDdGeqpKyAY9GJGi8idQo5lcmouwqLprR6V0MBxKIxlw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629580390460907.9795050631832; Sat, 21 Aug 2021 14:13:10 -0700 (PDT) Received: from localhost ([::1]:58616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHYIf-0002CW-Eq for importer@patchew.org; Sat, 21 Aug 2021 17:13:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHYHN-0000B2-Ha for qemu-devel@nongnu.org; Sat, 21 Aug 2021 17:11:49 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:52949) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHYHJ-0001b8-7n for qemu-devel@nongnu.org; Sat, 21 Aug 2021 17:11:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=5ZVZyj3YzMwTNDGFgyv9k2EPVfxtHmOdwi1p8mZRfZ0=; b=SF/Ks Pnmj08oJmdChuHRSKvqiqWlzWTwoDx06Is2aSeWV293HghprW4IG4Md1Z2Zz8/c0BvAp3pMsu+bwW 0UTwRqJmyCr8bJ21ppcF0A6ZCEx/HK1A7Jvi1h5W9Lxuv5n4kU3sFhaXFBMNrqmm5q3udLgSqE5Ad 2xErHHTW++2bhE31yI6nlcOGzemjSKhdegXTZuZK+CpIGqW8cVOxocjPAiKpMDxHwlpDg+uzWxC27 f5k9hPJAL55YTyQXcqDjB9g9R8KzmWFGl/i5054HMchfsIYbAdb3iZfw7slOJSIFNkUkhY8gk7nBx rhzpqa0RHjV7dI2D8yzilteMVmzmw==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 21 Aug 2021 22:30:49 +0200 Subject: [PATCH 2/5] qemu/qarray.h: weak scalar type check in QARRAY_CREATE() To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=a3f07198ba9e12b45ef38b45fa543e9b597ee70f@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1629580392975100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Unfortunately something like _Static_assert(typeof(a) =3D=3D typeof(b), "type mismatch"); is currently not suported by C. So for the time being at least check that the size of the scalar types match at compile time. Signed-off-by: Christian Schoenebeck --- include/qemu/qarray.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/qemu/qarray.h b/include/qemu/qarray.h index 230a556e81..2cb8656c5d 100644 --- a/include/qemu/qarray.h +++ b/include/qemu/qarray.h @@ -27,6 +27,8 @@ #ifndef QEMU_QARRAY_H #define QEMU_QARRAY_H =20 +#include "qemu/compiler.h" + /** * QArray provides a mechanism to access arrays in common C-style (e.g. by * square bracket [] operator) in conjunction with reference variables that @@ -143,6 +145,10 @@ * @param len - amount of array elements to be allocated immediately */ #define QARRAY_CREATE(scalar_type, auto_var, len) \ + QEMU_BUILD_BUG_MSG( \ + sizeof(scalar_type) !=3D sizeof(*auto_var), \ + "QArray scalar type mismatch" \ + ); \ qarray_create_##scalar_type((&auto_var), len) =20 #endif /* QEMU_QARRAY_H */ --=20 2.20.1