From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aeOhr-0003i7-Bx for qemu-devel@nongnu.org; Fri, 11 Mar 2016 10:10:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aeOhl-0000Z0-H4 for qemu-devel@nongnu.org; Fri, 11 Mar 2016 10:10:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44435) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aeOhl-0000Yu-A9 for qemu-devel@nongnu.org; Fri, 11 Mar 2016 10:10:17 -0500 Date: Fri, 11 Mar 2016 17:10:12 +0200 From: "Michael S. Tsirkin" Message-ID: <1457708548-14093-46-git-send-email-mst@redhat.com> References: <1457708548-14093-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: <1457708548-14093-1-git-send-email-mst@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 45/53] ipmi: remove IPMI_CHECK_RESERVATION() macro 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 Some IPMI command handlers in the BMC simulator use a macro IPMI_CHECK_RESERVATION() to check a SDR reservation but the macro implicitly uses local variables. This patch simply removes it. Signed-off-by: C=E9dric Le Goater Acked-by: Corey Minyard Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/ipmi/ipmi_bmc_sim.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c index 1b615f6..3089bfe 100644 --- a/hw/ipmi/ipmi_bmc_sim.c +++ b/hw/ipmi/ipmi_bmc_sim.c @@ -292,16 +292,6 @@ static inline void rsp_buffer_pushmore(RspBuffer *rs= p, uint8_t *bytes, rsp->len +=3D n; } =20 -/* Check that the reservation in the command is valid. */ -#define IPMI_CHECK_RESERVATION(off, r) \ - do { \ - if ((cmd[off] | (cmd[off + 1] << 8)) !=3D r) { \ - rsp->buffer[2] =3D IPMI_CC_INVALID_RESERVATION; \ - return; \ - } \ - } while (0) - - static void ipmi_sim_handle_timeout(IPMIBmcSim *ibs); =20 static void ipmi_gettime(struct ipmi_time *time) @@ -1226,8 +1216,12 @@ static void get_sdr(IPMIBmcSim *ibs, struct ipmi_sdr_header *sdrh; =20 if (cmd[6]) { - IPMI_CHECK_RESERVATION(2, ibs->sdr.reservation); + if ((cmd[2] | (cmd[3] << 8)) !=3D ibs->sdr.reservation) { + rsp->buffer[2] =3D IPMI_CC_INVALID_RESERVATION; + return; + } } + pos =3D 0; if (sdr_find_entry(&ibs->sdr, cmd[4] | (cmd[5] << 8), &pos, &nextrec)) { @@ -1276,7 +1270,11 @@ static void clear_sdr_rep(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len, RspBuffer *rsp) { - IPMI_CHECK_RESERVATION(2, ibs->sdr.reservation); + if ((cmd[2] | (cmd[3] << 8)) !=3D ibs->sdr.reservation) { + rsp->buffer[2] =3D IPMI_CC_INVALID_RESERVATION; + return; + } + if (cmd[4] !=3D 'C' || cmd[5] !=3D 'L' || cmd[6] !=3D 'R') { rsp->buffer[2] =3D IPMI_CC_INVALID_DATA_FIELD; return; @@ -1332,7 +1330,10 @@ static void get_sel_entry(IPMIBmcSim *ibs, unsigned int val; =20 if (cmd[6]) { - IPMI_CHECK_RESERVATION(2, ibs->sel.reservation); + if ((cmd[2] | (cmd[3] << 8)) !=3D ibs->sel.reservation) { + rsp->buffer[2] =3D IPMI_CC_INVALID_RESERVATION; + return; + } } if (ibs->sel.next_free =3D=3D 0) { rsp->buffer[2] =3D IPMI_CC_REQ_ENTRY_NOT_PRESENT; @@ -1387,7 +1388,11 @@ static void clear_sel(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len, RspBuffer *rsp) { - IPMI_CHECK_RESERVATION(2, ibs->sel.reservation); + if ((cmd[2] | (cmd[3] << 8)) !=3D ibs->sel.reservation) { + rsp->buffer[2] =3D IPMI_CC_INVALID_RESERVATION; + return; + } + if (cmd[4] !=3D 'C' || cmd[5] !=3D 'L' || cmd[6] !=3D 'R') { rsp->buffer[2] =3D IPMI_CC_INVALID_DATA_FIELD; return; --=20 MST