From f3d60aea34de60c4371c04fa1b8482ca71a64b53 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Fri, 29 Aug 2014 23:36:11 -0400 Subject: [PATCH] Hopefully fix most of the errors and warnings from the last push Change-Id: I1a466b2d55f120796910039a0296ca324c58e891 --- bootloader/iaudio_coldfire.c | 1 + firmware/common/file_internal.c | 3 ++- firmware/common/unicode.c | 28 ++++++++++++++++++---- firmware/export/config.h | 1 + firmware/include/string-extra.h | 3 ++- firmware/storage.c | 2 +- firmware/target/hosted/filesystem-app.c | 4 ++-- firmware/target/hosted/filesystem-hosted.h | 1 + 8 files changed, 33 insertions(+), 10 deletions(-) diff --git a/bootloader/iaudio_coldfire.c b/bootloader/iaudio_coldfire.c index 2f31958a87..953e649b9a 100644 --- a/bootloader/iaudio_coldfire.c +++ b/bootloader/iaudio_coldfire.c @@ -40,6 +40,7 @@ #include "panic.h" #include "power.h" #include "powermgmt.h" +#include "file_internal.h" #include "file.h" #include "version.h" #include "loader_strerror.h" diff --git a/firmware/common/file_internal.c b/firmware/common/file_internal.c index ebe77f0c9f..e5b43cd19d 100644 --- a/firmware/common/file_internal.c +++ b/firmware/common/file_internal.c @@ -36,7 +36,8 @@ /* for internal functions' scanning use to save quite a bit of stack space - access must be serialized by the writer lock */ -#if defined(CPU_SH) || defined(IAUDIO_M5) +#if defined(CPU_SH) || defined(IAUDIO_M5) \ + || CONFIG_CPU == IMX233 /* otherwise, out of IRAM */ struct fat_direntry dir_fatent; #else diff --git a/firmware/common/unicode.c b/firmware/common/unicode.c index 954ad47e1d..8988686b70 100644 --- a/firmware/common/unicode.c +++ b/firmware/common/unicode.c @@ -54,6 +54,7 @@ #else /* APPLICATION */ #ifdef __PCTOOL__ #define yield() +#define DEFAULT_CP_STATIC_ALLOC #endif #define open_noiso_internal open #endif /* !APPLICATION */ @@ -182,6 +183,23 @@ const char *get_current_codepage_name_linux(void) } #endif /* defined(APPLICATION) && defined(__linux__) */ +#ifdef DEFAULT_CP_STATIC_ALLOC +static unsigned short default_cp_table_buf[MAX_CP_TABLE_SIZE+1]; +#define cp_table_get_data(handle) \ + default_cp_table_buf +#define cp_table_free(handle) \ + do {} while (0) +#define cp_table_alloc(filename, size, opsp) \ + ({ (void)(opsp); 1; }) +#else +#define cp_table_alloc(filename, size, opsp) \ + core_alloc_ex((filename), (size), (opsp)) +#define cp_table_free(handle) \ + core_free(handle) +#define cp_table_get_data(handle) \ + core_get_data(handle) +#endif + static const unsigned char utf8comp[6] = { 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC @@ -233,9 +251,9 @@ static int alloc_and_load_cp_table(int cp, void *buf) !(size % (off_t)sizeof (uint16_t))) { /* if the buffer is provided, use that but don't alloc */ - int handle = buf ? 0 : core_alloc_ex(filename, size, &ops); + int handle = buf ? 0 : cp_table_alloc(filename, size, &ops); if (handle > 0) - buf = core_get_data(handle); + buf = cp_table_get_data(handle); if (buf && read(fd, buf, size) == size) { close(fd); @@ -244,7 +262,7 @@ static int alloc_and_load_cp_table(int cp, void *buf) } if (handle > 0) - core_free(handle); + cp_table_free(handle); } close(fd); @@ -284,7 +302,7 @@ unsigned char* iso_decode(const unsigned char *iso, unsigned char *utf8, if (tid == default_cp_tid) { /* use default table */ if (default_cp_handle > 0) { - table = core_get_data(default_cp_handle); + table = cp_table_get_data(default_cp_handle); default_cp_table_ref++; } @@ -564,7 +582,7 @@ void set_codepage(int cp) cp_lock_leave(); if (handle > 0) - core_free(handle); + cp_table_free(handle); } int get_codepage(void) diff --git a/firmware/export/config.h b/firmware/export/config.h index 2a1cdb3416..b1ee101fe6 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -584,6 +584,7 @@ Lyre prototype 1 */ #define CONFIG_CPU 0 #undef HAVE_MULTIVOLUME #undef HAVE_MULTIDRIVE +#undef CONFIG_STORAGE #endif #ifdef APPLICATION diff --git a/firmware/include/string-extra.h b/firmware/include/string-extra.h index 9ab53d8154..549a018dfc 100644 --- a/firmware/include/string-extra.h +++ b/firmware/include/string-extra.h @@ -28,7 +28,8 @@ #include "strtok_r.h" #include "memset16.h" -#if defined(WIN32) || defined(APPLICATION) +#if defined(WIN32) || defined(APPLICATION) \ + || defined(__PCTOOL__) #ifndef mempcpy #define mempcpy __builtin_mempcpy #endif diff --git a/firmware/storage.c b/firmware/storage.c index 7ef7428854..e0b491a5f9 100644 --- a/firmware/storage.c +++ b/firmware/storage.c @@ -192,7 +192,7 @@ int storage_num_drives(void) int storage_driver_type(int drive) { - if (drive >= num_drives) + if ((unsigned int)drive >= num_drives) return -1; unsigned int bit = (storage_drivers[drive] & DRIVER_MASK)>>DRIVER_OFFSET; diff --git a/firmware/target/hosted/filesystem-app.c b/firmware/target/hosted/filesystem-app.c index 7ef8d3109b..a4730a07d9 100644 --- a/firmware/target/hosted/filesystem-app.c +++ b/firmware/target/hosted/filesystem-app.c @@ -69,7 +69,7 @@ static const char *handle_special_links(const char* link, unsigned flags, { (void) flags; char vol_string[VOL_MAX_LEN + 1]; - get_volume_name(-1, vol_string); + int len = get_volume_name(-1, vol_string); /* link might be passed with or without HOME_DIR expanded. To handle * both perform substring matching (VOL_NAMES is unique enough) */ @@ -354,7 +354,7 @@ DIR * app_opendir(const char *dirname) #ifdef HAVE_MULTIDRIVE this->volumes_returned = INT_MAX; /* assume NOT $HOME */ - if (rbhome_fildes >= 0 && os_samefile(rbhome_fildes, fd) > 0) + if (rbhome_fildes >= 0 && os_fsamefile(rbhome_fildes, this->osfd) > 0) this->volumes_returned = 0; /* there's no place like $HOME */ #endif /* HAVE_MULTIDRIVE */ diff --git a/firmware/target/hosted/filesystem-hosted.h b/firmware/target/hosted/filesystem-hosted.h index 3d979eb19d..5147ef6db6 100644 --- a/firmware/target/hosted/filesystem-hosted.h +++ b/firmware/target/hosted/filesystem-hosted.h @@ -63,6 +63,7 @@ bool os_file_exists(const char *ospath); #define _FILESYSTEM_HOSTED__DIR_H_ #ifndef OSFUNCTIONS_DECLARED +int os_opendirfd(const char *osdirname); int os_opendir_and_fd(const char *osdirname, OS_DIR_T **osdirpp, int *osfdp);