mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-27 01:11:14 +00:00
717d482cd0
Fix compilation warning in variable length array msg and ret value not handled. Fix compilation warning: /__w/openwrt/openwrt/openwrt/build_dir/target-arm-openwrt-linux-muslgnueabi_musl/linux-ipq40xx_chromium/dsl_cpe_mei-ugw_8.5.2.10/src/drv_mei_cpe_api_intern.c: In function 'MEI_Internal_DumpMessage': /__w/openwrt/openwrt/openwrt/build_dir/target-arm-openwrt-linux-muslgnueabi_musl/linux-ipq40xx_chromium/dsl_cpe_mei-ugw_8.5.2.10/src/drv_mei_cpe_api_intern.c:441:4: error: ISO C90 forbids variable length array 'msg' [-Werror=vla] 441 | char msg[nMsgSize]; | ^~~~ /__w/openwrt/openwrt/openwrt/build_dir/target-arm-openwrt-linux-muslgnueabi_musl/linux-ipq40xx_chromium/dsl_cpe_mei-ugw_8.5.2.10/src/drv_mei_cpe_api_intern.c:442:4: error: ISO C90 forbids array 'buf' whose size cannot be evaluated [-Werror=vla] 442 | char buf[nBufSize]; | ^~~~ cc1: all warnings being treated as errors /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-arm-openwrt-linux-muslgnueabi_musl/linux-ipq40xx_generic/dsl_cpe_mei-ugw_8.5.2.10/src/drv_mei_cpe_linux.c: In function 'MEI_Ioctl': /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-arm-openwrt-linux-muslgnueabi_musl/linux-ipq40xx_generic/dsl_cpe_mei-ugw_8.5.2.10/src/drv_mei_cpe_linux.c:1270:4: error: ignoring return value of 'copy_to_user' declared with attribute 'warn_unused_result' [-Werror=unused-result] 1270 | copy_to_user( ((IOCTL_MEI_arg_t *)nArgument), &local_args, retSize); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-arm-openwrt-linux-muslgnueabi_musl/linux-ipq40xx_generic/dsl_cpe_mei-ugw_8.5.2.10/src/drv_mei_cpe_linux.c: In function 'MEI_IoctlMeiDbgAccessWr_Wrap': /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-arm-openwrt-linux-muslgnueabi_musl/linux-ipq40xx_generic/dsl_cpe_mei-ugw_8.5.2.10/src/drv_mei_cpe_linux.c:3574:4: error: ignoring return value of 'copy_to_user' declared with attribute 'warn_unused_result' [-Werror=unused-result] 3574 | copy_to_user( (void *)&pUserArgument->count, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3575 | (void *)&pLocalArgument->count, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3576 | sizeof(pUserArgument->count) ) ; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-arm-openwrt-linux-muslgnueabi_musl/linux-ipq40xx_generic/dsl_cpe_mei-ugw_8.5.2.10/src/drv_mei_cpe_linux.c: In function 'MEI_IoctlMeiDbgAccessRd_Wrap': /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-arm-openwrt-linux-muslgnueabi_musl/linux-ipq40xx_generic/dsl_cpe_mei-ugw_8.5.2.10/src/drv_mei_cpe_linux.c:3603:7: error: ignoring return value of 'copy_to_user' declared with attribute 'warn_unused_result' [-Werror=unused-result] 3603 | copy_to_user( pUserBuf, | ^~~~~~~~~~~~~~~~~~~~~~~ 3604 | pLocalArgument->pData_32, | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3605 | pLocalArgument->count * sizeof(IFX_uint32_t) ) ; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-arm-openwrt-linux-muslgnueabi_musl/linux-ipq40xx_generic/dsl_cpe_mei-ugw_8.5.2.10/src/drv_mei_cpe_linux.c:3610:4: error: ignoring return value of 'copy_to_user' declared with attribute 'warn_unused_result' [-Werror=unused-result] 3610 | copy_to_user( (void *)&pUserArgument->count, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3611 | (void *)&pLocalArgument->count, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3612 | sizeof(pUserArgument->count) ) ; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
100 lines
3.1 KiB
Diff
100 lines
3.1 KiB
Diff
--- a/src/drv_mei_cpe_api_intern.c
|
|
+++ b/src/drv_mei_cpe_api_intern.c
|
|
@@ -421,7 +421,9 @@ IFX_int32_t MEI_InternalMsgSend(
|
|
return retVal;
|
|
}
|
|
|
|
-static IFX_void_t MEI_Internal_DumpMessage(
|
|
+#define MEI_Internal_DumpMessage_bufSize 10
|
|
+
|
|
+static IFX_int32_t MEI_Internal_DumpMessage(
|
|
MEI_DYN_CNTRL_T *pMeiDynCntrl,
|
|
const IFX_uint16_t nMsgId,
|
|
const IFX_uint16_t *pData,
|
|
@@ -435,15 +437,20 @@ static IFX_void_t MEI_Internal_DumpMessa
|
|
IFX_uint8_t i;
|
|
const IFX_uint32_t nCommonPayloadSize = 5*nSize/2;
|
|
const IFX_uint8_t nInfoSize = 35;
|
|
- const IFX_uint8_t nBufSize = 10;
|
|
IFX_uint32_t nMsgSize = nCommonPayloadSize + nInfoSize;
|
|
IFX_uint32_t nCharsWrittenToBuf = 0;
|
|
- char msg[nMsgSize];
|
|
- char buf[nBufSize];
|
|
+ char *msg;
|
|
+ char buf[MEI_Internal_DumpMessage_bufSize];
|
|
|
|
if((pData == IFX_NULL) || (nSize < 4))
|
|
{
|
|
- return ;
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ msg = kcalloc(nMsgSize, sizeof(*msg), GFP_KERNEL);
|
|
+ if (!msg)
|
|
+ {
|
|
+ return -ENOMEM;
|
|
}
|
|
|
|
pMsg16 = (IFX_uint16_t*)(pData+2);
|
|
@@ -464,7 +471,8 @@ static IFX_void_t MEI_Internal_DumpMessa
|
|
/* 32-bit payload elements */
|
|
for (i=0; i<((nSize-4)/4); i++)
|
|
{
|
|
- nCharsWrittenToBuf = snprintf(buf, nBufSize, " %08X", pMsg32[i]);
|
|
+ nCharsWrittenToBuf = snprintf(buf, MEI_Internal_DumpMessage_bufSize,
|
|
+ " %08X", pMsg32[i]);
|
|
strncat(msg, buf, nMsgSize);
|
|
nMsgSize -= nCharsWrittenToBuf;
|
|
}
|
|
@@ -474,7 +482,8 @@ static IFX_void_t MEI_Internal_DumpMessa
|
|
/* 16-bit payload elements */
|
|
for (i=0; i<((nSize-4)/2); i++)
|
|
{
|
|
- nCharsWrittenToBuf = snprintf(buf, nBufSize, " %04X", pMsg16[i]);
|
|
+ nCharsWrittenToBuf = snprintf(buf, MEI_Internal_DumpMessage_bufSize,
|
|
+ " %04X", pMsg16[i]);
|
|
strncat(msg, buf, nMsgSize);
|
|
nMsgSize -= nCharsWrittenToBuf;
|
|
}
|
|
@@ -482,6 +491,10 @@ static IFX_void_t MEI_Internal_DumpMessa
|
|
strncat(msg, MEI_DRV_CRLF, nMsgSize);
|
|
|
|
PRN_DBG_USR_RAW(MEI_MSG_DUMP_API, dbg_level, (msg));
|
|
+
|
|
+ kfree(msg);
|
|
+
|
|
+ return 0;
|
|
}
|
|
|
|
IFX_int32_t MEI_InternalSendMessage(
|
|
@@ -503,18 +516,25 @@ IFX_int32_t MEI_InternalSendMessage(
|
|
msg.ack_msg.pPayload = (unsigned char *)pDataAck;
|
|
msg.ack_msg.paylSize_byte = nLenAck;
|
|
|
|
- MEI_Internal_DumpMessage(pMeiDynCntrl, msg.write_msg.msgId,
|
|
+ ret = MEI_Internal_DumpMessage(pMeiDynCntrl, msg.write_msg.msgId,
|
|
(IFX_uint16_t *)msg.write_msg.pPayload, msg.write_msg.paylSize_byte,
|
|
IFX_FALSE, MEI_DRV_PRN_LEVEL_NORMAL);
|
|
|
|
+ if (ret < 0)
|
|
+ {
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
ret = MEI_InternalMsgSend(pMeiDynCntrl, &msg);
|
|
|
|
- if (ret >= 0)
|
|
+ if (ret < 0)
|
|
{
|
|
- MEI_Internal_DumpMessage(pMeiDynCntrl, msg.ack_msg.msgId,
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ ret = MEI_Internal_DumpMessage(pMeiDynCntrl, msg.ack_msg.msgId,
|
|
(IFX_uint16_t *)msg.ack_msg.pPayload, msg.ack_msg.paylSize_byte,
|
|
IFX_TRUE, MEI_DRV_PRN_LEVEL_NORMAL);
|
|
- }
|
|
|
|
return ret;
|
|
}
|