Browse Source

small improvements

Julius Pfrommer 10 years ago
parent
commit
8db65c1aed
4 changed files with 12 additions and 13 deletions
  1. 2 3
      examples/networklayer_tcp.c
  2. 2 2
      src/ua_types.h
  3. 2 2
      src/util/ua_list.c
  4. 6 6
      tests/check_list.c

+ 2 - 3
examples/networklayer_tcp.c

@@ -51,9 +51,8 @@ typedef struct TCPConnectionHandle {
 
 UA_Int32 NetworklayerTCP_new(NetworklayerTCP **newlayer, UA_ConnectionConfig localConf,
 							 UA_UInt32 port) {
-    UA_UInt32 retval = UA_SUCCESS;
-    newlayer = malloc(sizeof(NetworklayerTCP));
-    if(retval != UA_SUCCESS)
+    *newlayer = malloc(sizeof(NetworklayerTCP));
+    if(newlayer == UA_NULL)
         return UA_ERROR;
 	(*newlayer)->localConf = localConf;
 	(*newlayer)->port = port;

+ 2 - 2
src/ua_types.h

@@ -65,9 +65,9 @@ extern "C" {
 
 /* Boolean values and null */
 #define UA_TRUE (42 == 42)
-#define TRUE UA_TRUE
+//#define TRUE UA_TRUE
 #define UA_FALSE (!UA_TRUE)
-#define FALSE UA_FALSE
+//#define FALSE UA_FALSE
 
 /* Compare values */
 #define UA_EQUAL 0

+ 2 - 2
src/util/ua_list.c

@@ -202,7 +202,7 @@ UA_list_Element *UA_list_find(UA_list_List *const list, UA_list_PayloadMatcher m
     if(matcher) {
         UA_list_Element *current = list->first;
         while(current) {
-            if(matcher && (*matcher)(current->payload) == TRUE)
+            if(matcher && (*matcher)(current->payload) == UA_TRUE)
                 return current;
             current = current->next;
         }
@@ -216,7 +216,7 @@ UA_list_Element *UA_list_search(UA_list_List *const list, UA_list_PayloadCompare
     if(compare) {
         UA_list_Element *current = list->first;
         while(current) {
-            if(compare && (*compare)(current->payload, payload) == TRUE)
+            if(compare && (*compare)(current->payload, payload) == UA_TRUE)
                 return current;
             current = current->next;
         }

+ 6 - 6
tests/check_list.c

@@ -24,22 +24,22 @@ void freer(void* payload){
 
 _Bool matcher(void* payload){
 	if(payload == UA_NULL){
-		return FALSE;
+		return UA_FALSE;
 	}
 	if(*((UA_Int32*)payload) == 42){
-		return TRUE;
+		return UA_TRUE;
 	}
-	return FALSE;
+	return UA_FALSE;
 }
 
 _Bool matcher2(void* payload){
 	if(payload == UA_NULL){
-		return FALSE;
+		return UA_FALSE;
 	}
 	if(*((UA_Int32*)payload) == 43){
-		return TRUE;
+		return UA_TRUE;
 	}
-	return FALSE;
+	return UA_FALSE;
 }
 
 _Bool comparer(void* payload, void* otherPayload) {