Qt: Clean up sign warnings

This commit is contained in:
Vicki Pfau 2021-01-16 01:04:56 -08:00
parent b6dbbb14ab
commit ffa5e65856
8 changed files with 30 additions and 31 deletions

View File

@ -40,20 +40,18 @@ void AudioDevice::setInput(mCoreThread* 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);

View File

@ -52,7 +52,7 @@ void AudioProcessorSDL::pause() {
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);

View File

@ -200,7 +200,7 @@ void LoadSaveState::loadState(int slot) {
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();
}

View File

@ -109,10 +109,10 @@ MapView::MapView(std::shared_ptr<CoreController> controller, QWidget* parent)
}
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;

View File

@ -347,7 +347,7 @@ void MemoryModel::paintEvent(QPaintEvent*) {
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 @@ void MemoryModel::adjustCursor(int adjust, bool shift) {
}
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;
}
}

View File

@ -256,7 +256,7 @@ void MemoryView::updateSelection(uint32_t start, uint32_t end) {
}
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));

View File

@ -133,8 +133,8 @@ void ObjView::updateTilesGBA(bool force) {
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 @@ void ObjView::updateTilesGB(bool force) {
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) {

View File

@ -69,7 +69,7 @@ void PaletteView::updatePalette() {
return;
}
const uint16_t* palette;
size_t count;
int count;
switch (m_controller->platform()) {
#ifdef M_CORE_GBA
case mPLATFORM_GBA: