[英]MISRA C:2012 Rule-17.7
I am getting MISRA C:2012 Rule-17.7 violation for below code.我收到以下代码的 MISRA C:2012 Rule-17.7 违规。 I am quite new to C code and MISRA concepts.我对 C 代码和 MISRA 概念很陌生。 Any suggestions would be greatly appreciated.任何建议将不胜感激。
5277: Dem_SetEventStatus(Rte_PDAV_DemEvent_DtcC00100_1, EventStatus);
^
Msg(7:3200) 'Dem_SetEventStatus' returns a value which is not being used.
MISRA C:2012 Rule-17.7
Background背景
The Diagnostic Event Manager (Dem) is a Basic Software Module of the AUTOSAR Diagnostic Services.诊断事件管理器 (Dem) 是AUTOSAR诊断服务的基本软件模块。 Relevant errors are reported either from Application Layer (resp. SW-C) or Basic Software Modules (BSWM).相关错误从应用层(resp. SW-C)或基本软件模块(BSWM)报告。
The Diagnostic Event Manager (Dem) handles and stores the diagnostic events detected by diagnostic monitors in both Software Components (SW-Cs) and Basic Software Modules (BSWM).诊断事件管理器 (Dem) 处理并存储诊断监视器在软件组件 (SW-C) 和基本软件模块 (BSWM) 中检测到的诊断事件。 The stored event information is available via an interface to other BSW modules or SW-Cs.存储的事件信息可通过与其他 BSW 模块或 SW-C 的接口获得。
Function Dem_SetEventStatus() Function Dem_SetEventStatus()
This function has a prototype of:这个function有一个原型:
Std_ReturnType Dem_SetEventStatus(
Dem_EventIdType EventId,
Dem_EventStatusType EventStatus
)
Note the return type is Std_ReturnType
- which returns either E_OK
or E_NOT_OK
请注意,返回类型是Std_ReturnType
- 返回E_OK
或E_NOT_OK
MISRA C:2012 Rule 17.7 MISRA C:2012 规则 17.7
MISRA C:2012 Rule 17.7 requires that you do something with the values returned from a (non- void
) function... MISRA C:2012 规则 17.7 要求您对从(非void
)function... 返回的值执行某些操作
The function is telling you something... it has either succeeded E_OK
or failed E_NOT_OK
- ignoring this information is probably not a good idea. function 告诉你一些事情......它要么成功E_OK
要么失败E_NOT_OK
- 忽略此信息可能不是一个好主意。
If you genuinely want to ignore it, then stick in a (void)
cast - but make sure you add a good clear rationale for doing so.如果你真的想忽略它,那么坚持(void)
演员 - 但确保你添加一个很好的明确理由这样做。
See profile for affiliation查看隶属关系的个人资料
Dem_SetEventStatus
is returning a standard return type with some values (eg, EOK
and E_NOT_OK
) Dem_SetEventStatus
返回带有一些值的标准返回类型(例如, EOK
和E_NOT_OK
)
If the API was successful in doing what it was supposed to do then you will get E_OK
and if some error pops up then you get E_NOK
如果 API 成功地完成了它应该做的事情,那么你会得到E_OK
,如果弹出一些错误,那么你会得到E_NOK
With an indication of error, you may want to retry setting the event or just ignore depending on your strategy to handle the functionality.如果出现错误指示,您可能需要重试设置事件或忽略处理功能的策略。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.