PVS-StudioWarnings

PVS-Studio warning V636 for OpenDDS

Nov 19th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. inline ACE_UINT32
  2. ACE_CU64_TO_CU32 (ACE_UINT64 n)
  3. {
  4.   return static_cast<ACE_UINT32> (n);
  5. }
  6.  
  7. inline void
  8. Latency_Stats::dump_results (const ACE_TCHAR *test_name,
  9.                              const ACE_TCHAR *sub_test)
  10. {
  11.   ....
  12.   double min_usec = ACE_CU64_TO_CU32 (this->min_) / gsf;
  13.   ....
  14. }
  15.  
  16. This suspicious code was found in OpenDDS project by PVS-Studio static code analyzer.
  17. Warning message is:
  18. V636 The 'ACE_CU64_TO_CU32(this->min_) / gsf' expression was implicitly casted from 'int' type to 'double' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;. latency_stats.h 73
  19.  
  20. PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment