<div dir="ltr">Hi Charls<div><br></div><div>You're finished up on the wrong reflector. This is the working group for the ISO C language committee's safety and security working group - principally responsible for </div><div>ISO_IEC_TS_17961  C secure coding rules.  We aren't directly connected with MISRA.</div><div><br></div><div>I suggest you post your questions either on the MISRA bulletin board    <a href="https://www.misra.org.uk/forum/index.php">https://www.misra.org.uk/forum/index.php</a></div><div>or find an appropriate forum on   <a href="http://stackoverflow.com">stackoverflow.com</a></div><div><br></div><div>For question 1, something like</div><div><br></div><div>          int math_signf(const int val)</div>                 {if (val < 0) return 1;<div>                  if (val > 0) return -1;</div><div>                  return 0;<br>                 }</div><div><br></div><div>should do the trick - note MISRA doesn't allow implicit int for returns and parameters</div><div><br></div><div>                 Clive Pygott</div><div>                 LDRA Inc<br><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 1, 2020 at 10:16 AM Charls D. Chap <<a href="mailto:chapcharls@gmail.com">chapcharls@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I am on an automotive project, but I do not have access on codeprover<br>
target (like polyspace)<br>
Do you have any link of a codeprover, static analysis tool like<br>
polyspace? in order to explore the rules on my own?<br>
<br>
GCC, C90 (so no use of _Bool)<br>
Q1.<br>
I had this function<br>
math_signf(const val)<br>
{<br>
    return ( (char) ( (0.0f < val) - (0.0f > val) ) ); /* breaks 10.1,<br>
10.5, 10.8 */<br>
}<br>
<br>
I am thinking of this, but I guess it still violates 10.5, 10.8<br>
<br>
math_sign(const val)<br>
{<br>
    return ( ((char)(0.0f < val)) - ((char)(0.0f > val)) ); /* breaks<br>
10.5, 10.8 */<br>
}<br>
<br>
Any help?<br>
<br>
Q2.<br>
float a, b, fy;<br>
unsigned char r = (unsigned char) (( a <= fy) && ( b <= fy)); //<br>
breaks 10.5 should not be cast to an inappropriate essential type<br>
<br>
any help?<br>
<br>
<br>
Q3<br>
float x, y, z;<br>
unsigned char ret = (unsigned char) ( ( x * y) <= z); // breaks 10.8<br>
I am trying to assign to ret  a boolean value, but I cast it to<br>
unsigned char, since _Bool is not allowed<br>
so I have the warning that a Boolean shall not be cast to the<br>
different essential type unsigned<br>
<br>
Any help?<br>
<br>
<br>
Regards,<br>
Charls<br>
<br>
_______________________________________________<br>
C-safe-secure-studygroup mailing list<br>
<a href="mailto:C-safe-secure-studygroup@lists.trustable.io" target="_blank">C-safe-secure-studygroup@lists.trustable.io</a><br>
<a href="https://lists.trustable.io/cgi-bin/mailman/listinfo/c-safe-secure-studygroup" rel="noreferrer" target="_blank">https://lists.trustable.io/cgi-bin/mailman/listinfo/c-safe-secure-studygroup</a><br>
</blockquote></div>