summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-08-12 07:22:38 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-08-12 07:22:38 +0000
commit7cb80a2a70d7816ecc64444b47af1ba74190d7e2 (patch)
tree4e4bec0f6f381f6dfcf3a8b214ee17675074596a /apps
parentbcf97a480115aa653af9e0eb5c012fc3673bc00f (diff)
downloadrockbox-7cb80a2a70d7816ecc64444b47af1ba74190d7e2.zip
rockbox-7cb80a2a70d7816ecc64444b47af1ba74190d7e2.tar.gz
rockbox-7cb80a2a70d7816ecc64444b47af1ba74190d7e2.tar.bz2
rockbox-7cb80a2a70d7816ecc64444b47af1ba74190d7e2.tar.xz
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
Diffstat (limited to 'apps')
-rw-r--r--apps/filetypes.c2
-rw-r--r--apps/settings.c15
-rw-r--r--apps/settings_list.h2
3 files changed, 13 insertions, 6 deletions
diff --git a/apps/filetypes.c b/apps/filetypes.c
index 1e7224a..090898a 100644
--- a/apps/filetypes.c
+++ b/apps/filetypes.c
@@ -241,7 +241,7 @@ void filetype_init(void)
#ifdef HAVE_LCD_COLOR
/* the extra item here is for the unknown types
which use the last array element */
- custom_colors = (int*)buffer_alloc(sizeof(int)*max_types+1);
+ custom_colors = (int*)buffer_alloc(sizeof(int)*(max_types+1));
#endif
/* set the directory item first */
filetypes[0].extension = NULL;
diff --git a/apps/settings.c b/apps/settings.c
index 8b82606..f2bb542 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -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;
diff --git a/apps/settings_list.h b/apps/settings_list.h
index 9bc8eb9..2034d85 100644
--- a/apps/settings_list.h
+++ b/apps/settings_list.h
@@ -96,7 +96,7 @@ struct choice_setting {
#define F_NVRAM_BYTES_MASK 0xE000 /*0-4 bytes can be stored */
#define F_NVRAM_MASK_SHIFT 13
-#define NVRAM_CONFIG_VERSION 2
+#define NVRAM_CONFIG_VERSION 3
/* Above define should be bumped if
- a new NVRAM setting is added between 2 other NVRAM settings
- number of bytes for a NVRAM setting is changed