Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-8342

Coverity: CID 121074: UNINTENDED_INTEGER_DIVISION in src/support/float.c

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • WT10.0.1, 5.2.0, 5.0.5
    • Affects Version/s: None
    • Component/s: None
    • None

      Coverity link: https://coverity.corp.mongodb.com/reports.htm#v17018/p10049/fileInstanceId=38836915&defectInstanceId=20184607&mergedDefectId=121074&eventId=20184607-0

      37 int38__wt_floatcmp(float f1, float f2)
      39 {
      40 #define WT_FLOAT_PRECISION 1000
      
        CID 121074 (#1 of 1): Result is not floating-point (UNINTENDED_INTEGER_DIVISION)integer_division: Dividing integer expressions 1 and 1000, and then converting the integer quotient to type float. Any remainder, or fractional part of the quotient, is ignored.  To compute and use a non-integer quotient, change or cast either operand to type float. If integer division is intended, consider indicating that by casting the result to type int 
      
      41    if (fabsf(f1 - f2) < 1 / WT_FLOAT_PRECISION)
      42        return (0); 

       

      That is "1 / 1000" is integer zero, not a floating point number.

            Assignee:
            keith.bostic@mongodb.com Keith Bostic (Inactive)
            Reporter:
            donald.anderson@mongodb.com Donald Anderson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: