From 810df18bf41093a44a310c103a32d0f5463c132b Mon Sep 17 00:00:00 2001 From: Martin Becker Date: Mon, 9 Sep 2019 15:59:28 +0200 Subject: [PATCH 01/11] Fixed empty list parsing. --- erpcgen/src/templates/c_coders.template | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/erpcgen/src/templates/c_coders.template b/erpcgen/src/templates/c_coders.template index 6ffcad07c..b734e95b0 100644 --- a/erpcgen/src/templates/c_coders.template +++ b/erpcgen/src/templates/c_coders.template @@ -87,15 +87,17 @@ codec->read(&_tmp_local); uint32_t {$info.sizeTemp}; {% endif %} codec->startReadList(&{$info.sizeTemp}); +if({$info.sizeTemp}) +{ {% if info.hasLengthVariable && not info.constantVariable %} {% if info.pointerScalarTypes && source == "client" %}*{% endif %}{$info.size} = {$info.sizeTemp}; {% endif %} {% if info.maxSize != info.sizeTemp %} -if ({$info.sizeTemp} <= {$info.maxSize}) -{ -{% set indent = " " >%} + if ({$info.sizeTemp} <= {$info.maxSize}) + { +{% set indent = " " >%} {% else %} -{% set indent = "" >%} +{% set indent = " " >%} {% endif %} {% if source == "server" || info.useMallocOnClientSide == true %} {$indent}{$info.name} = ({$info.mallocType}) erpc_malloc({$info.maxSize} * sizeof({$info.mallocSizeType})); @@ -110,12 +112,13 @@ if ({$info.sizeTemp} <= {$info.maxSize}) {$addIndent(indent, decodeArrayType(info))} {% endif %} {% if info.maxSize != info.sizeTemp %} -} -else -{ - codec->updateStatus(kErpcStatus_Fail); -} + } + else + { + codec->updateStatus(kErpcStatus_Fail); + } {% endif %} +} {% endif >%} {% enddef ------------------------------------- ListType %} From d97d452435d26201af5507579d05a95a90c510c9 Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 9 Sep 2019 15:59:28 +0200 Subject: [PATCH 02/11] Fixed empty list parsing. --- erpcgen/src/templates/c_coders.template | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/erpcgen/src/templates/c_coders.template b/erpcgen/src/templates/c_coders.template index 6ffcad07c..b734e95b0 100644 --- a/erpcgen/src/templates/c_coders.template +++ b/erpcgen/src/templates/c_coders.template @@ -87,15 +87,17 @@ codec->read(&_tmp_local); uint32_t {$info.sizeTemp}; {% endif %} codec->startReadList(&{$info.sizeTemp}); +if({$info.sizeTemp}) +{ {% if info.hasLengthVariable && not info.constantVariable %} {% if info.pointerScalarTypes && source == "client" %}*{% endif %}{$info.size} = {$info.sizeTemp}; {% endif %} {% if info.maxSize != info.sizeTemp %} -if ({$info.sizeTemp} <= {$info.maxSize}) -{ -{% set indent = " " >%} + if ({$info.sizeTemp} <= {$info.maxSize}) + { +{% set indent = " " >%} {% else %} -{% set indent = "" >%} +{% set indent = " " >%} {% endif %} {% if source == "server" || info.useMallocOnClientSide == true %} {$indent}{$info.name} = ({$info.mallocType}) erpc_malloc({$info.maxSize} * sizeof({$info.mallocSizeType})); @@ -110,12 +112,13 @@ if ({$info.sizeTemp} <= {$info.maxSize}) {$addIndent(indent, decodeArrayType(info))} {% endif %} {% if info.maxSize != info.sizeTemp %} -} -else -{ - codec->updateStatus(kErpcStatus_Fail); -} + } + else + { + codec->updateStatus(kErpcStatus_Fail); + } {% endif %} +} {% endif >%} {% enddef ------------------------------------- ListType %} From cbad243cdb4bd95771a10f41de80d5128570e919 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 10 Sep 2019 13:57:12 +0200 Subject: [PATCH 03/11] Same fix for binary_t. --- erpcgen/src/templates/c_coders.template | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/erpcgen/src/templates/c_coders.template b/erpcgen/src/templates/c_coders.template index b734e95b0..fda1ebe2e 100644 --- a/erpcgen/src/templates/c_coders.template +++ b/erpcgen/src/templates/c_coders.template @@ -34,15 +34,17 @@ uint32_t {$info.sizeTemp}; {% endif %} uint8_t * {$info.dataTemp}; codec->readBinary(&{$info.sizeTemp}, &{$info.dataTemp}); +if({$info.sizeTemp}) +{ {% if info.hasLengthVariable && not info.constantVariable %} {% if info.pointerScalarTypes && source == "client" %}*{% endif %}{$info.size} = {$info.sizeTemp}; {% endif %} {% if info.maxSize != info.sizeTemp %} if ({$info.sizeTemp} <= {$info.maxSize}) { -{% set indent = " " >%} +{% set indent = " " >%} {% else %} -{% set indent = "" >%} +{% set indent = " " >%} {% endif %} {% if source == "server" || info.useMallocOnClientSide == true %} {$indent}{$info.name} = (uint8_t *) erpc_malloc({$info.maxSize} * sizeof(uint8_t)); @@ -62,12 +64,17 @@ if ({$info.sizeTemp} <= {$info.maxSize}) {$indent}memcpy({$info.name}, {$info.dataTemp}, {$info.sizeTemp}); {% endif %} {% if info.maxSize != info.sizeTemp %} + } + else + { + codec->updateStatus(kErpcStatus_Fail); + } +{% endif %} } else { - codec->updateStatus(kErpcStatus_Fail); + {$info.name} = NULL; } -{% endif %} {% enddef ------------------------------- BinaryType %} {% def decodeEnumType(info) ---------------- EnumType %} From 908b9b77781b507382e0c6ab39577f153f38ae45 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 10 Sep 2019 14:53:24 +0200 Subject: [PATCH 04/11] Set elements to NULL if nothing was read --- erpcgen/src/templates/c_coders.template | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpcgen/src/templates/c_coders.template b/erpcgen/src/templates/c_coders.template index fda1ebe2e..8e73f4bc8 100644 --- a/erpcgen/src/templates/c_coders.template +++ b/erpcgen/src/templates/c_coders.template @@ -126,6 +126,10 @@ if({$info.sizeTemp}) } {% endif %} } +else +{ + {$info.name} = NULL; +} {% endif >%} {% enddef ------------------------------------- ListType %} From 31c2f371aedf60b46e22a2f92d0194029e2dccaf Mon Sep 17 00:00:00 2001 From: Cervenka Dusan Date: Fri, 4 Feb 2022 14:53:41 +0100 Subject: [PATCH 05/11] Improving kErpcStatus_MemoryError flag usage Signed-off-by: Cervenka Dusan --- erpc_c/infra/erpc_basic_codec.cpp | 18 ++---------------- erpc_c/infra/erpc_message_buffer.cpp | 12 ++++++++++-- erpcgen/src/templates/c_coders.template | 4 ++-- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/erpc_c/infra/erpc_basic_codec.cpp b/erpc_c/infra/erpc_basic_codec.cpp index 88bd183f3..54c8df89e 100644 --- a/erpc_c/infra/erpc_basic_codec.cpp +++ b/erpc_c/infra/erpc_basic_codec.cpp @@ -37,14 +37,7 @@ void BasicCodec::writeData(const void *value, uint32_t length) { if (isStatusOk()) { - if (value != NULL) - { - m_status = m_cursor.write(value, length); - } - else - { - m_status = kErpcStatus_MemoryError; - } + m_status = m_cursor.write(value, length); } } @@ -202,14 +195,7 @@ void BasicCodec::readData(void *value, uint32_t length) { if (isStatusOk()) { - if (value != NULL) - { - m_status = m_cursor.read(value, length); - } - else - { - m_status = kErpcStatus_MemoryError; - } + m_status = m_cursor.read(value, length); } } diff --git a/erpc_c/infra/erpc_message_buffer.cpp b/erpc_c/infra/erpc_message_buffer.cpp index d5588ee28..224c355bf 100644 --- a/erpc_c/infra/erpc_message_buffer.cpp +++ b/erpc_c/infra/erpc_message_buffer.cpp @@ -102,7 +102,11 @@ erpc_status_t MessageBuffer::Cursor::read(void *data, uint32_t length) erpc_status_t err; - if (m_remaining < length) + if ((length > 0U) && (data == NULL)) + { + err = kErpcStatus_MemoryError; + } + else if (m_remaining < length) { err = kErpcStatus_BufferOverrun; } @@ -124,7 +128,11 @@ erpc_status_t MessageBuffer::Cursor::write(const void *data, uint32_t length) erpc_status_t err; - if (length > m_remaining) + if ((length > 0U) && (data == NULL)) + { + err = kErpcStatus_MemoryError; + } + else if (length > m_remaining) { err = kErpcStatus_BufferOverrun; } diff --git a/erpcgen/src/templates/c_coders.template b/erpcgen/src/templates/c_coders.template index 7272455e3..470ac649a 100644 --- a/erpcgen/src/templates/c_coders.template +++ b/erpcgen/src/templates/c_coders.template @@ -34,7 +34,7 @@ uint32_t {$info.sizeTemp}; {% endif %} uint8_t * {$info.dataTemp}; codec->readBinary(&{$info.sizeTemp}, &{$info.dataTemp}); -if({$info.sizeTemp}) +if ({$info.sizeTemp}) { {% if info.hasLengthVariable && not info.constantVariable %} {% if info.pointerScalarTypes && source == "client" %}*{% endif %}{$info.size} = {$info.sizeTemp}; @@ -94,7 +94,7 @@ codec->read(&_tmp_local); uint32_t {$info.sizeTemp}; {% endif %} codec->startReadList(&{$info.sizeTemp}); -if({$info.sizeTemp}) +if ({$info.sizeTemp}) { {% if info.hasLengthVariable && not info.constantVariable %} {% if info.pointerScalarTypes && source == "client" %}*{% endif %}{$info.size} = {$info.sizeTemp}; From e7154eab41dc57d337166e52313ed75fa56bcb55 Mon Sep 17 00:00:00 2001 From: Cervenka Dusan Date: Fri, 4 Feb 2022 15:05:31 +0100 Subject: [PATCH 06/11] Improve zero list length usage Signed-off-by: Cervenka Dusan --- erpcgen/src/templates/c_coders.template | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/erpcgen/src/templates/c_coders.template b/erpcgen/src/templates/c_coders.template index 470ac649a..40e21428f 100644 --- a/erpcgen/src/templates/c_coders.template +++ b/erpcgen/src/templates/c_coders.template @@ -34,8 +34,6 @@ uint32_t {$info.sizeTemp}; {% endif %} uint8_t * {$info.dataTemp}; codec->readBinary(&{$info.sizeTemp}, &{$info.dataTemp}); -if ({$info.sizeTemp}) -{ {% if info.hasLengthVariable && not info.constantVariable %} {% if info.pointerScalarTypes && source == "client" %}*{% endif %}{$info.size} = {$info.sizeTemp}; {% endif %} @@ -49,7 +47,7 @@ if ({$info.sizeTemp} <= {$info.maxSize}) {% if source == "server" || info.useMallocOnClientSide == true %} {$indent}{$info.name} = (uint8_t *) erpc_malloc({$info.maxSize} * sizeof(uint8_t)); {% if generateAllocErrorChecks == true %} -{$indent}if ({$info.name} == NULL) +{$indent}if (({$info.name} == NULL) && ({$info.sizeTemp} > 0)) {$indent}{ {$indent} codec->updateStatus(kErpcStatus_MemoryError); {$indent}} @@ -70,11 +68,6 @@ if ({$info.sizeTemp} <= {$info.maxSize}) codec->updateStatus(kErpcStatus_Fail); } {% endif %} -} -else -{ - {$info.name} = NULL; -} {% enddef ------------------------------- BinaryType %} {% def decodeEnumType(info) ---------------- EnumType %} @@ -94,8 +87,6 @@ codec->read(&_tmp_local); uint32_t {$info.sizeTemp}; {% endif %} codec->startReadList(&{$info.sizeTemp}); -if ({$info.sizeTemp}) -{ {% if info.hasLengthVariable && not info.constantVariable %} {% if info.pointerScalarTypes && source == "client" %}*{% endif %}{$info.size} = {$info.sizeTemp}; {% endif %} @@ -109,7 +100,7 @@ if ({$info.sizeTemp}) {% if source == "server" || info.useMallocOnClientSide == true %} {$indent}{$info.name} = ({$info.mallocType}) erpc_malloc({$info.maxSize} * sizeof({$info.mallocSizeType})); {% if generateAllocErrorChecks == true %} -{$indent}if ({$info.name} == NULL) +{$indent}if (({$info.name} == NULL) && ({$info.sizeTemp} > 0)) {$indent}{ {$indent} codec->updateStatus(kErpcStatus_MemoryError); {$indent}} @@ -125,11 +116,6 @@ if ({$info.sizeTemp}) codec->updateStatus(kErpcStatus_Fail); } {% endif %} -} -else -{ - {$info.name} = NULL; -} {% endif >%} {% enddef ------------------------------------- ListType %} From b7572bdac7e4d180da5875b7daed8cabbcdc239d Mon Sep 17 00:00:00 2001 From: Cervenka Dusan Date: Fri, 4 Feb 2022 15:08:43 +0100 Subject: [PATCH 07/11] Revert spaces in coders.template Signed-off-by: Cervenka Dusan --- erpcgen/src/templates/c_coders.template | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/erpcgen/src/templates/c_coders.template b/erpcgen/src/templates/c_coders.template index 40e21428f..9b8ed16a5 100644 --- a/erpcgen/src/templates/c_coders.template +++ b/erpcgen/src/templates/c_coders.template @@ -40,9 +40,9 @@ codec->readBinary(&{$info.sizeTemp}, &{$info.dataTemp}); {% if info.maxSize != info.sizeTemp %} if ({$info.sizeTemp} <= {$info.maxSize}) { -{% set indent = " " >%} -{% else %} {% set indent = " " >%} +{% else %} +{% set indent = "" >%} {% endif %} {% if source == "server" || info.useMallocOnClientSide == true %} {$indent}{$info.name} = (uint8_t *) erpc_malloc({$info.maxSize} * sizeof(uint8_t)); @@ -62,11 +62,11 @@ if ({$info.sizeTemp} <= {$info.maxSize}) {$indent}memcpy({$info.name}, {$info.dataTemp}, {$info.sizeTemp}); {% endif %} {% if info.maxSize != info.sizeTemp %} - } - else - { - codec->updateStatus(kErpcStatus_Fail); - } +} +else +{ + codec->updateStatus(kErpcStatus_Fail); +} {% endif %} {% enddef ------------------------------- BinaryType %} @@ -91,11 +91,11 @@ codec->startReadList(&{$info.sizeTemp}); {% if info.pointerScalarTypes && source == "client" %}*{% endif %}{$info.size} = {$info.sizeTemp}; {% endif %} {% if info.maxSize != info.sizeTemp %} - if ({$info.sizeTemp} <= {$info.maxSize}) - { -{% set indent = " " >%} -{% else %} +if ({$info.sizeTemp} <= {$info.maxSize}) +{ {% set indent = " " >%} +{% else %} +{% set indent = "" >%} {% endif %} {% if source == "server" || info.useMallocOnClientSide == true %} {$indent}{$info.name} = ({$info.mallocType}) erpc_malloc({$info.maxSize} * sizeof({$info.mallocSizeType})); @@ -110,11 +110,11 @@ codec->startReadList(&{$info.sizeTemp}); {$addIndent(indent, decodeArrayType(info))} {% endif %} {% if info.maxSize != info.sizeTemp %} - } - else - { - codec->updateStatus(kErpcStatus_Fail); - } +} +else +{ + codec->updateStatus(kErpcStatus_Fail); +} {% endif %} {% endif >%} {% enddef ------------------------------------- ListType %} From 5c05b565fe21258fe0ae0fa6a51e3563ae720f67 Mon Sep 17 00:00:00 2001 From: Cervenka Dusan Date: Fri, 4 Feb 2022 15:12:34 +0100 Subject: [PATCH 08/11] Minor Signed-off-by: Cervenka Dusan --- erpc_c/infra/erpc_message_buffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpc_c/infra/erpc_message_buffer.cpp b/erpc_c/infra/erpc_message_buffer.cpp index 224c355bf..aff8c0da8 100644 --- a/erpc_c/infra/erpc_message_buffer.cpp +++ b/erpc_c/infra/erpc_message_buffer.cpp @@ -106,7 +106,7 @@ erpc_status_t MessageBuffer::Cursor::read(void *data, uint32_t length) { err = kErpcStatus_MemoryError; } - else if (m_remaining < length) + else if (length > m_remaining) { err = kErpcStatus_BufferOverrun; } From c0fcdd6479783ee5934630b1b38831ebc06058b4 Mon Sep 17 00:00:00 2001 From: Cervenka Dusan Date: Fri, 4 Feb 2022 15:22:31 +0100 Subject: [PATCH 09/11] Minor code style changes Signed-off-by: Cervenka Dusan --- erpcgen/src/templates/c_client_source.template | 2 +- erpcgen/src/templates/c_coders.template | 2 +- erpcgen/src/templates/c_common_functions.template | 2 +- erpcgen/src/templates/c_server_source.template | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/erpcgen/src/templates/c_client_source.template b/erpcgen/src/templates/c_client_source.template index 2303fea99..7d95d31cc 100644 --- a/erpcgen/src/templates/c_client_source.template +++ b/erpcgen/src/templates/c_client_source.template @@ -107,7 +107,7 @@ extern ClientManager *g_client; {% for param in fn.parametersToClient if (param.serializedDirection == "" || param.serializedDirection == InDirection || param.referencedName != "") %} {% if param.isNullable %} -{$clientIndent} if ({$param.nullableName} != NULL{% if ((source == "client") && (param.direction != ReturnDirection) && (empty(param.lengthName) == false)) %} && {$param.lengthName} != NULL{% endif %}) +{$clientIndent} if (({$param.nullableName} != NULL){% if ((source == "client") && (param.direction != ReturnDirection) && (empty(param.lengthName) == false)) %} && ({$param.lengthName} != NULL){% endif %}) {$clientIndent} { {$addIndent(clientIndent & " ", param.coderCall.decode(param.coderCall))} } diff --git a/erpcgen/src/templates/c_coders.template b/erpcgen/src/templates/c_coders.template index 9b8ed16a5..11541badc 100644 --- a/erpcgen/src/templates/c_coders.template +++ b/erpcgen/src/templates/c_coders.template @@ -312,7 +312,7 @@ codec->writeCallback((arrayOfFunPtr)({$info.callbacks}), {$info.callbacksCount}, {% def encodeSharedType(info) %} {% if sharedMemBeginAddr != "" %} -if ({$info.name} >= ERPC_SHARED_MEMORY_BEGIN && {$info.name} <= ERPC_SHARED_MEMORY_END) +if (({$info.name} >= ERPC_SHARED_MEMORY_BEGIN) && ({$info.name} <= ERPC_SHARED_MEMORY_END)) { codec->writePtr(reinterpret_cast({%if source == "client" && info.InoutOutDirection %}*{% endif %}{$info.name})); } diff --git a/erpcgen/src/templates/c_common_functions.template b/erpcgen/src/templates/c_common_functions.template index 0b83203b6..153e13ca6 100644 --- a/erpcgen/src/templates/c_common_functions.template +++ b/erpcgen/src/templates/c_common_functions.template @@ -459,7 +459,7 @@ struct {% enddef ------------------------------- unionMembersDeclaration %} {% def f_paramIsNullableEncode(param) %} -if ({$param.nullableName} == NULL{% if ((source == "client") && (param.direction != ReturnDirection) && (empty(param.lengthName) == false)) %} || {$param.lengthName} == NULL{% endif %}) +if (({$param.nullableName} == NULL){% if ((source == "client") && (param.direction != ReturnDirection) && (empty(param.lengthName) == false)) %} || ({$param.lengthName} == NULL){% endif %}) { codec->writeNullFlag(true); } diff --git a/erpcgen/src/templates/c_server_source.template b/erpcgen/src/templates/c_server_source.template index 3d5dd7f4d..c05514e71 100644 --- a/erpcgen/src/templates/c_server_source.template +++ b/erpcgen/src/templates/c_server_source.template @@ -114,7 +114,7 @@ ERPC_MANUALLY_CONSTRUCTED_STATIC({$iface.serviceClassName}, s_{$iface.serviceCla #endif {% if serverIDName == "serviceID" %} {% for callbackFunction in callbackType.functions %} -{$serverIndent} {% if loop.first == false %}else {% endif %}if ({$serverIDName} == {$callbackFunction.serviceId} && {$functionIDName} == {$callbackFunction.id}) +{$serverIndent} {% if loop.first == false %}else {% endif %}if (({$serverIDName} == {$callbackFunction.serviceId}) && ({$functionIDName} == {$callbackFunction.id})) {$serverIndent} { {$serverIndent} {$callbackFunction.serverPrototype} {$serverIndent} } From 3045a374a14295b5cc6fe45ccfabd52818875cac Mon Sep 17 00:00:00 2001 From: Cervenka Dusan Date: Fri, 4 Feb 2022 15:47:50 +0100 Subject: [PATCH 10/11] Fixed clang compiler and pytest Signed-off-by: Cervenka Dusan --- erpcgen/src/templates/c_client_source.template | 7 ++++++- erpcgen/src/templates/c_common_functions.template | 7 ++++++- erpcgen/test/test_nullable_c.yml | 6 +++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/erpcgen/src/templates/c_client_source.template b/erpcgen/src/templates/c_client_source.template index 7d95d31cc..93feea88f 100644 --- a/erpcgen/src/templates/c_client_source.template +++ b/erpcgen/src/templates/c_client_source.template @@ -107,7 +107,12 @@ extern ClientManager *g_client; {% for param in fn.parametersToClient if (param.serializedDirection == "" || param.serializedDirection == InDirection || param.referencedName != "") %} {% if param.isNullable %} -{$clientIndent} if (({$param.nullableName} != NULL){% if ((source == "client") && (param.direction != ReturnDirection) && (empty(param.lengthName) == false)) %} && ({$param.lengthName} != NULL){% endif %}) +{% if ((source == "client") && (param.direction != ReturnDirection) && (empty(param.lengthName) == false)) %} +{% set lengthNameCon = ") && (" & param.lengthName & " != NULL)" >%} +{% else %} +{% set lengthNameCon = "" >%} +{% endif %} +{$clientIndent} if ({% if lengthNameCon != "" %}({% endif %}{$param.nullableName} != NULL{$lengthNameCon}) {$clientIndent} { {$addIndent(clientIndent & " ", param.coderCall.decode(param.coderCall))} } diff --git a/erpcgen/src/templates/c_common_functions.template b/erpcgen/src/templates/c_common_functions.template index 153e13ca6..5081eff88 100644 --- a/erpcgen/src/templates/c_common_functions.template +++ b/erpcgen/src/templates/c_common_functions.template @@ -459,7 +459,12 @@ struct {% enddef ------------------------------- unionMembersDeclaration %} {% def f_paramIsNullableEncode(param) %} -if (({$param.nullableName} == NULL){% if ((source == "client") && (param.direction != ReturnDirection) && (empty(param.lengthName) == false)) %} || ({$param.lengthName} == NULL){% endif %}) +{% if ((source == "client") && (param.direction != ReturnDirection) && (empty(param.lengthName) == false)) %} +{% set lengthNameCon = ") || (" & param.lengthName & " == NULL)" >%} +{% else %} +{% set lengthNameCon = "" >%} +{% endif %} +if ({% if lengthNameCon != "" %}({% endif %}{$param.nullableName} == NULL{$lengthNameCon}) { codec->writeNullFlag(true); } diff --git a/erpcgen/test/test_nullable_c.yml b/erpcgen/test/test_nullable_c.yml index f73990a90..e737775dd 100644 --- a/erpcgen/test/test_nullable_c.yml +++ b/erpcgen/test/test_nullable_c.yml @@ -335,7 +335,7 @@ test_client.cpp: - void bar(const bool * l, uint32_t c) - if: dir == 'inout' and ann == '@nullable' then: - - if (l == NULL || c == NULL) + - if ((l == NULL) || (c == NULL)) else: - if (l == NULL) - codec->writeNullFlag @@ -398,7 +398,7 @@ test_client.cpp: - void bar(bool * l, uint32_t * c) - if: ann == '@nullable' then: - - if (l == NULL || c == NULL) + - if ((l == NULL) || (c == NULL)) else: - if (l == NULL) - codec->writeNullFlag @@ -412,7 +412,7 @@ test_client.cpp: - codec->write - if: ann == '@nullable' then: - - if (l != NULL && c != NULL) + - if ((l != NULL) && (c != NULL)) else: - if (l != NULL) - codec->startReadList From 864f72def95d996a05688c3465c5638344e0e2e8 Mon Sep 17 00:00:00 2001 From: Cervenka Dusan Date: Thu, 17 Feb 2022 00:21:59 +0100 Subject: [PATCH 11/11] Added test for empty list size. Signed-off-by: Cervenka Dusan --- test/test_lists/test_lists_client_impl.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test_lists/test_lists_client_impl.cpp b/test/test_lists/test_lists_client_impl.cpp index 5c8a2e376..0e59f62cd 100644 --- a/test/test_lists/test_lists_client_impl.cpp +++ b/test/test_lists/test_lists_client_impl.cpp @@ -44,6 +44,20 @@ TEST(test_list, SendReceivedInt32) erpc_free(received_list); } +TEST(test_list, sendReceiveZeroSize) +{ + list_int32_1_t *received_list, send_list; + send_list.elementsCount = 0; + send_list.elements = NULL; + + received_list = sendReceivedInt32(&send_list); + + EXPECT_TRUE(received_list->elementsCount == 0); + + erpc_free(received_list->elements); + erpc_free(received_list); +} + TEST(test_list, SendReceived2Int32) { list_int32_2_t *received_list, send_list;