1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-05 07:24:34 +00:00

Fix compiler warnings in z_camera/db_camera (#947)

* Fix compiler warnings in z_camera/db_camera

* review

Co-authored-by: zelda2774 <zelda2774@invalid>
This commit is contained in:
zelda2774 2021-09-07 18:13:52 +02:00 committed by GitHub
parent 3d57eaf019
commit c577ed1e84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 23 deletions

View file

@ -7020,10 +7020,19 @@ void Camera_PrintSettings(Camera* camera) {
if (camera->camDataIdx < 0) {
sp50[i++] = '-';
}
if (camera->camDataIdx / 0xA != 0) {
sp50[i++] = i / 0xA + '0';
//! @bug: this code was clearly meaning to print `abs(camera->camDataIdx)` as a
//! one-or-two-digit number, instead of `i`.
// "sp50[i++] = ..." matches here, but is undefined behavior due to conflicting
// reads/writes between sequence points, triggering warnings. Work around by
// putting i++ afterwards while on the same line.
// clang-format off
if (camera->camDataIdx / 10 != 0) {
sp50[i] = i / 10 + '0'; i++;
}
sp50[i++] = i % 10 + '0';
sp50[i] = i % 10 + '0'; i++;
// clang-format on
sp50[i++] = ' ';
sp50[i++] = ' ';
sp50[i++] = ' ';