|
@@ -13,16 +13,13 @@
|
|
|
* UA_DataType structure. The UA_DataType structures as well as all non-builtin
|
|
|
* datatypes are autogenerated. */
|
|
|
|
|
|
-/* Static definition of NULL type instances */
|
|
|
-const UA_String UA_STRING_NULL = {.length = 0, .data = NULL };
|
|
|
-const UA_ByteString UA_BYTESTRING_NULL = {.length = 0, .data = NULL };
|
|
|
-const UA_Guid UA_GUID_NULL = {.data1 = 0, .data2 = 0, .data3 = 0,
|
|
|
- .data4 = {0,0,0,0,0,0,0,0}};
|
|
|
-const UA_NodeId UA_NODEID_NULL = {0, UA_NODEIDTYPE_NUMERIC, {0}};
|
|
|
-const UA_ExpandedNodeId UA_EXPANDEDNODEID_NULL = {
|
|
|
- .nodeId = {.namespaceIndex = 0, .identifierType = UA_NODEIDTYPE_NUMERIC,
|
|
|
- .identifier.numeric = 0 },
|
|
|
- .namespaceUri = {.length = 0, .data = NULL}, .serverIndex = 0 };
|
|
|
+/* Global definition of NULL type instances. These are always zeroed out, as
|
|
|
+ * mandated by the C/C++ standard for global values with no initializer. */
|
|
|
+const UA_String UA_STRING_NULL;
|
|
|
+const UA_ByteString UA_BYTESTRING_NULL;
|
|
|
+const UA_Guid UA_GUID_NULL;
|
|
|
+const UA_NodeId UA_NODEID_NULL;
|
|
|
+const UA_ExpandedNodeId UA_EXPANDEDNODEID_NULL;
|
|
|
|
|
|
/* TODO: The standard-defined types are ordered. See if binary search is more
|
|
|
* efficient. */
|
|
@@ -63,11 +60,11 @@ UA_String_fromChars(char const src[]) {
|
|
|
UA_String str = UA_STRING_NULL;
|
|
|
size_t length = strlen(src);
|
|
|
if(length > 0) {
|
|
|
- str.data = UA_malloc(length);
|
|
|
+ str.data = (UA_Byte*)UA_malloc(length);
|
|
|
if(!str.data)
|
|
|
return str;
|
|
|
} else {
|
|
|
- str.data = UA_EMPTY_ARRAY_SENTINEL;
|
|
|
+ str.data = (UA_Byte*)UA_EMPTY_ARRAY_SENTINEL;
|
|
|
}
|
|
|
memcpy(str.data, src, length);
|
|
|
str.length = length;
|
|
@@ -124,7 +121,7 @@ UA_String
|
|
|
UA_DateTime_toString(UA_DateTime t) {
|
|
|
UA_String str = UA_STRING_NULL;
|
|
|
// length of the string is 31 (plus \0 at the end)
|
|
|
- if(!(str.data = UA_malloc(32)))
|
|
|
+ if(!(str.data = (UA_Byte*)UA_malloc(32)))
|
|
|
return str;
|
|
|
str.length = 31;
|
|
|
UA_DateTimeStruct tSt = UA_DateTime_toStruct(t);
|
|
@@ -182,7 +179,7 @@ UA_ByteString_allocBuffer(UA_ByteString *bs, size_t length) {
|
|
|
UA_ByteString_init(bs);
|
|
|
if(length == 0)
|
|
|
return UA_STATUSCODE_GOOD;
|
|
|
- if(!(bs->data = UA_malloc(length)))
|
|
|
+ if(!(bs->data = (UA_Byte*)UA_malloc(length)))
|
|
|
return UA_STATUSCODE_BADOUTOFMEMORY;
|
|
|
bs->length = length;
|
|
|
return UA_STATUSCODE_GOOD;
|
|
@@ -386,16 +383,16 @@ UA_Variant_setScalar(UA_Variant *v, void * UA_RESTRICT p,
|
|
|
UA_StatusCode
|
|
|
UA_Variant_setScalarCopy(UA_Variant *v, const void *p,
|
|
|
const UA_DataType *type) {
|
|
|
- void *new = UA_malloc(type->memSize);
|
|
|
- if(!new)
|
|
|
+ void *n = UA_malloc(type->memSize);
|
|
|
+ if(!n)
|
|
|
return UA_STATUSCODE_BADOUTOFMEMORY;
|
|
|
- UA_StatusCode retval = UA_copy(p, new, type);
|
|
|
+ UA_StatusCode retval = UA_copy(p, n, type);
|
|
|
if(retval != UA_STATUSCODE_GOOD) {
|
|
|
- UA_free(new);
|
|
|
+ UA_free(n);
|
|
|
//cppcheck-suppress memleak
|
|
|
return retval;
|
|
|
}
|
|
|
- UA_Variant_setScalar(v, new, type);
|
|
|
+ UA_Variant_setScalar(v, n, type);
|
|
|
//cppcheck-suppress memleak
|
|
|
return UA_STATUSCODE_GOOD;
|
|
|
}
|
|
@@ -524,8 +521,7 @@ UA_Variant_copyRange(const UA_Variant *orig_src, UA_Variant *dst,
|
|
|
* with in the "scalar" type that may define an array by itself (string,
|
|
|
* variant, ...). */
|
|
|
UA_NumericRange thisrange, nextrange;
|
|
|
- UA_NumericRangeDimension scalarThisDimension = (UA_NumericRangeDimension){
|
|
|
- .min = 0, .max = 0}; /* a single entry */
|
|
|
+ UA_NumericRangeDimension scalarThisDimension = {0,0}; /* a single entry */
|
|
|
if(isScalar) {
|
|
|
/* Replace scalar src with array of length 1 */
|
|
|
arraySrc = *src;
|
|
@@ -629,7 +625,7 @@ UA_Variant_copyRange(const UA_Variant *orig_src, UA_Variant *dst,
|
|
|
dst->arrayLength = count;
|
|
|
if(src->arrayDimensionsSize > 0) {
|
|
|
dst->arrayDimensions =
|
|
|
- UA_Array_new(thisrange.dimensionsSize, &UA_TYPES[UA_TYPES_UINT32]);
|
|
|
+ (UA_UInt32*)UA_Array_new(thisrange.dimensionsSize, &UA_TYPES[UA_TYPES_UINT32]);
|
|
|
if(!dst->arrayDimensions) {
|
|
|
Variant_deletemembers(dst, NULL);
|
|
|
return UA_STATUSCODE_BADOUTOFMEMORY;
|
|
@@ -751,7 +747,7 @@ DiagnosticInfo_copy(UA_DiagnosticInfo const *src, UA_DiagnosticInfo *dst,
|
|
|
if(src->hasAdditionalInfo)
|
|
|
retval = UA_String_copy(&src->additionalInfo, &dst->additionalInfo);
|
|
|
if(src->hasInnerDiagnosticInfo && src->innerDiagnosticInfo) {
|
|
|
- dst->innerDiagnosticInfo = UA_malloc(sizeof(UA_DiagnosticInfo));
|
|
|
+ dst->innerDiagnosticInfo = (UA_DiagnosticInfo*)UA_malloc(sizeof(UA_DiagnosticInfo));
|
|
|
if(dst->innerDiagnosticInfo) {
|
|
|
retval |= DiagnosticInfo_copy(src->innerDiagnosticInfo,
|
|
|
dst->innerDiagnosticInfo, NULL);
|