all repos — mgba @ ffa5e65856c5950a26b3aedd2cc35d7f2f5041dc

mGBA Game Boy Advance Emulator

Qt: Clean up sign warnings
Vicki Pfau vi@endrift.com
Sat, 16 Jan 2021 01:04:56 -0800
commit

ffa5e65856c5950a26b3aedd2cc35d7f2f5041dc

parent

b6dbbb14abc159b9378353df2d978527f3414389

M src/platform/qt/AudioDevice.cppsrc/platform/qt/AudioDevice.cpp

@@ -40,20 +40,18 @@ m_context = input;

} qint64 AudioDevice::readData(char* data, qint64 maxSize) { - if (maxSize > 0xFFFFFFFFLL) { - maxSize = 0xFFFFFFFFLL; - } - if (!m_context->core) { LOG(QT, WARN) << tr("Audio device is missing its core"); return 0; } + maxSize /= sizeof(GBAStereoSample); mCoreSyncLockAudio(&m_context->impl->sync); - int available = blip_samples_avail(m_context->core->getAudioChannel(m_context->core, 0)); - if (available > maxSize / sizeof(GBAStereoSample)) { - available = maxSize / sizeof(GBAStereoSample); - } + int available = std::min<qint64>({ + blip_samples_avail(m_context->core->getAudioChannel(m_context->core, 0)), + maxSize, + std::numeric_limits<int>::max() + }); blip_read_samples(m_context->core->getAudioChannel(m_context->core, 0), &reinterpret_cast<GBAStereoSample*>(data)->left, available, true); blip_read_samples(m_context->core->getAudioChannel(m_context->core, 1), &reinterpret_cast<GBAStereoSample*>(data)->right, available, true); mCoreSyncConsumeAudio(&m_context->impl->sync);
M src/platform/qt/AudioProcessorSDL.cppsrc/platform/qt/AudioProcessorSDL.cpp

@@ -52,7 +52,7 @@ }

void AudioProcessorSDL::setBufferSamples(int samples) { AudioProcessor::setBufferSamples(samples); - if (m_audio.samples != samples) { + if (m_audio.samples != static_cast<size_t>(samples)) { m_audio.samples = samples; if (m_audio.core) { mSDLDeinitAudio(&m_audio);
M src/platform/qt/LoadSaveState.cppsrc/platform/qt/LoadSaveState.cpp

@@ -200,7 +200,7 @@

unsigned width, height; thread->core->desiredVideoDimensions(thread->core, &width, &height); mStateExtdataItem item; - if (mStateExtdataGet(&extdata, EXTDATA_SCREENSHOT, &item) && item.size >= width * height * 4) { + if (mStateExtdataGet(&extdata, EXTDATA_SCREENSHOT, &item) && item.size >= static_cast<int32_t>(width * height * 4)) { stateImage = QImage((uchar*) item.data, width, height, QImage::Format_ARGB32).rgbSwapped(); }
M src/platform/qt/MapView.cppsrc/platform/qt/MapView.cpp

@@ -109,10 +109,10 @@ selectTile(0, 0);

} void MapView::selectMap(int map) { - if (map >= mMapCacheSetSize(&m_cacheSet->maps)) { + if (map == m_map || map < 0) { return; } - if (map == m_map) { + if (static_cast<unsigned>(map) >= mMapCacheSetSize(&m_cacheSet->maps)) { return; } m_map = map;
M src/platform/qt/MemoryModel.cppsrc/platform/qt/MemoryModel.cpp

@@ -347,7 +347,7 @@ }

int height = (viewport()->size().height() - m_cellHeight) / m_cellHeight; for (int y = 0; y < height; ++y) { int yp = m_cellHeight * y + m_margins.top(); - if ((y + m_top) * 16 >= m_size) { + if ((y + m_top) * 16U >= m_size) { break; } QString data;

@@ -673,34 +673,35 @@ return;

} int cursorPosition = m_top; if (shift) { + uint32_t absolute; if (m_selectionAnchor == m_selection.first) { if (adjust < 0 && m_base - adjust > m_selection.second) { - adjust = m_base - m_selection.second + m_align; + absolute = m_base - m_selection.second + m_align; } else if (adjust > 0 && m_selection.second + adjust >= m_base + m_size) { - adjust = m_base + m_size - m_selection.second; + absolute = m_base + m_size - m_selection.second; } - adjust += m_selection.second; - if (adjust <= m_selection.first) { + absolute += m_selection.second; + if (absolute <= m_selection.first) { m_selection.second = m_selection.first + m_align; - m_selection.first = adjust - m_align; + m_selection.first = absolute - m_align; cursorPosition = m_selection.first; } else { - m_selection.second = adjust; + m_selection.second = absolute; cursorPosition = m_selection.second - m_align; } } else { if (adjust < 0 && m_base - adjust > m_selection.first) { - adjust = m_base - m_selection.first; + absolute = m_base - m_selection.first; } else if (adjust > 0 && m_selection.first + adjust >= m_base + m_size) { - adjust = m_base + m_size - m_selection.first - m_align; + absolute = m_base + m_size - m_selection.first - m_align; } - adjust += m_selection.first; - if (adjust >= m_selection.second) { + absolute += m_selection.first; + if (absolute >= m_selection.second) { m_selection.first = m_selection.second - m_align; - m_selection.second = adjust + m_align; - cursorPosition = adjust; + m_selection.second = absolute + m_align; + cursorPosition = absolute; } else { - m_selection.first = adjust; + m_selection.first = absolute; cursorPosition = m_selection.first; } }
M src/platform/qt/MemoryView.cppsrc/platform/qt/MemoryView.cpp

@@ -256,7 +256,7 @@ updateStatus();

} void MemoryView::updateStatus() { - int align = m_ui.hexfield->alignment(); + unsigned align = m_ui.hexfield->alignment(); mCore* core = m_controller->thread()->core; QByteArray selection(m_ui.hexfield->serialize()); QString text(m_ui.hexfield->decodeText(selection));
M src/platform/qt/ObjView.cppsrc/platform/qt/ObjView.cpp

@@ -133,8 +133,8 @@ m_tileOffset = newInfo.tile;

mTileCache* tileCache = mTileCacheSetGetPointer(&m_cacheSet->tiles, newInfo.paletteSet); int i = 0; - for (int y = 0; y < newInfo.height; ++y) { - for (int x = 0; x < newInfo.width; ++x, ++i, ++tile, ++tileBase) { + for (unsigned y = 0; y < newInfo.height; ++y) { + for (unsigned x = 0; x < newInfo.width; ++x, ++i, ++tile, ++tileBase) { const color_t* data = mTileCacheGetTileIfDirty(tileCache, &m_tileStatus[16 * tileBase], tile, newInfo.paletteId); if (data) { m_ui.tiles->setTile(i, data);

@@ -224,7 +224,7 @@ m_boundary = 1024;

int i = 0; m_ui.tile->setPalette(newInfo.paletteId); - for (int y = 0; y < newInfo.height; ++y, ++i) { + for (unsigned y = 0; y < newInfo.height; ++y, ++i) { unsigned t = tile + i; const color_t* data = mTileCacheGetTileIfDirty(tileCache, &m_tileStatus[8 * t], t, newInfo.paletteId); if (data) {
M src/platform/qt/PaletteView.cppsrc/platform/qt/PaletteView.cpp

@@ -69,7 +69,7 @@ if (!m_controller->thread() || !m_controller->thread()->core) {

return; } const uint16_t* palette; - size_t count; + int count; switch (m_controller->platform()) { #ifdef M_CORE_GBA case mPLATFORM_GBA: