Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: REM Cost Reform

...

Code Block
bgColor#ccccff
langc
float calc_percentage(float value) {
  return (float)(value * 0.1f);
}

void float_routine(void) {
  float value = 99.0f;
  long double percentage;

  percentage = calc_percentage(value);
}

 


Forcing the range and precision inside the calcPercentage() function is a good way to fix the problem once without having to apply fixes in multiple locations (every time calcPercentage() is called).  

...

Failure to follow this guideline can lead to inconsistent results across different platforms.

Rule

Severity

Likelihood

Detectable

Remediation Cost

Repairable

Priority

Level

FLP07-C

Low

Probable

Medium

No

Yes

P4

L3

Automated Detection

Tool

Version

Checker

Description

Axivion Bauhaus Suite

Include Page
Axivion Bauhaus Suite_V
Axivion Bauhaus Suite_V

CertC-FLP07
Klocwork

Include Page
Klocwork_V
Klocwork_V

CERT.RTN.FLT.CAST.DBL
CERT.RTN.FLT.IMPLICIT.CAST.DBL

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Bibliography

[ISO/IEC 9899:2011]Subclause 6.8.6.4, "The return Statement"
Annex F.6, "The return Statement"
[WG14/N1396]
 

...



...