From nobody Sun Dec 14 03:25:07 2025 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=1629639271; cv=none; d=zohomail.com; s=zohoarc; b=ET65k/2180678+oBQ1wKZe14TGQ/TfaXKJ/vIEa6K0qBAl6kFGL60vcwlm/TOgNUAwEwtcCwzTrSvM3OvLyS6LJNihBxGNtvpxptRRtre9b3du+g+HEtQkj8+NkG5TqOCstEOlbU7k3Ezvt0bosyBwJx7ZGQVdNl9ug6I+iSLJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629639271; 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=kSpyee820uqQz+yU57xOxLjJAmEZwnGIMzUGc3CBYLk=; b=kMOQmJ4Y9KvdHDTxWkkOQ5IkDVgsECAqXQuJU9NB+bw5RWEXd3msBop1mAT2jAgr0ns/j5bpyBR22cmBbvFBvXB/wFEJ9R9NnPiMHGf1bqO+WACo0uJXevOl9B7IwuMbs0aL4WOdtOEmHyYutsmIIweLU8TGPyKXyRYzqKz/0xY= 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 1629639271158476.28966848841424; Sun, 22 Aug 2021 06:34:31 -0700 (PDT) Received: from localhost ([::1]:40958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHncM-0002CS-4J for importer@patchew.org; Sun, 22 Aug 2021 09:34:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <77d96c7e87c5f25e1e42319131f4d21ec646eb32@lizzy.crudebyte.com>) id 1mHnYg-0003L5-5Q for qemu-devel@nongnu.org; Sun, 22 Aug 2021 09:30:43 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:47877) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <77d96c7e87c5f25e1e42319131f4d21ec646eb32@lizzy.crudebyte.com>) id 1mHnYe-0001Cs-Pa for qemu-devel@nongnu.org; Sun, 22 Aug 2021 09:30:41 -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=kSpyee820uqQz+yU57xOxLjJAmEZwnGIMzUGc3CBYLk=; b=a0YsX gW6xZ8x1I6dl3GN7c65KBKzNwA/TUf0hYWK0sv3JApOddm8fwiQup48uGElKhTIgAc1Ay6y3yAWeb tGzMJLNRZxxUyCuS37oCiS+dnOlFy7h/sqNM9HgkeK7OfKY0o12SmFVcchMDGrjPoLavOFTXjUfyP pBqg4f69E32mL15bxFtIkfkuhc0d8mAe6F99EG4mzdKITPM+LuQ/9nBc3vkhtfggUAkIYKZyUcL0o ndsApLV36uH5yv3LWh83ZM0uOQ8C03Ifo5rh3QBeAdY8J+uSQMEZ7Jfyaos9OcUG6eTGIWWcOnNvg b9PYZpKuiJ2S1xldjL6icxdfAEHcA==; Message-Id: <77d96c7e87c5f25e1e42319131f4d21ec646eb32.1629638507.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 22 Aug 2021 15:17:00 +0200 Subject: [PATCH v2 2/5] qemu/qarray.h: check scalar type in QARRAY_CREATE() To: qemu-devel@nongnu.org Cc: Greg Kurz , Richard Henderson 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=77d96c7e87c5f25e1e42319131f4d21ec646eb32@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: 1629639272032100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Make sure at compile time that the scalar type of the array requested to be created via QARRAY_CREATE() matches the scalar type of the passed auto reference variable (unique pointer). Suggested-by: Richard Henderson 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 9885e5e9ed..643c8877c5 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 @@ -145,6 +147,10 @@ * @param len - amount of array elements to be allocated immediately */ #define QARRAY_CREATE(scalar_type, auto_var, len) \ + QEMU_BUILD_BUG_MSG( \ + !__builtin_types_compatible_p(scalar_type, typeof(*auto_var)), \ + "QArray scalar type mismatch" \ + ); \ qarray_create_##scalar_type((&auto_var), len) =20 #endif /* QEMU_QARRAY_H */ --=20 2.20.1