Explorar o código

remove more bugs found by clang

Julius Pfrommer %!s(int64=10) %!d(string=hai) anos
pai
achega
cc9da73a45
Modificáronse 4 ficheiros con 13 adicións e 9 borrados
  1. 2 2
      CMakeLists.txt
  2. 6 3
      examples/networklayer_tcp.c
  3. 2 0
      src/server/ua_session_manager.c
  4. 3 4
      src/ua_config.h.in

+ 2 - 2
CMakeLists.txt

@@ -87,8 +87,6 @@ if(ENABLE_JSON_ENCODING)
     list(APPEND generate_src_options "--with-json")
 endif(ENABLE_JSON_ENCODING)
 
-configure_file("src/ua_config.h.in" "${PROJECT_BINARY_DIR}/src_generated/ua_config.h")
-
 ## multithreading
 option(ENABLE_MULTITHREADING "Enable multithreading" OFF)
 if(ENABLE_MULTITHREADING)
@@ -113,6 +111,8 @@ if(ENABLE_COVERAGE)
     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
 endif(ENABLE_COVERAGE)
 
+configure_file("src/ua_config.h.in" "${PROJECT_BINARY_DIR}/src_generated/ua_config.h")
+
 # build generated code
 file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src_generated")
 include_directories("${PROJECT_BINARY_DIR}/src_generated") 

+ 6 - 3
examples/networklayer_tcp.c

@@ -52,7 +52,10 @@ typedef struct TCPConnectionHandle {
 
 UA_Int32 NetworklayerTCP_new(NetworklayerTCP **newlayer, UA_ConnectionConfig localConf,
 							 UA_UInt32 port) {
-	UA_alloc((void**)newlayer, sizeof(NetworklayerTCP));
+    UA_UInt32 retval = UA_SUCCESS;
+    retval |= UA_alloc((void**)newlayer, sizeof(NetworklayerTCP));
+    if(retval != UA_SUCCESS)
+        return UA_ERROR;
 	(*newlayer)->localConf = localConf;
 	(*newlayer)->port = port;
 	(*newlayer)->connectionsSize = 0;
@@ -135,9 +138,9 @@ UA_Int32 writeHandle(TCPConnectionHandle *handle, UA_ByteStringArray gather_buf)
 		} while (n == -1L && errno == EINTR);
 
 		if (n >= 0) {
-			nWritten += n;
-			break;
 			// TODO: handle incompletely send messages
+			/* nWritten += n; */
+			break;
 		} else {
 			// TODO: error handling
 			break;

+ 2 - 0
src/server/ua_session_manager.c

@@ -13,6 +13,8 @@ UA_Int32 UA_SessionManager_new(UA_SessionManager **sessionManager, UA_UInt32 max
                                UA_UInt32 sessionTimeout, UA_UInt32 startSessionId) {
     UA_Int32 retval = UA_SUCCESS;
     retval |= UA_alloc((void **)sessionManager, sizeof(UA_SessionManager));
+    if(retval != UA_SUCCESS)
+        return UA_ERROR;
     retval |= UA_list_init(&(*sessionManager)->sessions);
     (*sessionManager)->maxSessionCount = maxSessionCount;
     (*sessionManager)->lastSessionId   = startSessionId;

+ 3 - 4
src/ua_config.h.in

@@ -1,9 +1,8 @@
 /* Buid options and configuration (set by cmake) */
-#define UA_ENCODING_AMOUNT @UA_ENCODING_AMOUNT@
-#cmakedefine ENABLE_MULTITHREADING
-#cmakedefine ENABLE_LOGGING
-#define UA_LOGLEVEL @UA_LOGLEVEL@
+#define UA_ENCODING_AMOUNT ${UA_ENCODING_AMOUNT}
+#define UA_LOGLEVEL ${UA_LOGLEVEL}
 
+#cmakedefine ENABLE_MULTITHREADING
 #cmakedefine MSVC
 #cmakedefine WIN32