Skip to content

Commit

Permalink
Fix warnings that implicit conversion to float changes the value.
Browse files Browse the repository at this point in the history
There are three warnings about an implicit conversion from into to
float causing the resulting float to be one higher that the original
integer.  Fix two of these by using a static cast, and the third by
using MAXFLOAT instead of INT32_MAX.
  • Loading branch information
linuxdude42 committed Nov 11, 2019
1 parent ab286ae commit a700781
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion mythtv/libs/libmyth/audio/audiooutpututil.cpp
Expand Up @@ -213,7 +213,8 @@ char *AudioOutputUtil::GeneratePinkFrames(char *frames, int channels,
if (chn==channel)
{
/* Don't use MAX volume */
double res = generate_pink_noise_sample(&pink) * 0x03fffffff;
double res = generate_pink_noise_sample(&pink) *
static_cast<float>(0x03fffffff);
int32_t ires = res;
if (bits == 16)
*samp16++ = LE_SHORT(ires >> 16);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/housekeeper.cpp
Expand Up @@ -395,7 +395,7 @@ bool PeriodicHouseKeeperTask::DoCheckRun(QDateTime now)
// remember, this is computing the probability that up to this point, one
// of these tests has returned positive, so each individual test has
// a necessarily low probability
bool res = (rand() > (int)(prob2 * RAND_MAX));
bool res = (rand() > (int)(prob2 * static_cast<float>(RAND_MAX)));
m_currentProb = prob;
// if (res)
// LOG(VB_GENERAL, LOG_DEBUG, QString("%1 will run: this=%2; total=%3")
Expand Down
3 changes: 2 additions & 1 deletion mythtv/libs/libmythtv/vbi608extractor.cpp
Expand Up @@ -22,6 +22,7 @@
#endif

#include <algorithm>
#include <cfloat>
#include <cstdint>
using namespace std;

Expand Down Expand Up @@ -53,7 +54,7 @@ static void print(

static float find_clock_diff(const QList<float> &list)
{
float min_diff = INT32_MAX;
float min_diff = FLT_MAX;
float max_diff = 0.0F;
float avg_diff = 0.0F;
for (uint i = 1; i < uint(list.size()); i++)
Expand Down

0 comments on commit a700781

Please sign in to comment.