Commit a956f4ca authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Linus Torvalds

[PATCH] smsc-ircc2: drop DIM macro in favor of ARRAY_SIZE

IRDA: smsc-ircc2 - remove home-grown DIM macro, use ARRAY_SIZE intead.
      Also fix out-of-bound array access.
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
Cc: Jean Tourrilhes <jt@hpl.hp.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 98b77773
...@@ -163,7 +163,6 @@ struct smsc_ircc_cb { ...@@ -163,7 +163,6 @@ struct smsc_ircc_cb {
/* Constants */ /* Constants */
static const char *driver_name = "smsc-ircc2"; static const char *driver_name = "smsc-ircc2";
#define DIM(x) (sizeof(x)/(sizeof(*(x))))
#define SMSC_IRCC2_C_IRDA_FALLBACK_SPEED 9600 #define SMSC_IRCC2_C_IRDA_FALLBACK_SPEED 9600
#define SMSC_IRCC2_C_DEFAULT_TRANSCEIVER 1 #define SMSC_IRCC2_C_DEFAULT_TRANSCEIVER 1
#define SMSC_IRCC2_C_NET_TIMEOUT 0 #define SMSC_IRCC2_C_NET_TIMEOUT 0
...@@ -240,7 +239,7 @@ static smsc_transceiver_t smsc_transceivers[] = ...@@ -240,7 +239,7 @@ static smsc_transceiver_t smsc_transceivers[] =
{ "ATC IRMode", smsc_ircc_set_transceiver_smsc_ircc_atc, smsc_ircc_probe_transceiver_smsc_ircc_atc }, { "ATC IRMode", smsc_ircc_set_transceiver_smsc_ircc_atc, smsc_ircc_probe_transceiver_smsc_ircc_atc },
{ NULL, NULL } { NULL, NULL }
}; };
#define SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS (DIM(smsc_transceivers)-1) #define SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS (ARRAY_SIZE(smsc_transceivers) - 1)
/* SMC SuperIO chipsets definitions */ /* SMC SuperIO chipsets definitions */
...@@ -400,7 +399,7 @@ static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u ...@@ -400,7 +399,7 @@ static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u
goto err_out; goto err_out;
err = -ENOMEM; err = -ENOMEM;
if (dev_count > DIM(dev_self)) { if (dev_count >= ARRAY_SIZE(dev_self)) {
IRDA_WARNING("%s(), too many devices!\n", __FUNCTION__); IRDA_WARNING("%s(), too many devices!\n", __FUNCTION__);
goto err_out1; goto err_out1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment