]> git.lyx.org Git - lyx.git/commitdiff
Fix a GCC warning: comparing signed vs. unsigned
authorScott Kostyshak <skostysh@lyx.org>
Tue, 20 May 2014 11:46:22 +0000 (07:46 -0400)
committerScott Kostyshak <skostysh@lyx.org>
Tue, 20 May 2014 12:01:49 +0000 (08:01 -0400)
This also changes the type of an int to an ssize_t.

nRead is initialized as an ssize_t because it could
be negative. It is cast to a size_t for comparison
to the size of a vector, but only after we check
that nRead is not negative.

src/support/filetools.cpp

index 19d970146490d92e9e51b64f842764522156dd49..66d4b22701e2750567ac5789205de8b34bcb079e 100644 (file)
@@ -840,7 +840,7 @@ bool readLink(FileName const & file, FileName & link)
        string const encoded = file.toFilesystemEncoding();
 #ifdef HAVE_DEF_PATH_MAX
        char linkbuffer[PATH_MAX + 1];
-       int const nRead = ::readlink(encoded.c_str(),
+       ssize_t const nRead = ::readlink(encoded.c_str(),
                                     linkbuffer, sizeof(linkbuffer) - 1);
        if (nRead <= 0)
                return false;
@@ -854,7 +854,7 @@ bool readLink(FileName const & file, FileName & link)
                if (nRead < 0) {
                        return false;
                }
-               if (nRead < buf.size() - 1) {
+               if (static_cast<size_t>(nRead) < buf.size() - 1) {
                        break;
                }
                buf.resize(buf.size() * 2);