فهرست منبع

Merge pull request #6971 from ghalliday/issue12993

HPCC-12993 Fix gcc warnings

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 10 سال پیش
والد
کامیت
b7380f4eee

+ 16 - 0
common/remote/hooks/libarchive/archive.cpp

@@ -184,8 +184,12 @@ public:
         archive_read_support_compression_bzip2(archive);
 #else
         archive_read_support_format_all(archive);
+#if (ARCHIVE_VERSION_NUMBER >= 3000000)
+        archive_read_support_filter_all(archive);
+#else
         archive_read_support_compression_all(archive);
 #endif
+#endif
         int retcode = archive_read_open_filename(archive, container, 10240);
         if (retcode == ARCHIVE_OK)
         {
@@ -204,7 +208,11 @@ public:
     }
     ~ArchiveFileIO()
     {
+#if (ARCHIVE_VERSION_NUMBER >= 3000000)
+        archive_read_free(archive);
+#else
         archive_read_finish(archive);
+#endif
     }
 
     virtual size32_t read(offset_t pos, size32_t len, void * _data)
@@ -486,8 +494,12 @@ public:
         archive_read_support_compression_bzip2(archive);
 #else
         archive_read_support_format_all(archive);
+#if (ARCHIVE_VERSION_NUMBER >= 3000000)
+        archive_read_support_filter_all(archive);
+#else
         archive_read_support_compression_all(archive);
 #endif
+#endif
         int retcode = archive_read_open_filename(archive, container, 10240);
         if (retcode == ARCHIVE_OK)
         {
@@ -522,7 +534,11 @@ public:
             }
             archive_entry_free(entry);
         }
+#if (ARCHIVE_VERSION_NUMBER >= 3000000)
+        archive_read_free(archive);
+#else
         archive_read_finish(archive);
+#endif
         return next();
     }
 

+ 2 - 1
ecl/ecl-bundle/ecl-bundle.cpp

@@ -281,7 +281,8 @@ StringBuffer & fetchURL(const char *bundleName, StringBuffer &fetchedLocation)
     // If the bundle name looks like a url, fetch it somewhere temporary first...
     if (isUrl(bundleName))
     {
-        // Put it into a temp directory - we need the filename to be right
+        //Put it into a temp directory - we need the filename to be right
+        //I don't think there is any way to disable the following warning....
         const char *tmp = tmpnam(NULL);
         recursiveCreateDirectory(tmp);
         deleteOnCloseDown.append(tmp);

+ 4 - 2
roxie/ccd/ccdfile.cpp

@@ -2734,7 +2734,8 @@ protected:
 
         f = open("test.buddy", _O_WRONLY | _O_CREAT | _O_TRUNC, _S_IREAD | _S_IWRITE);
         val = 2;
-        write(f, &val, sizeof(int));
+        ssize_t numwritten = write(f, &val, sizeof(int));
+        CPPUNIT_ASSERT(numwritten == sizeof(int));
         close(f);
 
         // Reading it should still read 1...
@@ -2753,7 +2754,8 @@ protected:
         // And the data in the file should be 2
         f = open("test.local", _O_RDONLY);
         val = 0;
-        read(f, &val, sizeof(int));
+        ssize_t numread = read(f, &val, sizeof(int));
+        CPPUNIT_ASSERT(numread == sizeof(int));
         close(f);
         CPPUNIT_ASSERT(val==2);
 

+ 18 - 4
system/jlib/jutil.cpp

@@ -27,6 +27,7 @@
 #include "jmutex.hpp"
 #include "jfile.hpp"
 #include "jprop.hpp"
+#include "jerror.hpp"
 #ifdef _WIN32
 #include <mmsystem.h> // for timeGetTime 
 #include <float.h> //for _isnan and _fpclass
@@ -1576,7 +1577,16 @@ void doStackProbe()
 {
     byte local;
     const volatile byte * x = (const byte *)&local;
+//The whole point of this function is to force memory to be accessed on the stack to avoid page faults.
+//Therefore disable the gcc warning.
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wuninitialized"
+#endif
     byte forceload = x[-4096];
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
 }
 
 #ifdef _WIN32
@@ -1914,14 +1924,18 @@ public:
     {
         saveuid = geteuid();
         savegid = getegid();
-        setegid(gid);
-        seteuid(uid);
+        if (setegid(gid) == -1)
+            throw makeOsException(errno, "Failed to set effective group id");
+        if (seteuid(uid) == -1)
+            throw makeOsException(errno, "Failed to set effective user id");
     }
 
     void revert()
     {
-        seteuid(saveuid);
-        setegid(savegid);
+        if (seteuid(saveuid) == -1)
+            throw makeOsException(errno, "Failed to restore effective group id");
+        if (setegid(savegid) == -1)
+            throw makeOsException(errno, "Failed to restore effective user id");
     }
 
     const char *username()

+ 1 - 1
system/xmllib/libxslt_processor.cpp

@@ -823,7 +823,7 @@ void globalLibXsltExtensionHandler(xmlXPathParserContextPtr ctxt, int nargs)
             msg.append(" without any arguments\n");
         else
             msg.append(" with too many arguments\n");
-        xsltGenericError(xsltGenericErrorContext, msg.str());
+        xsltGenericError(xsltGenericErrorContext, "%s", msg.str());
         ctxt->error = XPATH_INVALID_ARITY;
         return;
     }

+ 7 - 2
tools/initldap/initldap.cpp

@@ -63,7 +63,9 @@ bool initLDAP(IPropertyTree * ldapProps)
     fprintf(stdout, "\nEnter the '%s' LDAP Admin User name on '%s'...",serverType.get(),ldapAddress.str());
     do
     {
-        fgets(buff, sizeof(buff), stdin);
+        char * line = fgets(buff, sizeof(buff), stdin);
+        if (!line)
+            return false;
     }
     while (buff[0] == (char)'\n');
 
@@ -72,7 +74,10 @@ bool initLDAP(IPropertyTree * ldapProps)
     StringAttr ldapUser(buff);
 
     fprintf(stdout, "Enter the LDAP Admin user '%s' password...",ldapUser.get());
-    fgets(buff, sizeof(buff), stdin);
+    char * line = fgets(buff, sizeof(buff), stdin);
+    if (!line)
+        return false;
+
     if (buff[strlen(buff)-1] == '\n')
         buff[strlen(buff)-1] = (char)NULL;
     StringAttr ldapPwd(buff);