1
0
Fork 0
forked from len0rd/rockbox

Fix a problem with the nvram settings which meant adding new items to the end needed the version bump (they dont anymore, but I'm bumping it now anyway to save some bug reports)

Also operator precedence fixing.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14290 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2007-08-12 07:22:38 +00:00
parent bcf97a4801
commit 7cb80a2a70
3 changed files with 13 additions and 6 deletions

View file

@ -143,15 +143,22 @@ static bool read_nvram_data(char* buf, int max_len)
/* all good, so read in the settings */
var_count = buf[3];
buf_pos = NVRAM_DATA_START;
for(i=0; (i<nb_settings) && (var_count>0) && (buf_pos<max_len); i++)
for(i=0; i<nb_settings; i++)
{
int nvram_bytes = (settings[i].flags&F_NVRAM_BYTES_MASK)
>>F_NVRAM_MASK_SHIFT;
if (nvram_bytes)
{
memcpy(settings[i].setting,&buf[buf_pos],nvram_bytes);
buf_pos += nvram_bytes;
var_count--;
if ((var_count>0) && (buf_pos<max_len))
{
memcpy(settings[i].setting,&buf[buf_pos],nvram_bytes);
buf_pos += nvram_bytes;
var_count--;
}
else /* should only happen when new items are added to the end */
{
memcpy(settings[i].setting, &settings[i].default_val, nvram_bytes);
}
}
}
return true;