Rule M16.10 - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17) +---- Forum: 6.10 Arithmetic Type Conversions (https://forum.misra.org.uk/forumdisplay.php?fid=37) +---- Thread: Rule M16.10 (/showthread.php?tid=1433) |
Rule M16.10 - phdenis - 04-07-2018 Hello all, I'm using the Misra 2004:C rules for the 1st time (e.g. I'm a newbie) and I got several errors linked to the rule M16.10 when I'm using the strncpy function like that: Code: strncpy(MyStr1,MyConstStr, sizeof(MyConstStr); I've fixed this error by adding a pointer to the code which is not used. Code: char *MyPtr; So my question is: For the functions like strncpy, memset and others functions of the same style, do we need to fix the misra error or do we have to justify it plainly? By advance, thanks for your help. Re: Rule M16.10 - dg1980 - 05-07-2018 From ISO C standard: Quote:The strncpy function returns the value of s1. So, no error information to test and hence no violation of 16.10. If you upgrade to MISRA C 2012 you can use this explicit exception for function return values: Code: (void)strncpy(MyStr1,MyConstStr, sizeof(MyConstStr); I did not find a corresponding entry in the obsolete 2004 standard. Re: Rule M16.10 - phdenis - 05-07-2018 Thanks for this reply, the problem is now fixed. Best Regards. Philippe |