From patchwork Mon Nov 6 06:57:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 741261 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp947732wrr; Sun, 5 Nov 2023 23:07:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXS/wve+GJBf3OgtfPrNo24VPJNx8XAXXaYfe3bfTd0hsV3ugENcbOL1YqdsV+4GhM/JgA X-Received: by 2002:a05:620a:140d:b0:775:cf5f:8a81 with SMTP id d13-20020a05620a140d00b00775cf5f8a81mr24684282qkj.62.1699254429846; Sun, 05 Nov 2023 23:07:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699254429; cv=none; d=google.com; s=arc-20160816; b=YGXbDo7G+09XKIE3aQyvGVflXd7r9KT4ehvsxKqvZ1GA24CHeufIJGU8nGkWMq+6m0 g4hFMe7w4ZYAhx1zmPXkGC5YHpYP0P4JoCZ2acwxDpDFNDLuq6zQcgr4ZDUxVSQDutjo LhW5xAHh2FNIKWqzSTSMCvubSEuGDRePamdwUoRgW6G3xWlWzPPncGfiV1Yq586kyTsj phZg2eAQJCFI4KzhciB6K8SXl+x7GrUXpK5tAq5uSqiCZpw5pF+nwNyiPiTX1hyUz+0h 7vNVu3fAriCiU6eQwz49iRzJeI7IrQtLb98i8JmK2OBDdVgBJBl0Y5pPb2MwdKcjmDVM YQ3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8KgC7l6+Ks9UAAd1eXGQex3KmmjQLxfw8YM2XKWIPZQ=; fh=U+hGNjcWZPeyLe2bTdTFM68h7FRptferheHiMMFpeys=; b=PpyomhVHhfjFTa/FZ2tfil1WkgOxf1M6isMDsp7S9HPJsYrVtejo2t+QXDJX6UkR2S QDnUykrOxETKiLeoP+kBT3BgEXVXfUdYP7yx5CjgOMTQ87TN82W9WuW1gdhGyExzDvZt 1cj4L4QmUyP3qlLX3C5EZrrwA0HYJL78kkXe6bz0CStn8/XtlKKfjLilJpTIzqeqcBEA OfZ9qtQv1BAsjlk9AOOcaw7Bqp7AQJ/a6OqZ35B2YtYyc2i1ZwWunI+IjS2eLF4o4NoT TpkamA6TXRfCUk/5P5JEfGCG2ekIPWjICFOXsZP0r0P7z2TymWcwyTC45zjyZCe5ggx3 q3vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ynFGfCPF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h13-20020a05620a21cd00b0076ceb5934f6si5146817qka.64.2023.11.05.23.07.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Nov 2023 23:07:09 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ynFGfCPF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qztZC-0004OO-Ll; Mon, 06 Nov 2023 01:58:34 -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 1qztZA-0004O4-VL for qemu-devel@nongnu.org; Mon, 06 Nov 2023 01:58:32 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qztZ9-0001MP-6v for qemu-devel@nongnu.org; Mon, 06 Nov 2023 01:58:32 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1cc9784dbc1so21373725ad.2 for ; Sun, 05 Nov 2023 22:58:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699253910; x=1699858710; 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=8KgC7l6+Ks9UAAd1eXGQex3KmmjQLxfw8YM2XKWIPZQ=; b=ynFGfCPFDl69Zj+9CrfjiMwnh3jeDsTw+WxklhXDMmqb5SJZRMxzlX5hyjv82dOv1J n+LXMnmmn4V+pwrIYskJ53qlGY9gDhG9Rq7FB/XL1uKycyfhUic6Uw/qlVJ+nFxsK/NQ ZF2jl0j3ZIXxfj5QEv2hps4mVyKqDJkwLYwNIyvQ8rGXPVObGZP8dmkocVlvA0brfRVw cCrvzzfvCxAL2d0X/JpC0Qxk6XOEA7PUBGYxNlfOH4jJ6ofqq8UOGxRoieYHO52b1m3e 0zQ3SS2EmuT8O3ZgtaK32EVVg+HkUE2ttPir6AsWZJnfWu0uEd9HaK4M3lmesn+rbqvd 6MOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699253910; x=1699858710; 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=8KgC7l6+Ks9UAAd1eXGQex3KmmjQLxfw8YM2XKWIPZQ=; b=EzPOD1Mp2o2CwhBJw5ifkHK1fgDs28fPwqjiJjc/0KOKcTgX+LA72ok5Fm0xanTHNb m8zC2BUcxaAa6Q9Uj2PeF0Q+k6xJJUCtET9SFkLkECgb2INXETQgQ9OoC+ImhpnKxv2c z8wcBCIrGf/QNoOvEae3rFSfg6Z/T469A/KAxZ8WbsSJH0ErOKwCmCKErSTyXCzqC+aQ ff4NRI1xdW3PHF7Urry+mMQlx326mUrZptBY6uQIYDXiQPZ1h2vZ1gLyeKV0X1anngkb xcXkXIm18mDS3uW2r6hD3mNcZGiXOZCC8oqkQ52+jIINbsA2yLLITnv8kWA1gc8SBo2M jbiA== X-Gm-Message-State: AOJu0YxPhLOiWgl+rAlUtvPIJlaQ4lMK6jF9GleoRBykYJ3B7OcfCWAO ob4N1/WciXDcJFlBLuhZ/vANXJx8o2Mta7M+5H4= X-Received: by 2002:a17:903:245:b0:1c5:d8a3:8789 with SMTP id j5-20020a170903024500b001c5d8a38789mr27131552plh.4.1699253909800; Sun, 05 Nov 2023 22:58:29 -0800 (PST) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id c3-20020a170902d48300b001c62e3e1286sm5167130plg.166.2023.11.05.22.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 22:58:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, farosas@suse.de, leobras@redhat.com Subject: [PATCH 01/71] migration: Make VMStateDescription.subsections const Date: Sun, 5 Nov 2023 22:57:17 -0800 Message-Id: <20231106065827.543129-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106065827.543129-1-richard.henderson@linaro.org> References: <20231106065827.543129-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Allow the array of pointers to itself be const. Propagate this through the copies of this field. Signed-off-by: Richard Henderson Reviewed-by: Juan Quintela Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé --- include/migration/vmstate.h | 2 +- migration/savevm.c | 12 ++++++------ migration/vmstate.c | 15 +++++++++------ 3 files changed, 16 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); const VMStateField *fields; - const VMStateDescription **subsections; + const VMStateDescription * const *subsections; }; extern const VMStateInfo vmstate_info_bool; diff --git a/migration/savevm.c b/migration/savevm.c index bc98c2ea6f..77a81937cd 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -551,11 +551,11 @@ static void dump_vmstate_vmsf(FILE *out_file, const VMStateField *field, } static void dump_vmstate_vmss(FILE *out_file, - const VMStateDescription **subsection, + const VMStateDescription *subsection, int indent) { - if (*subsection != NULL) { - dump_vmstate_vmsd(out_file, *subsection, indent, true); + if (subsection != NULL) { + dump_vmstate_vmsd(out_file, subsection, indent, true); } } @@ -597,7 +597,7 @@ static void dump_vmstate_vmsd(FILE *out_file, fprintf(out_file, "\n%*s]", indent, ""); } if (vmsd->subsections != NULL) { - const VMStateDescription **subsection = vmsd->subsections; + const VMStateDescription * const *subsection = vmsd->subsections; bool first; 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 = false; } @@ -831,7 +831,7 @@ void unregister_savevm(VMStateIf *obj, const char *idstr, void *opaque) static void vmstate_check(const VMStateDescription *vmsd) { const VMStateField *field = vmsd->fields; - const VMStateDescription **subsection = vmsd->subsections; + const VMStateDescription * const *subsection = vmsd->subsections; if (field) { while (field->name) { diff --git a/migration/vmstate.c b/migration/vmstate.c index b7723a4187..5876062d48 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -452,13 +452,16 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, } 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) == 0) { - return *sub; + if (sub) { + const VMStateDescription *s; + for (s = *sub; s ; s = *++sub) { + if (strcmp(idstr, s->name) == 0) { + return s; + } } - sub++; } return NULL; } @@ -517,7 +520,7 @@ static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd, static int vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, JSONWriter *vmdesc) { - const VMStateDescription **sub = vmsd->subsections; + const VMStateDescription * const *sub = vmsd->subsections; bool vmdesc_has_subsections = false; int ret = 0;