Skip to content

Commit 7e8902a

Browse files
committed
fix warnings in arm7 readUserSettings
1 parent f2bb1f1 commit 7e8902a

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

source/arm7/userSettings.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,41 +30,40 @@
3030
void readUserSettings() {
3131
//---------------------------------------------------------------------------------
3232

33-
PERSONAL_DATA slot1;
34-
PERSONAL_DATA slot2;
33+
PERSONAL_DATA slots[2];
3534

3635
short slot1count, slot2count;
3736
short slot1CRC, slot2CRC;
3837

3938
uint32 userSettingsBase;
4039
readFirmware( 0x20, &userSettingsBase,2);
41-
40+
4241
uint32 slot1Address = userSettingsBase * 8;
4342
uint32 slot2Address = userSettingsBase * 8 + 0x100;
44-
45-
readFirmware( slot1Address , &slot1, sizeof(PERSONAL_DATA));
46-
readFirmware( slot2Address , &slot2, sizeof(PERSONAL_DATA));
43+
44+
readFirmware( slot1Address , &slots[0], sizeof(PERSONAL_DATA));
45+
readFirmware( slot2Address , &slots[1], sizeof(PERSONAL_DATA));
4746
readFirmware( slot1Address + 0x70, &slot1count, 2);
4847
readFirmware( slot2Address + 0x70, &slot2count, 2);
4948
readFirmware( slot1Address + 0x72, &slot1CRC, 2);
5049
readFirmware( slot2Address + 0x72, &slot2CRC, 2);
5150

5251
// default to slot 1 user Settings
53-
void *currentSettings = &slot1;
54-
55-
short calc1CRC = swiCRC16( 0xffff, &slot1, sizeof(PERSONAL_DATA));
56-
short calc2CRC = swiCRC16( 0xffff, &slot2, sizeof(PERSONAL_DATA));
52+
int currentSettingsSlot = 0;
53+
54+
short calc1CRC = swiCRC16( 0xffff, &slots[0], sizeof(PERSONAL_DATA));
55+
short calc2CRC = swiCRC16( 0xffff, &slots[1], sizeof(PERSONAL_DATA));
5756

5857
// bail out if neither slot is valid
5958
if ( calc1CRC != slot1CRC && calc2CRC != slot2CRC) return;
60-
59+
6160
// if both slots are valid pick the most recent
62-
if ( calc1CRC == slot1CRC && calc2CRC == slot2CRC ) {
63-
currentSettings = (slot2count == (( slot1count + 1 ) & 0x7f) ? &slot2 : &slot1);
61+
if ( calc1CRC == slot1CRC && calc2CRC == slot2CRC ) {
62+
currentSettingsSlot = (slot2count == (( slot1count + 1 ) & 0x7f) ? 1 : 0);
6463
} else {
6564
if ( calc2CRC == slot2CRC )
66-
currentSettings = &slot2;
65+
currentSettingsSlot = 1;
6766
}
68-
memcpy ( PersonalData, currentSettings, sizeof(PERSONAL_DATA));
69-
67+
*PersonalData = slots[currentSettingsSlot];
68+
7069
}

0 commit comments

Comments
 (0)