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:
parent
3d57eaf019
commit
c577ed1e84
3 changed files with 32 additions and 23 deletions
|
@ -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++] = ' ';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue