Bug 1639033 - Fix signed-unsigned comparison warning in basicutil.c. r=kjacobs
authorJeff Walden <jwalden@mit.edu>
Tue, 19 May 2020 20:09:44 +0000
changeset 15623 98390eef50a10d496d35e38ef03f2248a47abd92
parent 15622 8d7c96ab80a78c84214b46d4fc0b8ecfd5904cb3
child 15624 6512178a58f5108488feda1da805afa6a1ab6315
push id3751
push userkjacobs@mozilla.com
push dateFri, 22 May 2020 20:56:57 +0000
reviewerskjacobs
bugs1639033
Bug 1639033 - Fix signed-unsigned comparison warning in basicutil.c. r=kjacobs Differential Revision: https://phabricator.services.mozilla.com/D75840
cmd/lib/basicutil.c
--- a/cmd/lib/basicutil.c
+++ b/cmd/lib/basicutil.c
@@ -12,16 +12,17 @@
 #include "prerror.h"
 #include "prprf.h"
 #include "plgetopt.h"
 #include "prenv.h"
 #include "prnetdb.h"
 
 #include "basicutil.h"
 #include <stdarg.h>
+#include <stddef.h>
 #include <sys/stat.h>
 #include <errno.h>
 
 #ifdef XP_UNIX
 #include <unistd.h>
 #endif
 
 #include "secoid.h"
@@ -627,17 +628,18 @@ SECU_GetOptionArg(const secuCommand *cmd
     else
         return NULL;
 }
 
 void
 SECU_PrintPRandOSError(const char *progName)
 {
     char buffer[513];
-    PRInt32 errLen = PR_GetErrorTextLength();
+    PRInt32 errLenInt = PR_GetErrorTextLength();
+    size_t errLen = errLenInt < 0 ? 0 : (size_t)errLenInt;
     if (errLen > 0 && errLen < sizeof buffer) {
         PR_GetErrorText(buffer);
     }
     SECU_PrintError(progName, "function failed");
     if (errLen > 0 && errLen < sizeof buffer) {
         PR_fprintf(PR_STDERR, "\t%s\n", buffer);
     }
 }