Skip to content

Commit

Permalink
Merge #806: refactor: Misc int sign change fixes
Browse files Browse the repository at this point in the history
0541642 refactor: Avoid implicit-integer-sign-change in processNewTransaction (MarcoFalke)
321f105 refactor: Avoid implicit-signed-integer-truncation-or-sign-change in FreedesktopImage (MarcoFalke)
6d8eecd refactor: Avoid implicit-integer-sign-change in createTransaction (MarcoFalke)

Pull request description:

  This is allowed by the language. However, the `integer` sanitizer complains about it. Thus, fix it, so that the `integer` sanitizer can be used in the future to catch unintended sign changes.

  Fixes #805.

ACKs for top commit:
  pablomartin4btc:
    tACK 0541642
  hebasto:
    ACK 0541642, I have reviewed the code and it looks OK.

Tree-SHA512: eaa941479bd7bee196eb8b31d93b8e1db122410cf62e8ec4cbbec35cfd14cc766081c3df5dd14a228e21ad2678d8b8ba0d2649e5934c994a90ae96d8b264b4ce
  • Loading branch information
hebasto committed Apr 18, 2024
2 parents dbd2000 + 0541642 commit aaab5fb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/qt/notificator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ FreedesktopImage::FreedesktopImage(const QImage &img):

for(unsigned int ptr = 0; ptr < num_pixels; ++ptr)
{
image[ptr*BYTES_PER_PIXEL+0] = data[ptr] >> 16; // R
image[ptr*BYTES_PER_PIXEL+1] = data[ptr] >> 8; // G
image[ptr*BYTES_PER_PIXEL+2] = data[ptr]; // B
image[ptr*BYTES_PER_PIXEL+3] = data[ptr] >> 24; // A
image[ptr * BYTES_PER_PIXEL + 0] = char(data[ptr] >> 16); // R
image[ptr * BYTES_PER_PIXEL + 1] = char(data[ptr] >> 8); // G
image[ptr * BYTES_PER_PIXEL + 2] = char(data[ptr]); // B
image[ptr * BYTES_PER_PIXEL + 3] = char(data[ptr] >> 24); // A
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/qt/walletview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void WalletView::processNewTransaction(const QModelIndex& parent, int start, int
return;

QString date = ttm->index(start, TransactionTableModel::Date, parent).data().toString();
qint64 amount = ttm->index(start, TransactionTableModel::Amount, parent).data(Qt::EditRole).toULongLong();
qint64 amount = ttm->index(start, TransactionTableModel::Amount, parent).data(Qt::EditRole).toLongLong();
QString type = ttm->index(start, TransactionTableModel::Type, parent).data().toString();
QModelIndex index = ttm->index(start, 0, parent);
QString address = ttm->data(index, TransactionTableModel::AddressRole).toString();
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class WalletImpl : public Wallet
if (!res) return util::Error{util::ErrorString(res)};
const auto& txr = *res;
fee = txr.fee;
change_pos = txr.change_pos ? *txr.change_pos : -1;
change_pos = txr.change_pos ? int(*txr.change_pos) : -1;

return txr.tx;
}
Expand Down

0 comments on commit aaab5fb

Please sign in to comment.