Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two -Wsign-compare warnings in mythes.cxx #3

Closed
jspitz opened this issue Aug 12, 2017 · 0 comments
Closed

Two -Wsign-compare warnings in mythes.cxx #3

jspitz opened this issue Aug 12, 2017 · 0 comments

Comments

@jspitz
Copy link
Contributor

jspitz commented Aug 12, 2017

The following patch resolves the warnings:

diff --git a/3rdparty/mythes/1.2.5/mythes.cxx b/3rdparty/mythes/1.2.5/mythes.cxx
index ecf526e..b03799f 100644
--- a/3rdparty/mythes/1.2.5/mythes.cxx
+++ b/3rdparty/mythes/1.2.5/mythes.cxx
@@ -48,7 +48,8 @@ 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*)) {
+    // spitz: fix -Wsign-compare warning
+    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;
@@ -176,7 +177,8 @@ 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))
+    // spitz: fix -Wsign-compare warning
+    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)) {
caolanm pushed a commit that referenced this issue Aug 21, 2022
@caolanm caolanm closed this as completed Aug 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants