From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afqVI-0003JJ-S9 for qemu-devel@nongnu.org; Tue, 15 Mar 2016 11:03:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afqVC-0007Us-VC for qemu-devel@nongnu.org; Tue, 15 Mar 2016 11:03:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43989) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afqVC-0007Un-Qi for qemu-devel@nongnu.org; Tue, 15 Mar 2016 11:03:18 -0400 Date: Tue, 15 Mar 2016 17:03:14 +0200 From: "Michael S. Tsirkin" Message-ID: <1458053975-2410-50-git-send-email-mst@redhat.com> References: <1458053975-2410-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1458053975-2410-1-git-send-email-mst@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL v2 49/51] ipmi: remove the need of an ending record in the SDR table List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Eduardo Habkost , Corey Minyard , =?us-ascii?B?PT9VVEYtOD9xP0M9QzM9QTlkcmljPTIwTGU9MjBHb2F0ZXI/PQ==?= , Marcel Apfelbaum , Greg Kurz From: C=E9dric Le Goater Currently, the code initializing the sdr table relies on an ending record with a recid of 0xffff. This patch changes the loop to use the sdr size as a breaking condition. Signed-off-by: C=E9dric Le Goater Acked-by: Corey Minyard Reviewed-by: Marcel Apfelbaum Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/ipmi/ipmi_bmc_sim.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c index 0d4d748..9176f8a 100644 --- a/hw/ipmi/ipmi_bmc_sim.c +++ b/hw/ipmi/ipmi_bmc_sim.c @@ -1690,34 +1690,27 @@ static const uint8_t init_sdrs[] =3D { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 'W', 'a', 't', 'c', 'h', 'd', 'o', 'g', - /* End */ - 0xff, 0xff, 0x00, 0x00, 0x00 }; =20 static void ipmi_sdr_init(IPMIBmcSim *ibs) { unsigned int i; - unsigned int recid; + int len; =20 - for (i =3D 0;;) { + for (i =3D 0; i < sizeof(init_sdrs); i +=3D len) { struct ipmi_sdr_header *sdrh; - int len; + if ((i + IPMI_SDR_HEADER_SIZE) > sizeof(init_sdrs)) { error_report("Problem with recid 0x%4.4x", i); return; } sdrh =3D (struct ipmi_sdr_header *) &init_sdrs[i]; len =3D ipmi_sdr_length(sdrh); - recid =3D ipmi_sdr_recid(sdrh); - if (recid =3D=3D 0xffff) { - break; - } if ((i + len) > sizeof(init_sdrs)) { error_report("Problem with recid 0x%4.4x", i); return; } sdr_add_entry(ibs, sdrh, len, NULL); - i +=3D len; } } =20 --=20 MST