From patchwork Tue Mar 15 15:03:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 8589491 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AAE7A9F6E1 for ; Tue, 15 Mar 2016 15:21:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7CA872012B for ; Tue, 15 Mar 2016 15:21:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 99EDD202C8 for ; Tue, 15 Mar 2016 15:21:32 +0000 (UTC) Received: from localhost ([::1]:49060 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afqmp-0003Ry-Q4 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 15 Mar 2016 11:21:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afqV2-0002jQ-Km for qemu-devel@nongnu.org; Tue, 15 Mar 2016 11:03:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afqV0-0007QL-AR for qemu-devel@nongnu.org; Tue, 15 Mar 2016 11:03:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51155) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afqV0-0007Q3-3L for qemu-devel@nongnu.org; Tue, 15 Mar 2016 11:03:06 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id AABCE64D27; Tue, 15 Mar 2016 15:03:05 +0000 (UTC) Received: from redhat.com (vpn1-6-68.ams2.redhat.com [10.36.6.68]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2FF32D4007457; Tue, 15 Mar 2016 11:03:03 -0400 Date: Tue, 15 Mar 2016 17:03:01 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1458053975-2410-47-git-send-email-mst@redhat.com> References: <1458053975-2410-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1458053975-2410-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 15 Mar 2016 15:03:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Cc: Peter Maydell , Eduardo Habkost , Corey Minyard , =?us-ascii?B?PT9VVEYtOD9xP0M9QzM9QTlkcmljPTIwTGU9MjBHb2F0ZXI/PQ==?= , Marcel Apfelbaum , Greg Kurz Subject: [Qemu-devel] [PULL v2 46/51] ipmi: add rsp_buffer_set_error() helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Cédric Le Goater The third byte in the response buffer of an IPMI command holds the error code. In many IPMI command handlers, this byte is updated directly. This patch adds a helper routine to clarify why this byte is being used. Signed-off-by: Cédric Le Goater Acked-by: Corey Minyard Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/ipmi/ipmi_bmc_sim.c | 115 ++++++++++++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c index 3089bfe..37c892d 100644 --- a/hw/ipmi/ipmi_bmc_sim.c +++ b/hw/ipmi/ipmi_bmc_sim.c @@ -270,11 +270,16 @@ struct RspBuffer { #define RSP_BUFFER_INITIALIZER { } +static inline void rsp_buffer_set_error(RspBuffer *rsp, uint8_t byte) +{ + rsp->buffer[2] = byte; +} + /* Add a byte to the response. */ static inline void rsp_buffer_push(RspBuffer *rsp, uint8_t byte) { if (rsp->len >= sizeof(rsp->buffer)) { - rsp->buffer[2] = IPMI_CC_REQUEST_DATA_TRUNCATED; + rsp_buffer_set_error(rsp, IPMI_CC_REQUEST_DATA_TRUNCATED); return; } rsp->buffer[rsp->len++] = byte; @@ -284,7 +289,7 @@ static inline void rsp_buffer_pushmore(RspBuffer *rsp, uint8_t *bytes, unsigned int n) { if (rsp->len + n >= sizeof(rsp->buffer)) { - rsp->buffer[2] = IPMI_CC_REQUEST_DATA_TRUNCATED; + rsp_buffer_set_error(rsp, IPMI_CC_REQUEST_DATA_TRUNCATED); return; } @@ -620,7 +625,7 @@ static void ipmi_sim_handle_command(IPMIBmc *b, /* Set up the response, set the low bit of NETFN. */ /* Note that max_rsp_len must be at least 3 */ if (sizeof(rsp.buffer) < 3) { - rsp.buffer[2] = IPMI_CC_REQUEST_DATA_TRUNCATED; + rsp_buffer_set_error(&rsp, IPMI_CC_REQUEST_DATA_TRUNCATED); goto out; } @@ -630,28 +635,28 @@ static void ipmi_sim_handle_command(IPMIBmc *b, /* If it's too short or it was truncated, return an error. */ if (cmd_len < 2) { - rsp.buffer[2] = IPMI_CC_REQUEST_DATA_LENGTH_INVALID; + rsp_buffer_set_error(&rsp, IPMI_CC_REQUEST_DATA_LENGTH_INVALID); goto out; } if (cmd_len > max_cmd_len) { - rsp.buffer[2] = IPMI_CC_REQUEST_DATA_TRUNCATED; + rsp_buffer_set_error(&rsp, IPMI_CC_REQUEST_DATA_TRUNCATED); goto out; } if ((cmd[0] & 0x03) != 0) { /* Only have stuff on LUN 0 */ - rsp.buffer[2] = IPMI_CC_COMMAND_INVALID_FOR_LUN; + rsp_buffer_set_error(&rsp, IPMI_CC_COMMAND_INVALID_FOR_LUN); goto out; } hdl = ipmi_get_handler(ibs, cmd[0] >> 2, cmd[1]); if (!hdl) { - rsp.buffer[2] = IPMI_CC_INVALID_CMD; + rsp_buffer_set_error(&rsp, IPMI_CC_INVALID_CMD); goto out; } if (cmd_len < hdl->cmd_len_min) { - rsp.buffer[2] = IPMI_CC_REQUEST_DATA_LENGTH_INVALID; + rsp_buffer_set_error(&rsp, IPMI_CC_REQUEST_DATA_LENGTH_INVALID); goto out; } @@ -761,26 +766,26 @@ static void chassis_control(IPMIBmcSim *ibs, switch (cmd[2] & 0xf) { case 0: /* power down */ - rsp->buffer[2] = k->do_hw_op(s, IPMI_POWEROFF_CHASSIS, 0); + rsp_buffer_set_error(rsp, k->do_hw_op(s, IPMI_POWEROFF_CHASSIS, 0)); break; case 1: /* power up */ - rsp->buffer[2] = k->do_hw_op(s, IPMI_POWERON_CHASSIS, 0); + rsp_buffer_set_error(rsp, k->do_hw_op(s, IPMI_POWERON_CHASSIS, 0)); break; case 2: /* power cycle */ - rsp->buffer[2] = k->do_hw_op(s, IPMI_POWERCYCLE_CHASSIS, 0); + rsp_buffer_set_error(rsp, k->do_hw_op(s, IPMI_POWERCYCLE_CHASSIS, 0)); break; case 3: /* hard reset */ - rsp->buffer[2] = k->do_hw_op(s, IPMI_RESET_CHASSIS, 0); + rsp_buffer_set_error(rsp, k->do_hw_op(s, IPMI_RESET_CHASSIS, 0)); break; case 4: /* pulse diagnostic interrupt */ - rsp->buffer[2] = k->do_hw_op(s, IPMI_PULSE_DIAG_IRQ, 0); + rsp_buffer_set_error(rsp, k->do_hw_op(s, IPMI_PULSE_DIAG_IRQ, 0)); break; case 5: /* soft shutdown via ACPI by overtemp emulation */ - rsp->buffer[2] = k->do_hw_op(s, - IPMI_SHUTDOWN_VIA_ACPI_OVERTEMP, 0); + rsp_buffer_set_error(rsp, k->do_hw_op(s, + IPMI_SHUTDOWN_VIA_ACPI_OVERTEMP, 0)); break; default: - rsp->buffer[2] = IPMI_CC_INVALID_DATA_FIELD; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); return; } } @@ -919,7 +924,7 @@ static void read_evt_msg_buf(IPMIBmcSim *ibs, unsigned int i; if (!(ibs->msg_flags & IPMI_BMC_MSG_FLAG_EVT_BUF_FULL)) { - rsp->buffer[2] = 0x80; + rsp_buffer_set_error(rsp, 0x80); return; } for (i = 0; i < 16; i++) { @@ -937,7 +942,7 @@ static void get_msg(IPMIBmcSim *ibs, qemu_mutex_lock(&ibs->lock); if (QTAILQ_EMPTY(&ibs->rcvbufs)) { - rsp->buffer[2] = 0x80; /* Queue empty */ + rsp_buffer_set_error(rsp, 0x80); /* Queue empty */ goto out; } rsp_buffer_push(rsp, 0); /* Channel 0 */ @@ -981,18 +986,18 @@ static void send_msg(IPMIBmcSim *ibs, if (cmd[2] != 0) { /* We only handle channel 0 with no options */ - rsp->buffer[2] = IPMI_CC_INVALID_DATA_FIELD; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); return; } if (cmd_len < 10) { - rsp->buffer[2] = IPMI_CC_REQUEST_DATA_LENGTH_INVALID; + rsp_buffer_set_error(rsp, IPMI_CC_REQUEST_DATA_LENGTH_INVALID); return; } if (cmd[3] != 0x40) { /* We only emulate a MC at address 0x40. */ - rsp->buffer[2] = 0x83; /* NAK on write */ + rsp_buffer_set_error(rsp, 0x83); /* NAK on write */ return; } @@ -1081,7 +1086,7 @@ static void reset_watchdog_timer(IPMIBmcSim *ibs, RspBuffer *rsp) { if (!ibs->watchdog_initialized) { - rsp->buffer[2] = 0x80; + rsp_buffer_set_error(rsp, 0x80); return; } do_watchdog_reset(ibs); @@ -1097,7 +1102,7 @@ static void set_watchdog_timer(IPMIBmcSim *ibs, val = cmd[2] & 0x7; /* Validate use */ if (val == 0 || val > 5) { - rsp->buffer[2] = IPMI_CC_INVALID_DATA_FIELD; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); return; } val = cmd[3] & 0x7; /* Validate action */ @@ -1106,22 +1111,22 @@ static void set_watchdog_timer(IPMIBmcSim *ibs, break; case IPMI_BMC_WATCHDOG_ACTION_RESET: - rsp->buffer[2] = k->do_hw_op(s, IPMI_RESET_CHASSIS, 1); + rsp_buffer_set_error(rsp, k->do_hw_op(s, IPMI_RESET_CHASSIS, 1)); break; case IPMI_BMC_WATCHDOG_ACTION_POWER_DOWN: - rsp->buffer[2] = k->do_hw_op(s, IPMI_POWEROFF_CHASSIS, 1); + rsp_buffer_set_error(rsp, k->do_hw_op(s, IPMI_POWEROFF_CHASSIS, 1)); break; case IPMI_BMC_WATCHDOG_ACTION_POWER_CYCLE: - rsp->buffer[2] = k->do_hw_op(s, IPMI_POWERCYCLE_CHASSIS, 1); + rsp_buffer_set_error(rsp, k->do_hw_op(s, IPMI_POWERCYCLE_CHASSIS, 1)); break; default: - rsp->buffer[2] = IPMI_CC_INVALID_DATA_FIELD; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); } if (rsp->buffer[2]) { - rsp->buffer[2] = IPMI_CC_INVALID_DATA_FIELD; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); return; } @@ -1134,14 +1139,14 @@ static void set_watchdog_timer(IPMIBmcSim *ibs, case IPMI_BMC_WATCHDOG_PRE_NMI: if (!k->do_hw_op(s, IPMI_SEND_NMI, 1)) { /* NMI not supported. */ - rsp->buffer[2] = IPMI_CC_INVALID_DATA_FIELD; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); return; } break; default: /* We don't support PRE_SMI */ - rsp->buffer[2] = IPMI_CC_INVALID_DATA_FIELD; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); return; } @@ -1217,7 +1222,7 @@ static void get_sdr(IPMIBmcSim *ibs, if (cmd[6]) { if ((cmd[2] | (cmd[3] << 8)) != ibs->sdr.reservation) { - rsp->buffer[2] = IPMI_CC_INVALID_RESERVATION; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_RESERVATION); return; } } @@ -1225,14 +1230,14 @@ static void get_sdr(IPMIBmcSim *ibs, pos = 0; if (sdr_find_entry(&ibs->sdr, cmd[4] | (cmd[5] << 8), &pos, &nextrec)) { - rsp->buffer[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; + rsp_buffer_set_error(rsp, IPMI_CC_REQ_ENTRY_NOT_PRESENT); return; } sdrh = (struct ipmi_sdr_header *) &ibs->sdr.sdr[pos]; if (cmd[6] > ipmi_sdr_length(sdrh)) { - rsp->buffer[2] = IPMI_CC_PARM_OUT_OF_RANGE; + rsp_buffer_set_error(rsp, IPMI_CC_PARM_OUT_OF_RANGE); return; } @@ -1244,7 +1249,7 @@ static void get_sdr(IPMIBmcSim *ibs, } if ((cmd[7] + rsp->len) > sizeof(rsp->buffer)) { - rsp->buffer[2] = IPMI_CC_CANNOT_RETURN_REQ_NUM_BYTES; + rsp_buffer_set_error(rsp, IPMI_CC_CANNOT_RETURN_REQ_NUM_BYTES); return; } @@ -1259,7 +1264,7 @@ static void add_sdr(IPMIBmcSim *ibs, struct ipmi_sdr_header *sdrh = (struct ipmi_sdr_header *) cmd + 2; if (sdr_add_entry(ibs, sdrh, cmd_len - 2, &recid)) { - rsp->buffer[2] = IPMI_CC_INVALID_DATA_FIELD; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); return; } rsp_buffer_push(rsp, recid & 0xff); @@ -1271,12 +1276,12 @@ static void clear_sdr_rep(IPMIBmcSim *ibs, RspBuffer *rsp) { if ((cmd[2] | (cmd[3] << 8)) != ibs->sdr.reservation) { - rsp->buffer[2] = IPMI_CC_INVALID_RESERVATION; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_RESERVATION); return; } if (cmd[4] != 'C' || cmd[5] != 'L' || cmd[6] != 'R') { - rsp->buffer[2] = IPMI_CC_INVALID_DATA_FIELD; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); return; } if (cmd[7] == 0xaa) { @@ -1288,7 +1293,7 @@ static void clear_sdr_rep(IPMIBmcSim *ibs, } else if (cmd[7] == 0) { rsp_buffer_push(rsp, 1); /* Erasure complete */ } else { - rsp->buffer[2] = IPMI_CC_INVALID_DATA_FIELD; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); return; } } @@ -1331,22 +1336,22 @@ static void get_sel_entry(IPMIBmcSim *ibs, if (cmd[6]) { if ((cmd[2] | (cmd[3] << 8)) != ibs->sel.reservation) { - rsp->buffer[2] = IPMI_CC_INVALID_RESERVATION; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_RESERVATION); return; } } if (ibs->sel.next_free == 0) { - rsp->buffer[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; + rsp_buffer_set_error(rsp, IPMI_CC_REQ_ENTRY_NOT_PRESENT); return; } if (cmd[6] > 15) { - rsp->buffer[2] = IPMI_CC_INVALID_DATA_FIELD; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); return; } if (cmd[7] == 0xff) { cmd[7] = 16; } else if ((cmd[7] + cmd[6]) > 16) { - rsp->buffer[2] = IPMI_CC_INVALID_DATA_FIELD; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); return; } else { cmd[7] += cmd[6]; @@ -1356,7 +1361,7 @@ static void get_sel_entry(IPMIBmcSim *ibs, if (val == 0xffff) { val = ibs->sel.next_free - 1; } else if (val >= ibs->sel.next_free) { - rsp->buffer[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; + rsp_buffer_set_error(rsp, IPMI_CC_REQ_ENTRY_NOT_PRESENT); return; } if ((val + 1) == ibs->sel.next_free) { @@ -1376,7 +1381,7 @@ static void add_sel_entry(IPMIBmcSim *ibs, RspBuffer *rsp) { if (sel_add_event(ibs, cmd + 2)) { - rsp->buffer[2] = IPMI_CC_OUT_OF_SPACE; + rsp_buffer_set_error(rsp, IPMI_CC_OUT_OF_SPACE); return; } /* sel_add_event fills in the record number. */ @@ -1389,12 +1394,12 @@ static void clear_sel(IPMIBmcSim *ibs, RspBuffer *rsp) { if ((cmd[2] | (cmd[3] << 8)) != ibs->sel.reservation) { - rsp->buffer[2] = IPMI_CC_INVALID_RESERVATION; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_RESERVATION); return; } if (cmd[4] != 'C' || cmd[5] != 'L' || cmd[6] != 'R') { - rsp->buffer[2] = IPMI_CC_INVALID_DATA_FIELD; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); return; } if (cmd[7] == 0xaa) { @@ -1406,7 +1411,7 @@ static void clear_sel(IPMIBmcSim *ibs, } else if (cmd[7] == 0) { rsp_buffer_push(rsp, 1); /* Erasure complete */ } else { - rsp->buffer[2] = IPMI_CC_INVALID_DATA_FIELD; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); return; } } @@ -1446,7 +1451,7 @@ static void set_sensor_evt_enable(IPMIBmcSim *ibs, if ((cmd[2] >= MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { - rsp->buffer[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; + rsp_buffer_set_error(rsp, IPMI_CC_REQ_ENTRY_NOT_PRESENT); return; } sens = ibs->sensors + cmd[2]; @@ -1482,7 +1487,7 @@ static void set_sensor_evt_enable(IPMIBmcSim *ibs, } break; case 3: - rsp->buffer[2] = IPMI_CC_INVALID_DATA_FIELD; + rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD); return; } IPMI_SENSOR_SET_RET_STATUS(sens, cmd[3]); @@ -1496,7 +1501,7 @@ static void get_sensor_evt_enable(IPMIBmcSim *ibs, if ((cmd[2] >= MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { - rsp->buffer[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; + rsp_buffer_set_error(rsp, IPMI_CC_REQ_ENTRY_NOT_PRESENT); return; } sens = ibs->sensors + cmd[2]; @@ -1515,7 +1520,7 @@ static void rearm_sensor_evts(IPMIBmcSim *ibs, if ((cmd[2] >= MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { - rsp->buffer[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; + rsp_buffer_set_error(rsp, IPMI_CC_REQ_ENTRY_NOT_PRESENT); return; } sens = ibs->sensors + cmd[2]; @@ -1535,7 +1540,7 @@ static void get_sensor_evt_status(IPMIBmcSim *ibs, if ((cmd[2] >= MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { - rsp->buffer[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; + rsp_buffer_set_error(rsp, IPMI_CC_REQ_ENTRY_NOT_PRESENT); return; } sens = ibs->sensors + cmd[2]; @@ -1555,7 +1560,7 @@ static void get_sensor_reading(IPMIBmcSim *ibs, if ((cmd[2] >= MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { - rsp->buffer[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; + rsp_buffer_set_error(rsp, IPMI_CC_REQ_ENTRY_NOT_PRESENT); return; } sens = ibs->sensors + cmd[2]; @@ -1576,7 +1581,7 @@ static void set_sensor_type(IPMIBmcSim *ibs, if ((cmd[2] >= MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { - rsp->buffer[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; + rsp_buffer_set_error(rsp, IPMI_CC_REQ_ENTRY_NOT_PRESENT); return; } sens = ibs->sensors + cmd[2]; @@ -1593,7 +1598,7 @@ static void get_sensor_type(IPMIBmcSim *ibs, if ((cmd[2] >= MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { - rsp->buffer[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; + rsp_buffer_set_error(rsp, IPMI_CC_REQ_ENTRY_NOT_PRESENT); return; } sens = ibs->sensors + cmd[2];