Ack, code review only.

Note:In NTFSv spec A.01.01, section "Appendix A API Usage Examples" uses 
strlen() in all the provided examples while allocating notifications.


Thanks,
Praveen

On 16-Sep-16 4:24 AM, Minh Hon Chau wrote:
>  osaf/libs/agents/saf/ntfa/ntfa_api.c          |  7 ++++---
>  tests/ntfsv/tet_saNtfArrayValGet.c            |  4 ++--
>  tests/ntfsv/tet_saNtfPtrValGet.c              |  4 ++--
>  tests/ntfsv/tet_scOutage_reinitializeHandle.c |  2 +-
>  4 files changed, 9 insertions(+), 8 deletions(-)
>
>
> Patch corrects the calculation of lengthAdditionalText in ntftest,
> and show the mismatch of lenghtAdditionalText and addtionalText as
> ERROR that could help to identify the error in first place.
>
> diff --git a/osaf/libs/agents/saf/ntfa/ntfa_api.c 
> b/osaf/libs/agents/saf/ntfa/ntfa_api.c
> --- a/osaf/libs/agents/saf/ntfa/ntfa_api.c
> +++ b/osaf/libs/agents/saf/ntfa/ntfa_api.c
> @@ -552,19 +552,20 @@ static SaAisErrorT checkHeader(v_data *p
>
>       // AIS: additionalText must be consistent with lengthAdditionalText
>       if (nh->additionalText == NULL && nh->lengthAdditionalText != 0) {
> -             TRACE_1("Mismatch b/w additionalText and lengthAdditionalText");
> +             LOG_ER("additionalText is NULL and lengthAdditionalText:%u", 
> nh->lengthAdditionalText);
>               return SA_AIS_ERR_INVALID_PARAM;
>       }
>
>       if (nh->lengthAdditionalText > MAX_ADDITIONAL_TEXT_LENGTH) {
> -             TRACE_1("lengthAdditionalText is too long");
> +             LOG_ER("lengthAdditionalText is too long");
>               return SA_AIS_ERR_INVALID_PARAM;
>       }
>
>       SaUint16T len = nh->lengthAdditionalText;
>       SaStringT addT = nh->additionalText;
>       if ((addT != NULL) && (len != strlen(addT) + 1)) {
> -             TRACE_1("Mismatch b/w additionalText and lengthAdditionalText");
> +             LOG_ER("Mismatch size b/w additionalText:%u and 
> lengthAdditionalText:%u",
> +                             (SaUint16T)(strlen(addT) + 1), len);
>               return SA_AIS_ERR_INVALID_PAR"AM;
>       }
>
> diff --git a/tests/ntfsv/tet_saNtfArrayValGet.c 
> b/tests/ntfsv/tet_saNtfArrayValGet.c
> --- a/tests/ntfsv/tet_saNtfArrayValGet.c
> +++ b/tests/ntfsv/tet_saNtfArrayValGet.c
> @@ -266,7 +266,7 @@ void saNtfArrayGetTest_common_prep(void)
>                       ntfHandle,
>                       &myAlarmNotification,
>                       0,
> -                     sizeof(DEFAULT_ADDITIONAL_TEXT),
> +                     (SaUint16T)(strlen(DEFAULT_ADDITIONAL_TEXT) + 1),
>                       0,
>                       0,
>                       0,
> @@ -289,7 +289,7 @@ void saNtfArrayGetTest_common_prep(void)
>       
> strncpy((char*)myAlarmNotification.notificationHeader.notifyingObject->value,
>                       "ngo", 4);
>       strncpy(myAlarmNotification.notificationHeader.additionalText,
> -               DEFAULT_ADDITIONAL_TEXT, sizeof(DEFAULT_ADDITIONAL_TEXT));
> +               DEFAULT_ADDITIONAL_TEXT, strlen(DEFAULT_ADDITIONAL_TEXT) + 1);
>
>      myAlarmNotification.proposedRepairActions[0].actionValueType = 
> SA_NTF_VALUE_ARRAY;
>      if((rc = saNtfArrayValAllocate(
> diff --git a/tests/ntfsv/tet_saNtfPtrValGet.c 
> b/tests/ntfsv/tet_saNtfPtrValGet.c
> --- a/tests/ntfsv/tet_saNtfPtrValGet.c
> +++ b/tests/ntfsv/tet_saNtfPtrValGet.c
> @@ -246,7 +246,7 @@ void saNtfPtrGetTest_common_prep(void)
>                       ntfHandle,
>                       &myAlarmNotification,
>                       0,
> -                     sizeof(DEFAULT_ADDITIONAL_TEXT),
> +                     (SaUint16T)(strlen(DEFAULT_ADDITIONAL_TEXT) + 1),
>                       0,
>                       0,
>                       0,
> @@ -271,7 +271,7 @@ void saNtfPtrGetTest_common_prep(void)
>        
> strncpy((char*)myAlarmNotification.notificationHeader.notifyingObject->value,
>                        "ngo", 4);
>        strncpy(myAlarmNotification.notificationHeader.additionalText,
> -                     DEFAULT_ADDITIONAL_TEXT, 
> sizeof(DEFAULT_ADDITIONAL_TEXT));
> +                     DEFAULT_ADDITIONAL_TEXT, 
> strlen(DEFAULT_ADDITIONAL_TEXT) + 1);
>
>      if((rc = saNtfPtrValAllocate(
>               myAlarmNotification.notificationHandle,
> diff --git a/tests/ntfsv/tet_scOutage_reinitializeHandle.c 
> b/tests/ntfsv/tet_scOutage_reinitializeHandle.c
> --- a/tests/ntfsv/tet_scOutage_reinitializeHandle.c
> +++ b/tests/ntfsv/tet_scOutage_reinitializeHandle.c
> @@ -509,7 +509,7 @@ SaAisErrorT scoutage_saNtfObjectCreateDe
>                       ntf_handle,
>                       objCreateDelete_notification,
>                       0,
> -                     (SaUint16T)(sizeof(DEFAULT_ADDITIONAL_TEXT) +1),
> +                     (SaUint16T)(strlen(DEFAULT_ADDITIONAL_TEXT) +1),
>                       0,
>                       2,
>                       SA_NTF_ALLOC_SYSTEM_LIMIT);
>

------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to