Hello,
In the file /plat/xilinx/zynqmp/aarch64/zynqmp_common.c, there is a function named plat_get_syscnt_freq2 with its definition. Simultaneously, the declaration of this function is included in include/plat/common/platform.h with the name plat_get_syscnt_freq2 and a different parameter type, leading to a violation when running the Coverity MISRA-C analysis for the Zynqmp platform. Declaration uses a different parameter type than the function Definition. Addressing this issue by introducing a typedef for plat_get_syscnt_freq2 in platform.h and specifying its type as uint32_t resolves the violation. However, it introduces a challenge for other platforms, as this modification necessitates similar changes across various platforms, causing violations in those areas due to the adjusted typedef. Is it possible to fix with the typedef? Please suggest.
Regards, Nithin
Hello Nithin,
Rather than making a change that would require all platforms to adapt, I think it would be preferrable to fix Xilinx implementation and change the return type of its plat_get_syscnt_freq2() to unsigned int, as mandated by the porting guide [1].
Best regards, Sandrine
[1] https://trustedfirmware-a.readthedocs.io/en/latest/porting-guide.html#functi... ________________________________ From: Nithin G via TF-A tf-a@lists.trustedfirmware.org Sent: 06 December 2023 12:08 To: tf-a@lists.trustedfirmware.org tf-a@lists.trustedfirmware.org Subject: [TF-A] Declaration uses a different parameter type than the function Definition.
Hello,
In the file /plat/xilinx/zynqmp/aarch64/zynqmp_common.c, there is a function named plat_get_syscnt_freq2 with its definition. Simultaneously, the declaration of this function is included in include/plat/common/platform.h with the name plat_get_syscnt_freq2 and a different parameter type, leading to a violation when running the Coverity MISRA-C analysis for the Zynqmp platform. Declaration uses a different parameter type than the function Definition. Addressing this issue by introducing a typedef for plat_get_syscnt_freq2 in platform.h and specifying its type as uint32_t resolves the violation. However, it introduces a challenge for other platforms, as this modification necessitates similar changes across various platforms, causing violations in those areas due to the adjusted typedef. Is it possible to fix with the typedef? Please suggest.
Regards, Nithin -- TF-A mailing list -- tf-a@lists.trustedfirmware.org To unsubscribe send an email to tf-a-leave@lists.trustedfirmware.org
Hello Sandrine,
Thanks for responding,
If the return type of plat_get_syscnt_freq2() is modified to unsigned int, it would result in another violation of Directive 4.6, as it involves using a basic numerical type without providing size and signedness information. To fix this need to change typedef uint32_t in definition and declaration as well. again, it is not possible to change in header file. Please suggest?
Regards, Nithin
Hi Nithin,
There is a wiki page about MISRA here: https://developer.trustedfirmware.org/w/tf_a/tf-a-misra-analysis/
And a file attached to it (MISRA-and-TF-Analysis-v1.3.ods). For rule 4.6, I can see that: D 4.6 MISRA C 2012 Advisory No No We use a mix of both. It would be too disruptive for the project to change.
So I can see 2 solutions there: - follow TF-A document and have a deviation for this rule - or make a patch to change 'unsigned int plat_get_syscnt_freq2(void)' to 'uint32_t plat_get_syscnt_freq2(void)' for all platforms and docs
Best regards, Yann
On 12/6/23 13:12, Nithin G via TF-A wrote:
Hello Sandrine,
Thanks for responding,
If the return type of plat_get_syscnt_freq2() is modified to unsigned int, it would result in another violation of Directive 4.6, as it involves using a basic numerical type without providing size and signedness information. To fix this need to change typedef uint32_t in definition and declaration as well. again, it is not possible to change in header file. Please suggest?
Regards, Nithin
Hello Sandrine,
Thanks for your reply,
I will check the document.
Regards, Nithin
Hello
Thanks for your reply.
I am getting the same violation rule.8.3 for /drivers/console/multi_console.c and related files also. attached the definition of console_unregister function. console_t *console_unregister(console_t *to_be_deleted) { console_t **ptr;
assert(to_be_deleted != NULL);
for (ptr = &console_list; *ptr != NULL; ptr = &(*ptr)->next) if (*ptr == to_be_deleted) { *ptr = (*ptr)->next; return to_be_deleted; }
return NULL; } Here, the declaration uses the different parameter type than console_unregister in include/drivers/console.h console_t *console_unregister(console_t *console);
However, is it possible to change in the definition of the function to match with the declaration. Please suggest?
Regards, Nithin G
tf-a@lists.trustedfirmware.org