From: notaz Date: Sun, 28 Aug 2022 20:51:40 +0000 (+0300) Subject: misc: get rid of an unaligned read X-Git-Tag: r24l~421 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5bb56b1a0ec9c4875a4b9f532d79ee477a5a6e8e;p=pcsx_rearmed.git misc: get rid of an unaligned read 96c6ec7055ecef55b3dd221c86b796512bf52107 introduced an unaligned read which is undefined behavior in C, even if most hardware allows it (but some very old ARMs don't). Perf. doesn't matter here so read byte-by-byte. notaz/pcsx_rearmed#261 --- diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index f6fe19ad..854bbb85 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -56,10 +56,11 @@ struct iso_directory_record { char name [1]; }; -void mmssdd( char *b, char *p ) +static void mmssdd( char *b, char *p ) { int m, s, d; - int block = SWAP32(*((uint32_t*) b)); + unsigned char *ub = (void *)b; + int block = (ub[3] << 24) | (ub[2] << 16) | (ub[1] << 8) | ub[0]; block += 150; m = block / 4500; // minutes