cppcheck fixes

This commit is contained in:
iceman1001 2022-01-04 07:28:20 +01:00
commit cd825bfac8

View file

@ -179,7 +179,7 @@ static void dither_chan_inplace(int16_t *chan, uint16_t width, uint16_t height)
int16_t newp = oldp > 127 ? 255 : 0; int16_t newp = oldp > 127 ? 255 : 0;
chan[X + Y * width] = newp; chan[X + Y * width] = newp;
int16_t err = oldp - newp; int16_t err = oldp - newp;
float m[] = {7, 3, 5, 1}; const float m[] = {7, 3, 5, 1};
if (X < width - 1) { if (X < width - 1) {
chan[X + 1 + Y * width] = chan[X + 1 + Y * width] + m[0] / 16 * err; chan[X + 1 + Y * width] = chan[X + 1 + Y * width] + m[0] / 16 * err;
} }
@ -239,7 +239,7 @@ static void dither_rgb_inplace(int16_t *chanR, int16_t *chanG, int16_t *chanB, u
int16_t errR = oldR - newR; int16_t errR = oldR - newR;
int16_t errG = oldG - newG; int16_t errG = oldG - newG;
int16_t errB = oldB - newB; int16_t errB = oldB - newB;
float m[] = {7, 3, 5, 1}; const float m[] = {7, 3, 5, 1};
if (Y % 2) { if (Y % 2) {
if (XX > 0) { if (XX > 0) {
chanR[XX - 1 + Y * width] = (chanR[XX - 1 + Y * width] + m[0] / 16 * errR); chanR[XX - 1 + Y * width] = (chanR[XX - 1 + Y * width] + m[0] / 16 * errR);
@ -593,7 +593,7 @@ static int start_drawing_1in54B(uint8_t model_nr, uint8_t *black, uint8_t *red)
uint8_t step_4[2] = {0xcd, 0x04}; uint8_t step_4[2] = {0xcd, 0x04};
uint8_t step_6[2] = {0xcd, 0x06}; uint8_t step_6[2] = {0xcd, 0x06};
uint8_t rx[20] = {0}; uint8_t rx[20] = {0};
uint16_t actrxlen[20], i = 0, progress = 0; uint16_t actrxlen[20], i, progress;
if (model_nr == M1in54B) { if (model_nr == M1in54B) {
step_5[2] = 100; step_5[2] = 100;
@ -616,6 +616,7 @@ static int start_drawing_1in54B(uint8_t model_nr, uint8_t *black, uint8_t *red)
if (ret != PM3_SUCCESS) { if (ret != PM3_SUCCESS) {
return ret; return ret;
} }
PrintAndLogEx(DEBUG, "1.54_Step7: e-paper config2 (red)"); PrintAndLogEx(DEBUG, "1.54_Step7: e-paper config2 (red)");
if (model_nr == M1in54B) { //1.54inch B Keychain if (model_nr == M1in54B) { //1.54inch B Keychain
for (i = 0; i < 50; i++) { for (i = 0; i < 50; i++) {
@ -635,12 +636,13 @@ static int start_drawing_1in54B(uint8_t model_nr, uint8_t *black, uint8_t *red)
if (ret != PM3_SUCCESS) { if (ret != PM3_SUCCESS) {
return ret; return ret;
} }
PrintAndLogEx(DEBUG, "1.54_Step9"); PrintAndLogEx(DEBUG, "1.54_Step9");
return PM3_SUCCESS; return PM3_SUCCESS;
} }
static int start_drawing(uint8_t model_nr, uint8_t *black, uint8_t *red) { static int start_drawing(uint8_t model_nr, uint8_t *black, uint8_t *red) {
uint8_t progress = 0; uint8_t progress;
uint8_t step0[2] = {0xcd, 0x0d}; uint8_t step0[2] = {0xcd, 0x0d};
uint8_t step1[3] = {0xcd, 0x00, 10}; // select e-paper type and reset e-paper uint8_t step1[3] = {0xcd, 0x00, 10}; // select e-paper type and reset e-paper
// 4 :2.13inch e-Paper // 4 :2.13inch e-Paper
@ -667,14 +669,12 @@ static int start_drawing(uint8_t model_nr, uint8_t *black, uint8_t *red) {
// uint8_t step13[2]={0xcd,0x0b}; // Judge whether the power supply is turned off successfully // uint8_t step13[2]={0xcd,0x0b}; // Judge whether the power supply is turned off successfully
// uint8_t step14[2]={0xcd,0x0c}; // The end of the transmission // uint8_t step14[2]={0xcd,0x0c}; // The end of the transmission
uint8_t rx[20]; uint8_t rx[20];
uint16_t actrxlen[20], i = 0; uint16_t actrxlen[20], i;
clearCommandBuffer(); clearCommandBuffer();
SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0, NULL, 0); SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0, NULL, 0);
PacketResponseNG resp; PacketResponseNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 2500) == false) {
PrintAndLogEx(ERR, "No tag found"); PrintAndLogEx(ERR, "No tag found");
DropField(); DropField();
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
@ -711,12 +711,13 @@ static int start_drawing(uint8_t model_nr, uint8_t *black, uint8_t *red) {
return PM3_ESOFT; return PM3_ESOFT;
} }
PrintAndLogEx(DEBUG, "model_nr = %d", model_nr); PrintAndLogEx(DEBUG, "model_nr = %d", model_nr);
int ret;
PrintAndLogEx(DEBUG, "Step0"); PrintAndLogEx(DEBUG, "Step0");
ret = transceive_blocking(step0, 2, rx, 20, actrxlen, true); //cd 0d int ret = transceive_blocking(step0, 2, rx, 20, actrxlen, true); //cd 0d
if (ret != PM3_SUCCESS) { if (ret != PM3_SUCCESS) {
return ret; return ret;
} }
PrintAndLogEx(DEBUG, "Step1: e-paper config"); PrintAndLogEx(DEBUG, "Step1: e-paper config");
// step1[2] screen model // step1[2] screen model
// step8[2] nr of bytes sent at once // step8[2] nr of bytes sent at once
@ -762,24 +763,28 @@ static int start_drawing(uint8_t model_nr, uint8_t *black, uint8_t *red) {
if (ret != PM3_SUCCESS) { if (ret != PM3_SUCCESS) {
return ret; return ret;
} }
msleep(100); msleep(100);
PrintAndLogEx(DEBUG, "Step2: e-paper normal mode type"); PrintAndLogEx(DEBUG, "Step2: e-paper normal mode type");
ret = transceive_blocking(step2, 2, rx, 20, actrxlen, true); // cd 01 ret = transceive_blocking(step2, 2, rx, 20, actrxlen, true); // cd 01
if (ret != PM3_SUCCESS) { if (ret != PM3_SUCCESS) {
return ret; return ret;
} }
msleep(100); msleep(100);
PrintAndLogEx(DEBUG, "Step3: e-paper config1"); PrintAndLogEx(DEBUG, "Step3: e-paper config1");
ret = transceive_blocking(step3, 2, rx, 20, actrxlen, true); // cd 02 ret = transceive_blocking(step3, 2, rx, 20, actrxlen, true); // cd 02
if (ret != PM3_SUCCESS) { if (ret != PM3_SUCCESS) {
return ret; return ret;
} }
msleep(200); msleep(200);
PrintAndLogEx(DEBUG, "Step4: e-paper power on"); PrintAndLogEx(DEBUG, "Step4: e-paper power on");
ret = transceive_blocking(step4, 2, rx, 20, actrxlen, true); // cd 03 ret = transceive_blocking(step4, 2, rx, 20, actrxlen, true); // cd 03
if (ret != PM3_SUCCESS) { if (ret != PM3_SUCCESS) {
return ret; return ret;
} }
if (model_nr == M1in54B) { if (model_nr == M1in54B) {
// 1.54B Keychain handler // 1.54B Keychain handler
PrintAndLogEx(DEBUG, "Start_Drawing_1in54B"); PrintAndLogEx(DEBUG, "Start_Drawing_1in54B");
@ -939,6 +944,7 @@ static int start_drawing(uint8_t model_nr, uint8_t *black, uint8_t *red) {
} else if (model_nr == M7in5HD) { } else if (model_nr == M7in5HD) {
msleep(1000); msleep(1000);
} }
uint8_t fail_num = 0; uint8_t fail_num = 0;
while (1) { while (1) {
if (model_nr == M1in54B) { if (model_nr == M1in54B) {