comparison of integers of different signs [-Wsign-compare]

This commit is contained in:
Philippe Teuwen 2019-04-13 23:55:58 +02:00
commit 993728072a
4 changed files with 17 additions and 16 deletions

View file

@ -457,12 +457,12 @@ int ASKDemod_ext(const char *Cmd, bool verbose, bool emSearch, uint8_t askType,
int invert = 0;
int clk = 0;
int maxErr = 100;
int maxLen = 0;
size_t maxLen = 0;
uint8_t askamp = 0;
char amp = tolower(param_getchar(Cmd, 0));
uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0};
sscanf(Cmd, "%i %i %i %i %c", &clk, &invert, &maxErr, &maxLen, &amp);
sscanf(Cmd, "%i %i %i %zu %c", &clk, &invert, &maxErr, &maxLen, &amp);
if (!maxLen) maxLen = BIGBUF_SIZE;
@ -573,7 +573,8 @@ static int Cmdaskmandemod(const char *Cmd) {
static int Cmdmandecoderaw(const char *Cmd) {
size_t size = 0;
int high = 0, low = 0;
int i = 0, errCnt = 0, invert = 0, maxErr = 20;
size_t i = 0;
int errCnt = 0, invert = 0, maxErr = 20;
char cmdp = tolower(param_getchar(Cmd, 0));
if (strlen(Cmd) > 5 || cmdp == 'h') return usage_data_manrawdecode();
@ -724,7 +725,7 @@ static int Cmdaskrawdemod(const char *Cmd) {
return ASKDemod(Cmd, true, false, 0);
}
int AutoCorrelate(const int *in, int *out, size_t len, int window, bool SaveGrph, bool verbose) {
int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveGrph, bool verbose) {
// sanity check
if (window > len) window = len;
@ -744,7 +745,7 @@ int AutoCorrelate(const int *in, int *out, size_t len, int window, bool SaveGrph
static int CorrelBuffer[MAX_GRAPH_TRACE_LEN];
for (int i = 0; i < len - window; ++i) {
for (size_t i = 0; i < len - window; ++i) {
for (size_t j = 0; j < (len - i); j++) {
autocv += (in[j] - mean) * (in[j + i] - mean);
@ -766,14 +767,14 @@ int AutoCorrelate(const int *in, int *out, size_t len, int window, bool SaveGrph
//
int hi = 0, idx = 0;
int distance = 0, hi_1 = 0, idx_1 = 0;
for (int i = 0; i <= len; ++i) {
for (size_t i = 0; i <= len; ++i) {
if (CorrelBuffer[i] > hi) {
hi = CorrelBuffer[i];
idx = i;
}
}
for (int i = idx + 1; i <= window; ++i) {
for (size_t i = idx + 1; i <= window; ++i) {
if (CorrelBuffer[i] > hi_1) {
hi_1 = CorrelBuffer[i];
idx_1 = i;
@ -856,8 +857,8 @@ static int CmdBitsamples(const char *Cmd) {
return false;
}
for (int j = 0; j < sizeof(got); j++) {
for (int k = 0; k < 8; k++) {
for (size_t j = 0; j < sizeof(got); j++) {
for (uint8_t k = 0; k < 8; k++) {
if (got[j] & (1 << (7 - k)))
GraphBuffer[cnt++] = 1;
else
@ -882,7 +883,7 @@ static int CmdBuffClear(const char *Cmd) {
static int CmdDec(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
for (int i = 0; i < (GraphTraceLen / 2); ++i)
for (size_t i = 0; i < (GraphTraceLen / 2); ++i)
GraphBuffer[i] = GraphBuffer[i * 2];
GraphTraceLen /= 2;
PrintAndLogEx(NORMAL, "decimated by 2");
@ -926,7 +927,7 @@ static int CmdGraphShiftZero(const char *Cmd) {
//set options from parameters entered with the command
sscanf(Cmd, "%i", &shift);
for (int i = 0; i < GraphTraceLen; i++) {
for (size_t i = 0; i < GraphTraceLen; i++) {
if (i + shift >= GraphTraceLen)
shiftedVal = GraphBuffer[i];
else

View file

@ -83,7 +83,7 @@ void printDemodBuff(void);
void setDemodBuff(uint8_t *buff, size_t size, size_t start_idx);
bool getDemodBuff(uint8_t *buff, size_t *size);
void save_restoreDB(uint8_t saveOpt);// option '1' to save DemodBuffer any other to restore
int AutoCorrelate(const int *in, int *out, size_t len, int window, bool SaveGrph, bool verbose);
int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveGrph, bool verbose);
int getSamples(int n, bool silent);
void setClockGrid(int clk, int offset);
int directionalThreshold(const int *in, int *out, size_t len, int8_t up, int8_t down);

View file

@ -39,7 +39,7 @@ COSEValueNameDesc_t COSEKeyTypeValueDesc[] = {
};
static COSEValueNameDesc_t *GetCOSEktyElm(int id) {
for (int i = 0; i < ARRAYLEN(COSEKeyTypeValueDesc); i++)
for (size_t i = 0; i < ARRAYLEN(COSEKeyTypeValueDesc); i++)
if (COSEKeyTypeValueDesc[i].Value == id)
return &COSEKeyTypeValueDesc[i];
return NULL;
@ -64,7 +64,7 @@ COSEValueTypeNameDesc_t COSECurvesDesc[] = {
};
static COSEValueTypeNameDesc_t *GetCOSECurveElm(int id) {
for (int i = 0; i < ARRAYLEN(COSECurvesDesc); i++)
for (size_t i = 0; i < ARRAYLEN(COSECurvesDesc); i++)
if (COSECurvesDesc[i].Value == id)
return &COSECurvesDesc[i];
return NULL;
@ -136,7 +136,7 @@ COSEValueNameDesc_t COSEAlg[] = {
};
static COSEValueNameDesc_t *GetCOSEAlgElm(int id) {
for (int i = 0; i < ARRAYLEN(COSEAlg); i++)
for (size_t i = 0; i < ARRAYLEN(COSEAlg); i++)
if (COSEAlg[i].Value == id)
return &COSEAlg[i];
return NULL;

View file

@ -41,7 +41,7 @@ extern bool GridLocked;
//Operations defined in data_operations
//int autoCorr(const int* in, int *out, size_t len, int window);
int AskEdgeDetect(const int *in, int *out, int len, int threshold);
int AutoCorrelate(const int *in, int *out, size_t len, int window, bool SaveGrph, bool verbose);
int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveGrph, bool verbose);
int directionalThreshold(const int *in, int *out, size_t len, int8_t up, int8_t down);
void save_restoreGB(uint8_t saveOpt);