소스 검색

Merge pull request #4 from ghalliday/bug81880

WIP: #81880 Fix some warnings from g++

Reviewed-by: Richard Chapman <rchapman@hpccsystems.com>
richardkchapman 14 년 전
부모
커밋
dd49d8b40e
9개의 변경된 파일43개의 추가작업 그리고 13개의 파일을 삭제
  1. 2 5
      dali/dfu/dfuserver.cpp
  2. 2 2
      dali/dfuplus/main.cpp
  3. 1 1
      ecl/hqlcpp/hqlhtcpp.cpp
  4. 1 1
      ecl/hqlcpp/hqlttcpp.cpp
  5. 1 0
      system/jlib/jerror.hpp
  6. 13 0
      system/jlib/jfile.cpp
  7. 1 0
      system/jlib/jfile.hpp
  8. 5 2
      system/jlib/jkeyboard.cpp
  9. 17 2
      tools/testsocket/testsocket.cpp

+ 2 - 5
dali/dfu/dfuserver.cpp

@@ -149,11 +149,8 @@ int main(int argc, const char *argv[])
         if (logdir.length() && recursiveCreateDirectory(logdir.str()))
             logname.append(logdir);
         else
-        {
-            char cwd[1024];
-            GetCurrentDirectory(1024, cwd);
-            logname.append(cwd);
-        }
+            appendCurrentDirectory(logname, true);
+
         if (logname.length() && logname.charAt(logname.length()-1) != PATHSEPCHAR)
             logname.append(PATHSEPCHAR);
         logname.append("dfuserver");

+ 2 - 2
dali/dfuplus/main.cpp

@@ -258,8 +258,8 @@ void promptFor(const char *prompt, const char *prop, bool hide, IProperties * gl
     else
     {
         char buf[100];
-        fgets(buf, 100, stdin);
-        result.append(buf);
+        if (fgets(buf, 100, stdin))
+            result.append(buf);
         if (result.length() && result.charAt(result.length()-1)=='\n')
             result.remove(result.length()-1, 1);
     }

+ 1 - 1
ecl/hqlcpp/hqlhtcpp.cpp

@@ -3190,7 +3190,7 @@ void HqlCppTranslator::doBuildFunction(BuildCtx & ctx, ITypeInfo * type, const c
 
         StringBuffer s, returnParameters;
         s.append("virtual ");
-        expandFunctionReturnType(s, returnParameters, type, false);
+        expandFunctionReturnType(s, returnParameters, type, NULL);
         s.append(" ").append(name).append("(").append(returnParameters).append(")");
 
         BuildCtx funcctx(ctx);

+ 1 - 1
ecl/hqlcpp/hqlttcpp.cpp

@@ -1311,7 +1311,7 @@ IHqlExpression * SequenceNumberAllocator::doTransformRootExpr(IHqlExpression * e
                     args.append(*LINK(transformed->queryChild(0)));
                 else
                     args.append(*LINK(transformed));
-                nextSequence(args, NULL, false, NULL, true, NULL);
+                nextSequence(args, NULL, NULL, NULL, true, NULL);
                 IHqlExpression * ret = createSetResult(args);
                 if (isOuterWorkflow)
                 {

+ 1 - 0
system/jlib/jerror.hpp

@@ -27,6 +27,7 @@
 
 #define JLIBERR_BadlyFormedDateTime             1000
 #define JLIBERR_BadUtf8InArguments              1001
+#define JLIBERR_InternalError                   1002
 
 //---- Text for all errors (make it easy to internationalise) ---------------------------
 

+ 13 - 0
system/jlib/jfile.cpp

@@ -41,6 +41,7 @@
 
 #include "time.h"
 
+#include "jerror.hpp"
 #include "jlib.hpp"
 #include "jio.hpp"
 #include "jmisc.hpp"
@@ -6331,3 +6332,15 @@ extern jlib_decl void writeSentinelFile(IFile * sentinelFile)
     Owned<IFileIO> sentinel = sentinelFile->open(IFOcreate);
     sentinel->write(0, 5, "rerun");
 }
+
+jlib_decl StringBuffer & appendCurrentDirectory(StringBuffer & target, bool blankIfFails)
+{
+    char temp[_MAX_PATH+1];
+    if (!getcwd(temp,sizeof(temp)))
+    {
+        if (blankIfFails)
+            return target;
+        throw MakeStringException(JLIBERR_InternalError, "getcwd failed (%d)", errno);
+    }
+    return target.append(temp);
+}

+ 1 - 0
system/jlib/jfile.hpp

@@ -600,5 +600,6 @@ extern jlib_decl IFileIOCache* createFileIOCache(unsigned max);
 extern jlib_decl void setIORetryCount(unsigned _ioRetryCount); // default 0 == off, retries if read op. fails, linux only
 extern jlib_decl IFile * createSentinelTarget(const char * argv0, const char * component);
 extern jlib_decl void writeSentinelFile(IFile * file);
+extern jlib_decl StringBuffer & appendCurrentDirectory(StringBuffer & target, bool blankIfFails);
 
 #endif

+ 5 - 2
system/jlib/jkeyboard.cpp

@@ -78,8 +78,11 @@ int keyboard::getch()
         ch = peek_character;
         peek_character = -1;
     } 
-    else 
-        read(0,&ch,1);
+    else
+    {
+        if (read(0,&ch,1) == 0)
+            return -1;
+    }
 
     return ch;
 #else

+ 17 - 2
tools/testsocket/testsocket.cpp

@@ -100,9 +100,16 @@ void sendFile(const char * filename, ISocket * socket)
         size = ftell(in);
         fseek(in, 0, SEEK_SET);
         buff = malloc(size);
-        fread(buff, 1, size, in);
+        size_t numRead = fread(buff, 1, size, in);
         fclose(in);
+        if (numRead != size)
+		{
+            printf("read from file %s failed (%u/%u)\n", filename, (unsigned)numRead, size);
+            size = 0;
+		}
     }
+	else
+		printf("read from file %s failed\n", filename);
 
     unsigned dllLen = size;
     _WINREV(dllLen);
@@ -131,9 +138,17 @@ void sendFileChunk(const char * filename, offset_t offset, ISocket * socket)
         if (size > CHUNK_SIZE)
             size = CHUNK_SIZE;
         buff = malloc(size);
-        fread(buff, 1, size, in);
+        size_t numRead = fread(buff, 1, size, in);
         fclose(in);
+        if (numRead != size)
+		{
+            printf("read from file %s failed (%u/%u)\n", filename, (unsigned)numRead, size);
+            size = 0;
+		}
     }
+	else
+		printf("read from file %s failed\n", filename);
+
 
     if (size > 0)
     {