From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44739) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRRp8-0006Wm-AI for qemu-devel@nongnu.org; Thu, 04 Feb 2016 16:52:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRRp4-0005J0-59 for qemu-devel@nongnu.org; Thu, 04 Feb 2016 16:52:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33543) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRRp3-0005Ik-OD for qemu-devel@nongnu.org; Thu, 04 Feb 2016 16:52:18 -0500 Date: Thu, 4 Feb 2016 23:52:13 +0200 From: "Michael S. Tsirkin" Message-ID: <1454612376-7072-20-git-send-email-mst@redhat.com> References: <1454612376-7072-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: <1454612376-7072-1-git-send-email-mst@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 19/49] ipmi: replace *_MAXCMD defines 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 ARRAY_SIZE() is simple to use and removes the need to pre-define the size of the command arrays. Signed-off-by: C=E9dric Le Goater Reviewed-by: Greg Kurz Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/ipmi/ipmi_bmc_sim.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c index 1f06dfc..f7e87b4 100644 --- a/hw/ipmi/ipmi_bmc_sim.c +++ b/hw/ipmi/ipmi_bmc_sim.c @@ -28,14 +28,12 @@ #include "qemu/error-report.h" =20 #define IPMI_NETFN_CHASSIS 0x00 -#define IPMI_NETFN_CHASSIS_MAXCMD 0x03 =20 #define IPMI_CMD_GET_CHASSIS_CAPABILITIES 0x00 #define IPMI_CMD_GET_CHASSIS_STATUS 0x01 #define IPMI_CMD_CHASSIS_CONTROL 0x02 =20 #define IPMI_NETFN_SENSOR_EVENT 0x04 -#define IPMI_NETFN_SENSOR_EVENT_MAXCMD 0x2e =20 #define IPMI_CMD_SET_SENSOR_EVT_ENABLE 0x28 #define IPMI_CMD_GET_SENSOR_EVT_ENABLE 0x29 @@ -44,7 +42,6 @@ #define IPMI_CMD_GET_SENSOR_READING 0x2d =20 /* #define IPMI_NETFN_APP 0x06 In ipmi.h */ -#define IPMI_NETFN_APP_MAXCMD 0x36 =20 #define IPMI_CMD_GET_DEVICE_ID 0x01 #define IPMI_CMD_COLD_RESET 0x02 @@ -61,7 +58,6 @@ #define IPMI_CMD_READ_EVT_MSG_BUF 0x35 =20 #define IPMI_NETFN_STORAGE 0x0a -#define IPMI_NETFN_STORAGE_MAXCMD 0x4a =20 #define IPMI_CMD_GET_SDR_REP_INFO 0x20 #define IPMI_CMD_GET_SDR_REP_ALLOC_INFO 0x21 @@ -1516,18 +1512,17 @@ static void get_sensor_reading(IPMIBmcSim *ibs, } } =20 -static const IPMICmdHandler chassis_cmds[IPMI_NETFN_CHASSIS_MAXCMD] =3D = { +static const IPMICmdHandler chassis_cmds[] =3D { [IPMI_CMD_GET_CHASSIS_CAPABILITIES] =3D chassis_capabilities, [IPMI_CMD_GET_CHASSIS_STATUS] =3D chassis_status, [IPMI_CMD_CHASSIS_CONTROL] =3D chassis_control }; static const IPMINetfn chassis_netfn =3D { - .cmd_nums =3D IPMI_NETFN_CHASSIS_MAXCMD, + .cmd_nums =3D ARRAY_SIZE(chassis_cmds), .cmd_handlers =3D chassis_cmds }; =20 -static const IPMICmdHandler -sensor_event_cmds[IPMI_NETFN_SENSOR_EVENT_MAXCMD] =3D { +static const IPMICmdHandler sensor_event_cmds[] =3D { [IPMI_CMD_SET_SENSOR_EVT_ENABLE] =3D set_sensor_evt_enable, [IPMI_CMD_GET_SENSOR_EVT_ENABLE] =3D get_sensor_evt_enable, [IPMI_CMD_REARM_SENSOR_EVTS] =3D rearm_sensor_evts, @@ -1535,11 +1530,11 @@ sensor_event_cmds[IPMI_NETFN_SENSOR_EVENT_MAXCMD]= =3D { [IPMI_CMD_GET_SENSOR_READING] =3D get_sensor_reading }; static const IPMINetfn sensor_event_netfn =3D { - .cmd_nums =3D IPMI_NETFN_SENSOR_EVENT_MAXCMD, + .cmd_nums =3D ARRAY_SIZE(sensor_event_cmds), .cmd_handlers =3D sensor_event_cmds }; =20 -static const IPMICmdHandler app_cmds[IPMI_NETFN_APP_MAXCMD] =3D { +static const IPMICmdHandler app_cmds[] =3D { [IPMI_CMD_GET_DEVICE_ID] =3D get_device_id, [IPMI_CMD_COLD_RESET] =3D cold_reset, [IPMI_CMD_WARM_RESET] =3D warm_reset, @@ -1555,11 +1550,11 @@ static const IPMICmdHandler app_cmds[IPMI_NETFN_A= PP_MAXCMD] =3D { [IPMI_CMD_GET_WATCHDOG_TIMER] =3D get_watchdog_timer, }; static const IPMINetfn app_netfn =3D { - .cmd_nums =3D IPMI_NETFN_APP_MAXCMD, + .cmd_nums =3D ARRAY_SIZE(app_cmds), .cmd_handlers =3D app_cmds }; =20 -static const IPMICmdHandler storage_cmds[IPMI_NETFN_STORAGE_MAXCMD] =3D = { +static const IPMICmdHandler storage_cmds[] =3D { [IPMI_CMD_GET_SDR_REP_INFO] =3D get_sdr_rep_info, [IPMI_CMD_RESERVE_SDR_REP] =3D reserve_sdr_rep, [IPMI_CMD_GET_SDR] =3D get_sdr, @@ -1575,7 +1570,7 @@ static const IPMICmdHandler storage_cmds[IPMI_NETFN= _STORAGE_MAXCMD] =3D { }; =20 static const IPMINetfn storage_netfn =3D { - .cmd_nums =3D IPMI_NETFN_STORAGE_MAXCMD, + .cmd_nums =3D ARRAY_SIZE(storage_cmds), .cmd_handlers =3D storage_cmds }; =20 --=20 MST