diff --git a/VERSION b/VERSION index 488061bf..555d564a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-66-g0aa8711796+1 \ No newline at end of file +B1-67-g1ef406bbaf+1 \ No newline at end of file diff --git a/common/include/common/ivshmem.h b/common/include/common/ivshmem.h index fe63f74d..73052da4 100644 --- a/common/include/common/ivshmem.h +++ b/common/include/common/ivshmem.h @@ -32,4 +32,5 @@ struct IVSHMEM void ivshmemOptionsInit(); bool ivshmemOpen(struct IVSHMEM * dev); +bool ivshmemOpenDev(struct IVSHMEM * dev, const char * shmDev); void ivshmemClose(struct IVSHMEM * dev); \ No newline at end of file diff --git a/common/include/common/stringutils.h b/common/include/common/stringutils.h index 50fabd11..48274569 100644 --- a/common/include/common/stringutils.h +++ b/common/include/common/stringutils.h @@ -18,4 +18,5 @@ Place, Suite 330, Boston, MA 02111-1307 USA */ // sprintf but with buffer allocation -int alloc_sprintf(char ** str, const char * format, ...); \ No newline at end of file +int alloc_sprintf(char ** str, const char * format, ...) + __attribute__ ((format (printf, 2, 3))); \ No newline at end of file diff --git a/common/src/option.c b/common/src/option.c index 5a9fc6fb..0121198d 100644 --- a/common/src/option.c +++ b/common/src/option.c @@ -600,7 +600,7 @@ void option_print() maxLen = alloc_sprintf( &line, "%-*s | Short | %-*s | Description", - strlen(state.groups[g].module) + state.groups[g].pad + 1, + (int)(strlen(state.groups[g].module) + state.groups[g].pad + 1), "Long", valueLen, "Value" diff --git a/common/src/platform/linux/CMakeLists.txt b/common/src/platform/linux/CMakeLists.txt index c0d2ec84..8e193a2d 100644 --- a/common/src/platform/linux/CMakeLists.txt +++ b/common/src/platform/linux/CMakeLists.txt @@ -17,4 +17,7 @@ if(ENABLE_BACKTRACE) target_link_libraries(lg_common_platform_code bfd) endif() -target_link_libraries(lg_common_platform_code pthread) +target_link_libraries(lg_common_platform_code + lg_common + pthread +) diff --git a/common/src/platform/linux/ivshmem.c b/common/src/platform/linux/ivshmem.c index d37fc37e..40c26745 100644 --- a/common/src/platform/linux/ivshmem.c +++ b/common/src/platform/linux/ivshmem.c @@ -42,7 +42,6 @@ static int uioOpenFile(const char * shmDevice, const char * file) { char * path; alloc_sprintf(&path, "/sys/class/uio/%s/%s", shmDevice, file); - int fd = open(path, O_RDONLY); if (fd < 0) { @@ -161,10 +160,14 @@ void ivshmemOptionsInit() } bool ivshmemOpen(struct IVSHMEM * dev) +{ + return ivshmemOpenDev(dev, option_get_string("app", "shmFile")); +} + +bool ivshmemOpenDev(struct IVSHMEM * dev, const char * shmDevice) { assert(dev); - const char * shmDevice = option_get_string("app", "shmFile"); unsigned int devSize; int devFD; @@ -257,5 +260,7 @@ void ivshmemClose(struct IVSHMEM * dev) close(info->fd); free(info); + dev->mem = NULL; + dev->size = 0; dev->opaque = NULL; } \ No newline at end of file diff --git a/common/src/platform/windows/CMakeLists.txt b/common/src/platform/windows/CMakeLists.txt index a799944d..7d3d8ab2 100644 --- a/common/src/platform/windows/CMakeLists.txt +++ b/common/src/platform/windows/CMakeLists.txt @@ -15,5 +15,6 @@ add_library(lg_common_platform_code STATIC ) target_link_libraries(lg_common_platform_code + lg_common setupapi ) diff --git a/common/src/stringutils.c b/common/src/stringutils.c index e35a2353..9f21f123 100644 --- a/common/src/stringutils.c +++ b/common/src/stringutils.c @@ -21,26 +21,24 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include -int alloc_sprintf(char ** str, const char * format, ...) +static int valloc_sprintf(char ** str, const char * format, va_list ap) { if (!str) return -1; *str = NULL; - va_list ap; - va_start(ap, format); - int len = vsnprintf(NULL, 0, format, ap); - va_end(ap); + + va_list ap1; + va_copy(ap1, ap); + int len = vsnprintf(NULL, 0, format, ap1); + va_end(ap1); if (len < 0) return len; *str = malloc(len+1); - va_start(ap, format); int ret = vsnprintf(*str, len + 1, format, ap); - va_end(ap); - if (ret < 0) { free(*str); @@ -48,5 +46,14 @@ int alloc_sprintf(char ** str, const char * format, ...) return ret; } + return ret; +} + +int alloc_sprintf(char ** str, const char * format, ...) +{ + va_list ap; + va_start(ap, format); + int ret = valloc_sprintf(str, format, ap); + va_end(ap); return ret; } \ No newline at end of file