ps2homebrew / hdl-dump

Install games in HDLoader format to APA-formatted hard drive
122 stars 25 forks source link

COMPAT_FLAGS_INVALID is a valid value, makes all usage of it bugs. #29

Open bignaux opened 3 years ago

bignaux commented 3 years ago

Example :

hdl_dump modify /dev/sdb Netflix +1+2+3+4+5+6+7+8
=> CD  1250944KB   1+2+3+4+5+6+7 *u4 SLUS21949    +1+2+3+4+5+6+7+8

The issue is that compat_flags_t is a uchar, and with 8 modes, all bits are useful, so we can't rely on an invalid value.

if (new_flags == COMPAT_FLAGS_INVALID)

typedef unsigned char compat_flags_t;
static const compat_flags_t COMPAT_FLAGS_INVALID = (compat_flags_t)-1;

I'm not interesting to fix that now since mode are not useful for me (using OPL), and that's used everywhere (big impact and work for no use). But i can write a bug reminder near declaration of COMPAT_FLAGS_INVALID. If we use a bigger type int to keep the invalid value mecanism, we break for example the hdl_hdr mapping...