From nobody Wed Nov 27 00:24:46 2024 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1703128669; cv=none; d=zohomail.com; s=zohoarc; b=WC1VW4EucWcbGUCSxXKoerKMXWU0cydM4lfLKF0mJKpcSzUF/uwwZ4YIgb9qe4gTSauVY/YAHZYV+M8CYKUv6vPI4cFHYFizUzdrTC3KrqCskhs2mkzWel+0rl8PYe9Bm7zjHuU5J6bVP7nS1G80uIS83ghtHfgnuTh/uLK8VFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703128669; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hP22ASds0dKq3upA0SbpqniwHlNMzWgmAUGbg1galUQ=; b=HTBKoPVTxx5GcrlazM6QuGPh2kheUsKdM5ceNyua/qiYXGqSzOuuhPKPMJV1k+j0K2ENhdwpokdFKHfdaZTk5EUauUx8TJRGcpVRX/Kr6FyuKHGy5gpSAFbsClo+o2REnzQmuAY0LAKp7eeO7vd0anOd2vMle+fbY2ZLw+lvYN0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1703128668950938.5423791500106; Wed, 20 Dec 2023 19:17:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rG9Yi-0007F0-Hn; Wed, 20 Dec 2023 22:17:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rG9Yh-0007Er-Jx for qemu-devel@nongnu.org; Wed, 20 Dec 2023 22:17:15 -0500 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rG9Yg-0003fu-0b for qemu-devel@nongnu.org; Wed, 20 Dec 2023 22:17:15 -0500 Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-78101108e3fso19637885a.1 for ; Wed, 20 Dec 2023 19:17:13 -0800 (PST) Received: from stoup.. ([172.58.139.164]) by smtp.gmail.com with ESMTPSA id n8-20020a05620a294800b0078116d55191sm360808qkp.130.2023.12.20.19.17.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 19:17:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703128633; x=1703733433; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hP22ASds0dKq3upA0SbpqniwHlNMzWgmAUGbg1galUQ=; b=vgxdsKXH1z6uvERBtZIBOTFbboV6blJ57OqZO1yuKmbe0uElOqNAxW8XG+2j/sti7O BsYd3s/W+wHAoJprCLve80u1m+7EVtypP0TreDKt4hhPbXHignCE4auD50weagcmgXnQ VX3AxE+cl+QPs5LT3f3JxuG40Tw8lO5IeYyvmXa7JCJ5SKXU2IOd5KGuuH3c2KEBQbt7 JmOFlrhc89/puaP5nrsyI6saJ9X7unCQk3APfH8HktqL7EKBYZLWdGQWnddCNR0IzjUi hlAN7DdAZgMScJBKr3eagJ6RJrEZ1fErJQShAYSGSBcelSmq0UppsrP40rv1FW3Xz0l4 2/0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703128633; x=1703733433; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hP22ASds0dKq3upA0SbpqniwHlNMzWgmAUGbg1galUQ=; b=udJ/+EaJKl6w+1WU/97AbIPwS+306tEfjEotUCshvPy4ppXgF5HcWzw86Uqwyr6ZuW IsLNcKzQn0ZGcAExd/IrNMohu+O9epKyWWqUwbfpqyzB7l7QKlGEwAvyYAy+HkuQqljv BenzxxF2VLZAcFfY9cRvRphI5pHWN8Ben0tjDDsA/DFHmX+6/Cpf/X9cqwwa961CSH0V EVl5Wk6D7LpHL9uP4M1UrVKIKH+H+p7ga0+KS4SamCWvSxpgIvdcrEaGewbfayLvrJrD gObs0TUh1LlOZpDfmY6ZV1FlQic7txqZqWzEN2UVwX60mVsNQuh0h5MCk3aZRAR+T0XE yPig== X-Gm-Message-State: AOJu0Yxoujk4S7kNuMP5/FwGxswPjqz/iAryoE6VHCjqK3W5vhc51PKt gXPdqei9xB+GIz/eht/GqgHRYx3Fqkl9Aw9VpgSImGgj X-Google-Smtp-Source: AGHT+IHWIvomV1ykT3fSzl8Tq7qHrVAcE09iNmtraIhgY/7GH6pCoceJ0jSf34F7Pkshsx54QInCbw== X-Received: by 2002:a05:620a:98d:b0:781:2021:ce93 with SMTP id x13-20020a05620a098d00b007812021ce93mr178741qkx.125.1703128633144; Wed, 20 Dec 2023 19:17:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juan Quintela Subject: [PATCH v2 01/71] migration: Make VMStateDescription.subsections const Date: Thu, 21 Dec 2023 14:15:42 +1100 Message-Id: <20231221031652.119827-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221031652.119827-1-richard.henderson@linaro.org> References: <20231221031652.119827-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2607:f8b0:4864:20::730; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x730.google.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1703128671547100005 Allow the array of pointers to itself be const. Propagate this through the copies of this field. Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Richard Henderson --- include/migration/vmstate.h | 2 +- migration/savevm.c | 12 ++++++------ migration/vmstate.c | 14 ++++++++------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 9821918631..294d2d8486 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -209,7 +209,7 @@ struct VMStateDescription { bool (*dev_unplug_pending)(void *opaque); =20 const VMStateField *fields; - const VMStateDescription **subsections; + const VMStateDescription * const *subsections; }; =20 extern const VMStateInfo vmstate_info_bool; diff --git a/migration/savevm.c b/migration/savevm.c index eec5503a42..39148636cc 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -551,11 +551,11 @@ static void dump_vmstate_vmsf(FILE *out_file, const V= MStateField *field, } =20 static void dump_vmstate_vmss(FILE *out_file, - const VMStateDescription **subsection, + const VMStateDescription *subsection, int indent) { - if (*subsection !=3D NULL) { - dump_vmstate_vmsd(out_file, *subsection, indent, true); + if (subsection !=3D NULL) { + dump_vmstate_vmsd(out_file, subsection, indent, true); } } =20 @@ -597,7 +597,7 @@ static void dump_vmstate_vmsd(FILE *out_file, fprintf(out_file, "\n%*s]", indent, ""); } if (vmsd->subsections !=3D NULL) { - const VMStateDescription **subsection =3D vmsd->subsections; + const VMStateDescription * const *subsection =3D vmsd->subsections; bool first; =20 fprintf(out_file, ",\n%*s\"Subsections\": [\n", indent, ""); @@ -606,7 +606,7 @@ static void dump_vmstate_vmsd(FILE *out_file, if (!first) { fprintf(out_file, ",\n"); } - dump_vmstate_vmss(out_file, subsection, indent + 2); + dump_vmstate_vmss(out_file, *subsection, indent + 2); subsection++; first =3D false; } @@ -831,7 +831,7 @@ void unregister_savevm(VMStateIf *obj, const char *idst= r, void *opaque) static void vmstate_check(const VMStateDescription *vmsd) { const VMStateField *field =3D vmsd->fields; - const VMStateDescription **subsection =3D vmsd->subsections; + const VMStateDescription * const *subsection =3D vmsd->subsections; =20 if (field) { while (field->name) { diff --git a/migration/vmstate.c b/migration/vmstate.c index b7723a4187..ef26f26ccd 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -452,13 +452,15 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDe= scription *vmsd, } =20 static const VMStateDescription * -vmstate_get_subsection(const VMStateDescription **sub, char *idstr) +vmstate_get_subsection(const VMStateDescription * const *sub, + const char *idstr) { - while (sub && *sub) { - if (strcmp(idstr, (*sub)->name) =3D=3D 0) { - return *sub; + if (sub) { + for (const VMStateDescription *s =3D *sub; s ; s =3D *++sub) { + if (strcmp(idstr, s->name) =3D=3D 0) { + return s; + } } - sub++; } return NULL; } @@ -517,7 +519,7 @@ static int vmstate_subsection_load(QEMUFile *f, const V= MStateDescription *vmsd, static int vmstate_subsection_save(QEMUFile *f, const VMStateDescription *= vmsd, void *opaque, JSONWriter *vmdesc) { - const VMStateDescription **sub =3D vmsd->subsections; + const VMStateDescription * const *sub =3D vmsd->subsections; bool vmdesc_has_subsections =3D false; int ret =3D 0; =20 --=20 2.34.1