Kaynağa Gözat

resolved warnings that prevented 'make clear check all' to complete

Leon Urbas 10 yıl önce
ebeveyn
işleme
3e3b84fec3

+ 3 - 3
src/opcua_namespace.c

@@ -161,9 +161,9 @@ UA_Int32 get_tc_writable_node(namespace *ns, transaction_context *tc, UA_NodeId
 	return UA_SUCCESS;
 }
 
-inline void release_node(ns_lock *lock) {
-	pthread_rwlock_unlock((pthread_rwlock_t *)lock);
-}
+//inline void release_node(ns_lock *lock) {
+//	pthread_rwlock_unlock((pthread_rwlock_t *)lock);
+//}
 
 void delete_node(namespace *ns, UA_NodeId *nodeid) {
 	ns_entry *slot;

+ 8 - 1
src/opcua_namespace.h

@@ -3,6 +3,8 @@
 
 /* Defines needed for pthread_rwlock_t */
 #define _XOPEN_SOURCE 500
+// this one is necessary on my 3.0.0-32-generic machine
+#define __USE_UNIX98
 #include <pthread.h>
 
 #include "opcua_basictypes.h"
@@ -50,7 +52,12 @@ UA_Int32 get_node(namespace *ns, UA_NodeId *nodeid, UA_Node ** const result, ns_
 UA_Int32 get_writable_node(namespace *ns, UA_NodeId *nodeid, UA_Node **result, ns_lock ** lock); // use only for _single_ writes.
 UA_Int32 get_tc_node(namespace *ns, transaction_context *tc, UA_NodeId *nodeid, UA_Node ** const result, ns_lock ** lock);
 UA_Int32 get_tc_writable_node(namespace *ns, transaction_context *tc, UA_NodeId *nodeid, UA_Node **result, ns_lock ** lock); // use only for _single_ writes.
-inline void release_node(ns_lock *lock);
+
+// inline void release_node(ns_lock *lock);
+// portable solution, see http://www.greenend.org.uk/rjk/tech/inline.html
+static inline void release_node(ns_lock *lock) {
+	pthread_rwlock_unlock((pthread_rwlock_t *)lock);
+}
 void delete_node(namespace *ns, UA_NodeId *nodeid);
 
 /* Internal */

+ 7 - 7
tests/check_builtin.c

@@ -279,7 +279,7 @@ END_TEST
 START_TEST(UA_String_calcSizeWithNegativLengthAndValidPointerShallReturnEncodingSize)
 {
 	// given
-	UA_String arg = {-1, "OPC"};
+	UA_String arg = {-1, (UA_Byte*) "OPC"};
 	// when
 	UA_Int32 encodingSize = UA_String_calcSize(&arg);
 	// then
@@ -299,7 +299,7 @@ END_TEST
 START_TEST(UA_String_calcSizeWithZeroLengthAndValidPointerShallReturnEncodingSize)
 {
 	// given
-	UA_String arg = {0, "OPC"};
+	UA_String arg = {0, (UA_Byte*) "OPC"};
 	// when
 	UA_Int32 encodingSize = UA_String_calcSize(&arg);
 	// then
@@ -309,7 +309,7 @@ END_TEST
 START_TEST(UA_String_calcSizeShallReturnEncodingSize)
 {
 	// given
-	UA_String arg = {3, "OPC"};
+	UA_String arg = {3, (UA_Byte*) "OPC"};
 	// when
 	UA_Int32 encodingSize = UA_String_calcSize(&arg);
 	// then
@@ -344,7 +344,7 @@ START_TEST(UA_NodeId_calcSizeEncodingStringShallReturnEncodingSize)
 	UA_NodeId arg;
 	arg.encodingByte = UA_NODEIDTYPE_STRING;
 	arg.identifier.string.length = 3;
-	arg.identifier.string.data = "PLT";
+	arg.identifier.string.data = (UA_Byte*) "PLT";
 	// when
 	UA_Int32 encodingSize = UA_NodeId_calcSize(&arg);
 	// then
@@ -473,7 +473,7 @@ START_TEST(UA_Variant_calcSizeVariableSizeArrayShallReturnEncodingSize)
 #define ARRAY_LEN 3
 	arg.arrayLength = ARRAY_LEN;
 	UA_String s1 = {-1, UA_NULL };
-	UA_String s2 = {3, "PLT" };
+	UA_String s2 = {3, (UA_Byte*) "PLT" };
 	UA_String s3 = {47, UA_NULL };
 	UA_String* data[ARRAY_LEN] = { &s1, &s2, &s3 };
 	arg.data = (void**) &data;
@@ -493,7 +493,7 @@ START_TEST(UA_Variant_calcSizeVariableSizeArrayWithNullPtrWillReturnWrongButLarg
 #define ARRAY_LEN 6
 	arg.arrayLength = ARRAY_LEN;
 	UA_String s1 = {-1, UA_NULL };
-	UA_String s2 = {3, "PLT" };
+	UA_String s2 = {3, (UA_Byte*) "PLT" };
 	UA_String s3 = {47, UA_NULL };
 	UA_String* data[ARRAY_LEN] = { &s1, &s2, &s3 }; // will be filled with null-ptrs
 	arg.data = (void**) &data;
@@ -626,7 +626,7 @@ START_TEST(UA_String_decodeWithZeroSizeShallNotAllocateMemoryAndNullPtr)
 	// given
 	UA_Int32 pos = 0;
 	UA_Byte src[] = {0x00,0x00,0x00,0x00,'A','C','P','L','T',' ','U','A',0xFF,0xFF,0xFF,0xFF,0xFF};
-	UA_String dst = { 2, "XX" };
+	UA_String dst = { 2, (UA_Byte*) "XX" };
 	// when
 	UA_Int32 retval = UA_String_decode(src, &pos, &dst);
 	// then

+ 1 - 1
tests/check_create.c

@@ -19,5 +19,5 @@ int main (void)
 {
 	int number_failed = 0;
 
-	return 0;
+	return (number_failed != 0);
 }

+ 3 - 10
tests/check_decode.c

@@ -20,7 +20,7 @@ START_TEST(decodeByte_test)
 	UA_ByteString rawMessage;
 	UA_Int32 position = 0;
 	//EncodeByte
-		char *mem = malloc(sizeof(UA_Byte));
+		UA_Byte* mem = (UA_Byte*) malloc(sizeof(UA_Byte));
 		UA_Byte val;
 
 		rawMessage.data = mem;
@@ -41,7 +41,7 @@ START_TEST(decodeInt16_test_positives)
 	UA_Int32 p = 0;
 	UA_Int16 val;
 	UA_ByteString rawMessage;
-	char mem[] = {
+	UA_Byte mem[] = {
 			0x00,0x00,	// 0
 			0x01,0x00,	// 1
 			0xFF,0x00,	// 255
@@ -86,7 +86,6 @@ START_TEST(decodeUInt16_test)
 {
 
 	UA_ByteString rawMessage;
-	UA_Int32 position = 0;
 	//EncodeUInt16
 	UA_Byte mem[2] = {0x01,0x00};
 
@@ -109,7 +108,6 @@ END_TEST
 START_TEST(decodeUInt32_test)
 {
 	UA_ByteString rawMessage;
-	UA_Int32 position = 0;
 	//EncodeUInt16
 	UA_Byte mem[4] = {0xFF,0x00,0x00,0x00};
 
@@ -126,7 +124,6 @@ END_TEST
 START_TEST(decodeInt32_test)
 {
 	UA_ByteString rawMessage;
-	UA_Int32 position = 0;
 	//EncodeUInt16
 	UA_Byte mem[4] = {0x00,0xCA,0x9A,0x3B};
 
@@ -144,7 +141,6 @@ END_TEST
 START_TEST(decodeUInt64_test)
 {
 	UA_ByteString rawMessage;
-	UA_Int32 position = 0;
 	UA_UInt64 expectedVal = 0xFF;
 	expectedVal = expectedVal << 56;
 	UA_Byte mem[8] = {00,00,00,00,0x00,0x00,0x00,0xFF};
@@ -162,7 +158,6 @@ END_TEST
 START_TEST(decodeInt64_test)
 {
 	UA_ByteString rawMessage;
-	UA_Int32 position = 0;
 	UA_Int64 expectedVal = 0xFF;
 	expectedVal = expectedVal << 56;
 	UA_Byte mem[8] = {00,00,00,00,0x00,0x00,0x00,0xFF};
@@ -178,7 +173,6 @@ START_TEST(decodeInt64_test)
 END_TEST
 START_TEST(decodeFloat_test)
 {
-	UA_Float expectedValue = -6.5;
 	UA_Int32 pos = 0;
 	UA_Byte buf[4] = {0x00,0x00,0xD0,0xC0};
 
@@ -201,8 +195,7 @@ START_TEST(decodeUAString_test)
 
 	UA_Int32 pos = 0;
 	UA_String string;
-	UA_Int32 l = 12;
-	char binString[12] = {0x08,0x00,0x00,0x00,'A','C','P','L','T',' ','U','A'};
+	UA_Byte binString[12] = {0x08,0x00,0x00,0x00,'A','C','P','L','T',' ','U','A'};
 
 	UA_String_decode(binString, &pos, &string);
 

+ 1 - 1
tests/check_delete.c

@@ -19,5 +19,5 @@ int main (void)
 {
 	int number_failed = 0;
 
-	return 0;
+	return (number_failed != 0);
 }

+ 5 - 8
tests/check_encode.c

@@ -21,7 +21,7 @@ START_TEST(encodeByte_test)
 	UA_ByteString rawMessage;
 	UA_Int32 position = 0;
 	//EncodeByte
-		char *mem = malloc(sizeof(UA_Byte));
+	UA_Byte *mem = malloc(sizeof(UA_Byte));
 		rawMessage.data = mem;
 		UA_Byte testByte = 0x08;
 		rawMessage.length = 1;
@@ -52,7 +52,7 @@ START_TEST(encodeInt16_test)
 
 	ck_assert_int_eq(position, 2);
 	UA_Int32 p = 0;
-	UA_Int16 val;
+	UA_UInt16 val;
 	UA_UInt16_decode(rawMessage.data, &p, &val);
 	ck_assert_int_eq(val,testUInt16);
 	//ck_assert_int_eq(rawMessage.data[0], 0xAB);
@@ -87,7 +87,6 @@ END_TEST
 START_TEST(encodeUInt32_test)
 {
 	UA_ByteString rawMessage;
-	UA_Int32 position = 0;
 	UA_UInt32 value = 0x0101FF00;
 	//EncodeUInt16
 
@@ -115,7 +114,6 @@ END_TEST
 START_TEST(encodeUInt64_test)
 {
 	UA_ByteString rawMessage;
-	UA_Int32 position = 0;
 	UA_UInt64 value = 0x0101FF00FF00FF00;
 	//EncodeUInt16
 
@@ -141,7 +139,6 @@ END_TEST
 START_TEST(encodeInt64_test)
 {
 	UA_ByteString rawMessage;
-	UA_Int32 position = 0;
 	UA_UInt64 value = 0x0101FF00FF00FF00;
 	//EncodeUInt16
 
@@ -168,7 +165,7 @@ START_TEST(encodeFloat_test)
 {
 	UA_Float value = -6.5;
 	UA_Int32 pos = 0;
-	UA_Byte* buf = (char*)malloc(sizeof(UA_Float));
+	UA_Byte* buf = (UA_Byte*)malloc(sizeof(UA_Float));
 
 	UA_Float_encode(&value,&pos,buf);
 
@@ -197,7 +194,7 @@ START_TEST(encodeUAString_test)
 	UA_String string;
 	UA_Int32 l = 11;
 	UA_Byte mem[11] = "ACPLT OPCUA";
-	UA_Byte *dstBuf = (char*) malloc(sizeof(UA_Int32)+l);
+	UA_Byte *dstBuf = (UA_Byte*) malloc(sizeof(UA_Int32)+l);
 	string.data =  mem;
 	string.length = 11;
 
@@ -213,7 +210,7 @@ START_TEST(encodeDataValue_test)
 {
 	UA_DataValue dataValue;
 	UA_Int32 pos = 0, retval;
-	UA_Byte* buf = (char*) malloc(15);
+	UA_Byte* buf = (UA_Byte*) malloc(15);
 	UA_DateTime dateTime;
 	dateTime = 80;
 	dataValue.serverTimestamp = dateTime;

+ 1 - 1
tests/check_indexedList.c

@@ -1,4 +1,4 @@
-#include "UA_config.h"
+#include <stdlib.h> // EXIT_SUCCESS
 #include "UA_indexedList.h"
 
 #include "check.h"

+ 1 - 2
tests/check_list.c

@@ -1,6 +1,5 @@
-#include "UA_config.h"
+#include <stdlib.h> // EXIT_SUCCESS
 #include "UA_list.h"
-
 #include "check.h"
 
 /* global test counters */

+ 1 - 1
tests/check_namespace.c

@@ -19,7 +19,7 @@
 
 START_TEST(test_Namespace) {
 	namespace *ns = UA_NULL;
-	create_ns(ns, 512);
+	create_ns(&ns, 512);
 	delete_ns(ns);
 }
 END_TEST

+ 7 - 6
tests/check_stack.c

@@ -61,12 +61,13 @@ END_TEST
 START_TEST(encode_builtInDatatypeArray_test_String)
 {
 	UA_Int32 noElements = 2;
-	UA_ByteString s1 = { 6, "OPC UA" };
-	UA_ByteString s2 = { -1, NULL };
+	UA_ByteString s1 = { 6, (UA_Byte*) "OPC UA" };
+	UA_ByteString s2 = { -1, UA_NULL };
 	UA_ByteString* array[] = { &s1, &s2	};
-	UA_Int32 pos = 0, i;
-	char buf[256];
-	char result[] = {
+	UA_Int32 pos = 0;
+	UA_UInt32 i;
+	UA_Byte buf[256];
+	UA_Byte result[] = {
 			0x02, 0x00, 0x00, 0x00,		// noElements
 			0x06, 0x00, 0x00, 0x00,		// s1.Length
 			'O', 'P', 'C', ' ', 'U', 'A', // s1.Data
@@ -78,7 +79,7 @@ START_TEST(encode_builtInDatatypeArray_test_String)
 	// check size
 	ck_assert_int_eq(pos, 4 + 4 + 6 + 4);
 	// check result
-	for (i=0; i< sizeof(result); i++) {
+	for (i=0; i < sizeof(result); i++) {
 		ck_assert_int_eq(buf[i],result[i]);
 	}
 }