Remove ARRAY_LENGTH, we've already ARRAYLEN

This commit is contained in:
Philippe Teuwen 2022-01-09 14:19:48 +01:00
commit 2269ad6914
3 changed files with 10 additions and 12 deletions

View file

@ -50,7 +50,7 @@ const CLIParserOption DesfireAlgoOpts[] = {
{T_AES, "aes"},
{0, NULL},
};
const size_t DesfireAlgoOptsLen = ARRAY_LENGTH(DesfireAlgoOpts);
const size_t DesfireAlgoOptsLen = ARRAYLEN(DesfireAlgoOpts);
const CLIParserOption DesfireKDFAlgoOpts[] = {
{MFDES_KDF_ALGO_NONE, "none"},
@ -58,7 +58,7 @@ const CLIParserOption DesfireKDFAlgoOpts[] = {
{MFDES_KDF_ALGO_GALLAGHER, "gallagher"},
{0, NULL},
};
const size_t DesfireKDFAlgoOptsLen = ARRAY_LENGTH(DesfireKDFAlgoOpts);
const size_t DesfireKDFAlgoOptsLen = ARRAYLEN(DesfireKDFAlgoOpts);
const CLIParserOption DesfireCommunicationModeOpts[] = {
{DCMPlain, "plain"},
@ -66,7 +66,7 @@ const CLIParserOption DesfireCommunicationModeOpts[] = {
{DCMEncrypted, "encrypt"},
{0, NULL},
};
const size_t DesfireCommunicationModeOptsLen = ARRAY_LENGTH(DesfireCommunicationModeOpts);
const size_t DesfireCommunicationModeOptsLen = ARRAYLEN(DesfireCommunicationModeOpts);
const CLIParserOption DesfireCommandSetOpts[] = {
{DCCNative, "native"},
@ -74,7 +74,7 @@ const CLIParserOption DesfireCommandSetOpts[] = {
{DCCISO, "iso"},
{0, NULL},
};
const size_t DesfireCommandSetOptsLen = ARRAY_LENGTH(DesfireCommandSetOpts);
const size_t DesfireCommandSetOptsLen = ARRAYLEN(DesfireCommandSetOpts);
const CLIParserOption DesfireSecureChannelOpts[] = {
{DACd40, "d40"},
@ -83,7 +83,7 @@ const CLIParserOption DesfireSecureChannelOpts[] = {
{DACLRP, "lrp"},
{0, NULL},
};
const size_t DesfireSecureChannelOptsLen = ARRAY_LENGTH(DesfireSecureChannelOpts);
const size_t DesfireSecureChannelOptsLen = ARRAYLEN(DesfireSecureChannelOpts);
const CLIParserOption DesfireFileAccessModeOpts[] = {
{0x00, "key0"},

View file

@ -205,7 +205,7 @@ static const CmdHeaderLengths_t CmdHeaderLengths[] = {
};
static uint8_t DesfireGetCmdHeaderLen(uint8_t cmd) {
for (int i = 0; i < ARRAY_LENGTH(CmdHeaderLengths); i++)
for (int i = 0; i < ARRAYLEN(CmdHeaderLengths); i++)
if (CmdHeaderLengths[i].cmd == cmd)
return CmdHeaderLengths[i].len;
@ -229,7 +229,7 @@ static bool DesfireEV1D40TransmitMAC(DesfireContext_t *ctx, uint8_t cmd) {
if (ctx->secureChannel != DACd40 && ctx->secureChannel != DACEV1)
return true;
for (int i = 0; i < ARRAY_LENGTH(EV1D40TransmitMAC); i++)
for (int i = 0; i < ARRAYLEN(EV1D40TransmitMAC); i++)
if (EV1D40TransmitMAC[i] == cmd)
return true;
@ -248,7 +248,7 @@ static bool DesfireEV1D40ReceiveMAC(DesfireContext_t *ctx, uint8_t cmd) {
if (ctx->secureChannel != DACd40)
return true;
for (int i = 0; i < ARRAY_LENGTH(D40ReceiveMAC); i++)
for (int i = 0; i < ARRAYLEN(D40ReceiveMAC); i++)
if (D40ReceiveMAC[i] == cmd)
return true;
@ -267,7 +267,7 @@ static const uint8_t ISOChannelValidCmd[] = {
};
static bool DesfireISOChannelValidCmd(uint8_t cmd) {
for (int i = 0; i < ARRAY_LENGTH(ISOChannelValidCmd); i++)
for (int i = 0; i < ARRAYLEN(ISOChannelValidCmd); i++)
if (ISOChannelValidCmd[i] == cmd)
return true;
@ -828,7 +828,7 @@ bool PrintChannelModeWarning(uint8_t cmd, DesfireSecureChannel secureChannel, De
}
bool found = false;
for (int i = 0; i < ARRAY_LENGTH(AllowedChannelModes); i++)
for (int i = 0; i < ARRAYLEN(AllowedChannelModes); i++)
if (AllowedChannelModes[i].cmd == cmd) {
// full compare
if (AllowedChannelModes[i].secureChannel == secureChannel &&

View file

@ -24,8 +24,6 @@
#include <endian.h>
#endif
#define ARRAY_LENGTH( array ) ( sizeof( array ) / sizeof( *( array ) ) )
// used for save/load files
#ifndef FILE_PATH_SIZE
# define FILE_PATH_SIZE 1000