Qt: Use less questionable way of checking for zeroing
This commit is contained in:
parent
5d7b875629
commit
a9262868fc
@ -15,6 +15,15 @@
|
|||||||
|
|
||||||
using namespace QGBA;
|
using namespace QGBA;
|
||||||
|
|
||||||
|
template<size_t N> bool isZeroed(const uint8_t* mem) {
|
||||||
|
for (size_t i = 0; i < N; ++i) {
|
||||||
|
if (mem[i]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ROMInfo::ROMInfo(std::shared_ptr<CoreController> controller, QWidget* parent)
|
ROMInfo::ROMInfo(std::shared_ptr<CoreController> controller, QWidget* parent)
|
||||||
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
|
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
|
||||||
{
|
{
|
||||||
@ -52,7 +61,7 @@ ROMInfo::ROMInfo(std::shared_ptr<CoreController> controller, QWidget* parent)
|
|||||||
m_ui.crc->setText(tr("(unknown)"));
|
m_ui.crc->setText(tr("(unknown)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(md5, &(const uint8_t[16]) {}, 16) != 0) {
|
if (!isZeroed<16>(md5)) {
|
||||||
m_ui.md5->setText(QString::asprintf("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
m_ui.md5->setText(QString::asprintf("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
||||||
md5[0x0], md5[0x1], md5[0x2], md5[0x3], md5[0x4], md5[0x5], md5[0x6], md5[0x7],
|
md5[0x0], md5[0x1], md5[0x2], md5[0x3], md5[0x4], md5[0x5], md5[0x6], md5[0x7],
|
||||||
md5[0x8], md5[0x9], md5[0xA], md5[0xB], md5[0xC], md5[0xD], md5[0xE], md5[0xF]));
|
md5[0x8], md5[0x9], md5[0xA], md5[0xB], md5[0xC], md5[0xD], md5[0xE], md5[0xF]));
|
||||||
@ -60,7 +69,7 @@ ROMInfo::ROMInfo(std::shared_ptr<CoreController> controller, QWidget* parent)
|
|||||||
m_ui.md5->setText(tr("(unknown)"));
|
m_ui.md5->setText(tr("(unknown)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(sha1, &(const uint8_t[20]) {}, 20) != 0) {
|
if (!isZeroed<20>(sha1)) {
|
||||||
m_ui.sha1->setText(QString::asprintf("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
m_ui.sha1->setText(QString::asprintf("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
||||||
sha1[ 0], sha1[ 1], sha1[ 2], sha1[ 3], sha1[ 4], sha1[ 5], sha1[ 6], sha1[ 7], sha1[ 8], sha1[ 9],
|
sha1[ 0], sha1[ 1], sha1[ 2], sha1[ 3], sha1[ 4], sha1[ 5], sha1[ 6], sha1[ 7], sha1[ 8], sha1[ 9],
|
||||||
sha1[10], sha1[11], sha1[12], sha1[13], sha1[14], sha1[15], sha1[16], sha1[17], sha1[18], sha1[19]));
|
sha1[10], sha1[11], sha1[12], sha1[13], sha1[14], sha1[15], sha1[16], sha1[17], sha1[18], sha1[19]));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user