Skip to content

Commit

Permalink
Two -Wsign-compare warnings in mythes.cxx #3
Browse files Browse the repository at this point in the history
to solve #3
  • Loading branch information
jspitz authored and Caolán McNamara committed Aug 21, 2022
1 parent 6b7f354 commit 8f126c3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mythes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int MyThes::thInitialize(const char* idxpath, const char* datpath)
readLine(pifile,wrd,MAX_WD_LEN);
int idxsz = atoi(wrd);

if (idxsz <= 0 || idxsz > std::numeric_limits<int>::max() / sizeof(char*)) {
if (idxsz <= 0 || static_cast<unsigned int>(idxsz) > std::numeric_limits<int>::max() / sizeof(char*)) {
fprintf(stderr,"Error - bad index %d\n", idxsz);
fclose(pifile);
return 0;
Expand Down Expand Up @@ -176,7 +176,7 @@ int MyThes::Lookup(const char * pText, int len, mentry** pme)
return 0;
}
int nmeanings = atoi(buf+np+1);
if (nmeanings < 0 || nmeanings > std::numeric_limits<int>::max() / sizeof(mentry))
if (nmeanings < 0 || static_cast<unsigned int>(nmeanings) > std::numeric_limits<int>::max() / sizeof(mentry))
nmeanings = 0;
*pme = (mentry*)(nmeanings ? malloc(nmeanings * sizeof(mentry)) : NULL);
if (!(*pme)) {
Expand Down

0 comments on commit 8f126c3

Please sign in to comment.