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

wtperf: MSVC complains about float conversion in throttle code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Done
    • None
    • WT2.9.0
    • None
    • None

    Description

      david.hows, in wtperf/wtperf_throttle.c, there's this code:

      throttle_cfg->ops_count =
          (uint64_t) (float)(usecs_delta /
          throttle_cfg->usecs_increment) *
          (float)throttle_cfg->ops_per_increment;
      throttle_cfg->last_increment = now;
      

      and MSVC complains:

      bench\wtperf\wtperf_throttle.c(110): warning C4244: '=': conversion from
      'float' to 'uint64_t', possible loss of data
      

      I'm not sure what's going on here – all of the fields are uint64_t, not sure why we're casting everything to float, couldn't we get the same results using an integer expression?

      I suspect the warning would go away if we just cast the result of the calculation to uint64_t, but I don't really understand what's going on here.

      Attachments

        Issue Links

          Activity

            People

              david.hows David Hows
              keith.bostic@mongodb.com Keith Bostic (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: