cppcheck fixes

This commit is contained in:
iceman1001 2022-01-08 15:29:11 +01:00
commit 0254b2a63a
3 changed files with 14 additions and 4 deletions

View file

@ -72,10 +72,17 @@ void DesfireClearIV(DesfireContext_t *ctx) {
void DesfireSetKey(DesfireContext_t *ctx, uint8_t keyNum, DesfireCryptoAlgorithm keyType, uint8_t *key) {
DesfireClearContext(ctx);
if (key == NULL)
return;
DesfireSetKeyNoClear(ctx, keyNum, keyType, key);
}
void DesfireSetKeyNoClear(DesfireContext_t *ctx, uint8_t keyNum, DesfireCryptoAlgorithm keyType, uint8_t *key) {
if (key == NULL)
return;
ctx->keyNum = keyNum;
ctx->keyType = keyType;
memcpy(ctx->key, key, desfire_get_key_length(keyType));
@ -93,8 +100,9 @@ void DesfireSetCommMode(DesfireContext_t *ctx, DesfireCommunicationMode commMode
void DesfireSetKdf(DesfireContext_t *ctx, uint8_t kdfAlgo, uint8_t *kdfInput, uint8_t kdfInputLen) {
ctx->kdfAlgo = kdfAlgo;
ctx->kdfInputLen = kdfInputLen;
if (kdfInputLen)
if (kdfInputLen) {
memcpy(ctx->kdfInput, kdfInput, kdfInputLen);
}
}
bool DesfireIsAuthenticated(DesfireContext_t *dctx) {

View file

@ -648,6 +648,10 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
int rows;
rl_reset_screen_size(); // refresh Readline idea of the actual screen width
rl_get_screen_size(&rows, &cols);
if (cols < 36)
return;
(void) rows;
if (prev_cols > cols) {
PrintAndLogEx(NORMAL, _CLEAR_ _TOP_ "");
@ -655,8 +659,6 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
prev_cols = cols;
#endif
int width = cols - 35;
if (width < 1)
return;
#define PERCENTAGE(V, T) ((V * width) / T)
// x/8 fractional part of the percentage

View file

@ -1422,7 +1422,7 @@ int HIDFindCardFormat(const char *format) {
bool HIDPack(int format_idx, wiegand_card_t *card, wiegand_message_t *packed, bool preamble) {
memset(packed, 0, sizeof(wiegand_message_t));
if (format_idx < 0 || format_idx >= ARRAYLEN(FormatTable) - 1)
if ((format_idx < 0) || (format_idx >= ARRAYLEN(FormatTable) - 1) )
return false;
return FormatTable[format_idx].Pack(card, packed, preamble);