mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-02 08:39:46 +02:00
Re-fix some warnings about mixing signed and unsigned better...
... Assuming that large unsigned magnitudes with high order bit set are not the problem, but signed negatives of small magnitude may be: 1) Always cast the unsigned to signed in comparisons, not the other way. Also: 2) Cast unsigned TERM to signed by itself, before subtracting. Don't cast the result. 3) Rewrite some comparisons by moving subtracted term to other side. See commits d2fe7b1757d77d93d82d53685a118517a4d2e996 f463eda36c059236ecc168919c745eb687170c95
This commit is contained in:
parent
85ceb5d7f4
commit
52a7f2320d
@ -556,7 +556,7 @@ size_t BlockFile::CommonReadData(
|
||||
else {
|
||||
auto channels = info.channels;
|
||||
wxASSERT(channels >= 1);
|
||||
wxASSERT(channel < (unsigned int)channels);
|
||||
wxASSERT((int)channel < channels);
|
||||
|
||||
if (channels == 1 &&
|
||||
format == int16Sample &&
|
||||
|
@ -77,14 +77,14 @@ bool Envelope::ConsistencyCheck()
|
||||
|
||||
while ( nextI - ii > 2 ) {
|
||||
// too many coincident time values
|
||||
if (ii == (size_t)mDragPoint || (int)(nextI - 1) == mDragPoint)
|
||||
if ((int)ii == mDragPoint || (int)nextI - 1 == mDragPoint)
|
||||
// forgivable
|
||||
;
|
||||
else {
|
||||
consistent = false;
|
||||
// repair it
|
||||
Delete( nextI - 2 );
|
||||
if (mDragPoint >= (int)(nextI - 2))
|
||||
if (mDragPoint >= (int)nextI - 2)
|
||||
--mDragPoint;
|
||||
--nextI, --count;
|
||||
// wxLogError
|
||||
@ -731,7 +731,7 @@ void Envelope::CollapseRegion( double t0, double t1, double sampleDur )
|
||||
auto len = mEnv.size();
|
||||
for ( size_t i = begin; i < len; ++i ) {
|
||||
auto &point = mEnv[i];
|
||||
if (rightPoint && i == (size_t)begin)
|
||||
if (rightPoint && (int)i == begin)
|
||||
// Avoid roundoff error.
|
||||
// Make exactly equal times of neighboring points so that we have
|
||||
// a real discontinuity.
|
||||
@ -884,7 +884,7 @@ void Envelope::RemoveUnneededPoints
|
||||
// Stop at any discontinuity
|
||||
if ( index > 0 && isDiscontinuity( index - 1 ) )
|
||||
break;
|
||||
if ( (unsigned int)(index + 1) < len && isDiscontinuity( index ) )
|
||||
if ( (index + 1) < (int)len && isDiscontinuity( index ) )
|
||||
break;
|
||||
|
||||
if ( ! remove( index, false ) )
|
||||
@ -1627,7 +1627,7 @@ double Envelope::SolveIntegralOfInverse( double t0, double area ) const
|
||||
if(area == 0.0)
|
||||
return t0;
|
||||
|
||||
unsigned int count = mEnv.size();
|
||||
const auto count = mEnv.size();
|
||||
if(count == 0) // 'empty' envelope
|
||||
return t0 + area * mDefaultValue;
|
||||
|
||||
@ -1655,7 +1655,7 @@ double Envelope::SolveIntegralOfInverse( double t0, double area ) const
|
||||
else if(t0 >= mEnv[count - 1].GetT()) // t0 at or following the last point
|
||||
{
|
||||
if (area < 0) {
|
||||
i = count - 2;
|
||||
i = (int)count - 2;
|
||||
lastT = mEnv[count - 1].GetT();
|
||||
lastVal = mEnv[count - 1].GetVal();
|
||||
double added = (lastT - t0) / lastVal; // negative
|
||||
|
@ -1217,7 +1217,7 @@ void Sequence::SetSamples(samplePtr buffer, sampleFormat format,
|
||||
// but it guards against infinite loop in case of inconsistencies
|
||||
// (too-small files, not yet seen?)
|
||||
// that cause the loop to make no progress because blen == 0
|
||||
&& (unsigned int)b < size
|
||||
&& b < (int)size
|
||||
) {
|
||||
newBlock.push_back( mBlock[b] );
|
||||
SeqBlock &block = newBlock.back();
|
||||
|
@ -2297,7 +2297,7 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
|
||||
#endif //EXPERIMENTAL_FFT_Y_GRID
|
||||
|
||||
if (!updated && clip->mSpecPxCache->valid &&
|
||||
(clip->mSpecPxCache->len == (size_t)(hiddenMid.height * hiddenMid.width))
|
||||
((int)clip->mSpecPxCache->len == hiddenMid.height * hiddenMid.width)
|
||||
&& scaleType == clip->mSpecPxCache->scaleType
|
||||
&& gain == clip->mSpecPxCache->gain
|
||||
&& range == clip->mSpecPxCache->range
|
||||
|
@ -914,7 +914,7 @@ void TrackPanel::HandleMotion
|
||||
auto begin = mTargets.begin(), end = mTargets.end(),
|
||||
iter = std::find(begin, end, oldHandle);
|
||||
if (iter != end) {
|
||||
unsigned int newPosition = iter - begin;
|
||||
size_t newPosition = iter - begin;
|
||||
if (newPosition <= oldPosition)
|
||||
mTarget = newPosition;
|
||||
// else, some NEW hit and this position takes priority
|
||||
|
@ -133,12 +133,12 @@ public:
|
||||
//for some reason, the cache is set up to access up to array[len], not array[len-1]
|
||||
if(invalStart <0)
|
||||
invalStart =0;
|
||||
else if((size_t)invalStart > len)
|
||||
else if(invalStart > (long)len)
|
||||
invalStart = len;
|
||||
|
||||
if(invalEnd <0)
|
||||
invalEnd =0;
|
||||
else if((size_t)invalEnd > len)
|
||||
else if(invalEnd > (long)len)
|
||||
invalEnd = len;
|
||||
|
||||
|
||||
@ -153,13 +153,13 @@ public:
|
||||
{
|
||||
//if the regions intersect OR are pixel adjacent
|
||||
InvalidRegion ®ion = mRegions[i];
|
||||
if(region.start <= (size_t)(invalEnd+1)
|
||||
&& (region.end + 1) >= (size_t)invalStart)
|
||||
if((long)region.start <= (invalEnd+1)
|
||||
&& ((long)region.end + 1) >= invalStart)
|
||||
{
|
||||
//take the union region
|
||||
if(region.start > (size_t)invalStart)
|
||||
if((long)region.start > invalStart)
|
||||
region.start = invalStart;
|
||||
if((int)region.end < invalEnd)
|
||||
if((long)region.end < invalEnd)
|
||||
region.end = invalEnd;
|
||||
added=true;
|
||||
break;
|
||||
@ -206,7 +206,7 @@ public:
|
||||
}
|
||||
|
||||
//if we are past the end of the region we added, we are past the area of regions that might be oversecting.
|
||||
if(invalEnd < 0 || region.start > (size_t)invalEnd)
|
||||
if(invalEnd < 0 || (long)region.start > invalEnd)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -842,7 +842,7 @@ bool SpecCache::CalculateOneSpectrum
|
||||
from = sampleCount(
|
||||
where[0].as_double() + xx * (rate / pixelsPerSecond)
|
||||
);
|
||||
else if ((size_t)xx > len)
|
||||
else if (xx > (int)len)
|
||||
from = sampleCount(
|
||||
where[len].as_double() + (xx - len) * (rate / pixelsPerSecond)
|
||||
);
|
||||
|
@ -307,7 +307,7 @@ bool EffectClickRemoval::RemoveClicks(size_t len, float *buffer)
|
||||
left = i+s2;
|
||||
}
|
||||
} else {
|
||||
if(left != 0 && (int)(i-left+s2) <= ww*2) {
|
||||
if(left != 0 && ((int)i-left+s2) <= ww*2) {
|
||||
float lv = buffer[left];
|
||||
float rv = buffer[i+ww+s2];
|
||||
for(j=left; j<i+ww+s2; j++) {
|
||||
|
@ -167,7 +167,7 @@ bool EffectFindClipping::ProcessOne(LabelTrack * lt,
|
||||
try {
|
||||
// mStart should be positive.
|
||||
// if we are throwing bad_alloc and mStart is negative, find out why.
|
||||
if (blockSize < (size_t)mStart)
|
||||
if (mStart < 0 || (int)blockSize < mStart)
|
||||
// overflow
|
||||
throw std::bad_alloc{};
|
||||
buffer.reinit(blockSize);
|
||||
|
@ -705,7 +705,8 @@ void EffectNoiseReduction::Worker::ApplyFreqSmoothing(FloatVector &gains)
|
||||
for (size_t ii = 0; ii < mSpectrumSize; ++ii)
|
||||
gains[ii] = log(gains[ii]);
|
||||
|
||||
for (int ii = 0; (size_t)ii < mSpectrumSize; ++ii) {
|
||||
// ii must be signed
|
||||
for (int ii = 0; ii < (int)mSpectrumSize; ++ii) {
|
||||
const int j0 = std::max(0, ii - (int)mFreqSmoothingBins);
|
||||
const int j1 = std::min(mSpectrumSize - 1, ii + mFreqSmoothingBins);
|
||||
for(int jj = j0; jj <= j1; ++jj) {
|
||||
|
@ -1869,7 +1869,7 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
|
||||
|
||||
short *mixed = (short *)mixer->GetBuffer();
|
||||
|
||||
if (blockLen < (unsigned int)inSamples) {
|
||||
if ((int)blockLen < inSamples) {
|
||||
if (channels > 1) {
|
||||
bytes = exporter.EncodeRemainder(mixed, blockLen, buffer.get());
|
||||
}
|
||||
|
@ -743,7 +743,7 @@ ProgressResult FFmpegImportFileHandle::WriteData(streamContext *sc)
|
||||
unsigned int pos = 0;
|
||||
while (pos < insamples)
|
||||
{
|
||||
for (size_t chn = 0; chn < (size_t)sc->m_stream->codec->channels; chn++)
|
||||
for (size_t chn = 0; (int)chn < sc->m_stream->codec->channels; chn++)
|
||||
{
|
||||
if (chn < nChannels)
|
||||
{
|
||||
|
@ -133,13 +133,13 @@ void MeterUpdateQueue::Clear()
|
||||
// queue was full.
|
||||
bool MeterUpdateQueue::Put(MeterUpdateMsg &msg)
|
||||
{
|
||||
// mStart cnan be greater than mEnd because it is all mod mBufferSize
|
||||
// mStart can be greater than mEnd because it is all mod mBufferSize
|
||||
wxASSERT( (mEnd + mBufferSize - mStart) >= 0 );
|
||||
int len = (mEnd + mBufferSize - mStart) % mBufferSize;
|
||||
|
||||
// Never completely fill the queue, because then the
|
||||
// state is ambiguous (mStart==mEnd)
|
||||
if (len >= (int)(mBufferSize-1))
|
||||
if (len + 1 >= (int)(mBufferSize))
|
||||
return false;
|
||||
|
||||
//wxLogDebug(wxT("Put: %s"), msg.toString());
|
||||
|
Loading…
x
Reference in New Issue
Block a user