mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Make use of (now supported) standard snprintf in stdarg-printf when used in logfs
This commit is contained in:
parent
320bbcf434
commit
adfbdfae38
@ -30,30 +30,17 @@
|
|||||||
#include <openpilot.h>
|
#include <openpilot.h>
|
||||||
|
|
||||||
#if defined(PIOS_INCLUDE_FREERTOS)
|
#if defined(PIOS_INCLUDE_FREERTOS)
|
||||||
static xSemaphoreHandle mutex;
|
static xSemaphoreHandle mutex = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct flashfs_logfs_cfg;
|
struct flashfs_logfs_cfg;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper for the unimplemented sprintf function
|
|
||||||
* warning, no buffer length boundary checks, use with caution!
|
|
||||||
*/
|
|
||||||
static void customSPrintf(uint8_t *buffer, uint8_t *format, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
va_start(args, format);
|
|
||||||
vsprintf((char *)buffer, (char *)format, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an 8 character (plus extension) filename for the object.
|
* Get an 8 character (plus extension) filename for the object.
|
||||||
* @param[in] obj The object handle.
|
* @param[in] obj The object handle.
|
||||||
* @param[in] instId The instance ID
|
* @param[in] instId The instance ID
|
||||||
* @param[in] file Filename string pointer WARNING, must be 14 bytes long and allocated, no checks!
|
* @param[in] file Filename string pointer -- must be 14 bytes long and allocated
|
||||||
*/
|
*/
|
||||||
static void objectFilename(uint32_t obj_id, uint16_t obj_inst_id, uint8_t *filename)
|
static void objectFilename(uint32_t obj_id, uint16_t obj_inst_id, uint8_t *filename)
|
||||||
{
|
{
|
||||||
@ -61,7 +48,7 @@ static void objectFilename(uint32_t obj_id, uint16_t obj_inst_id, uint8_t *filen
|
|||||||
// skip least sig nibble since that is used for meta object id
|
// skip least sig nibble since that is used for meta object id
|
||||||
uint8_t suffix = obj_inst_id & 0xff;
|
uint8_t suffix = obj_inst_id & 0xff;
|
||||||
|
|
||||||
customSPrintf(filename, (uint8_t *)"%08X.o%02X", prefix, suffix);
|
snprintf((char *)filename, 13, "%08X.o%02X", prefix, suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,30 +30,17 @@
|
|||||||
#include <openpilot.h>
|
#include <openpilot.h>
|
||||||
|
|
||||||
#if defined(PIOS_INCLUDE_FREERTOS)
|
#if defined(PIOS_INCLUDE_FREERTOS)
|
||||||
static xSemaphoreHandle mutex;
|
static xSemaphoreHandle mutex = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct flashfs_logfs_cfg;
|
struct flashfs_logfs_cfg;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper for the unimplemented sprintf function
|
|
||||||
* warning, no buffer length boundary checks, use with caution!
|
|
||||||
*/
|
|
||||||
static void customSPrintf(uint8_t *buffer, uint8_t *format, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
va_start(args, format);
|
|
||||||
vsprintf((char *)buffer, (char *)format, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an 8 character (plus extension) filename for the object.
|
* Get an 8 character (plus extension) filename for the object.
|
||||||
* @param[in] obj The object handle.
|
* @param[in] obj The object handle.
|
||||||
* @param[in] instId The instance ID
|
* @param[in] instId The instance ID
|
||||||
* @param[in] file Filename string pointer WARNING, must be 14 bytes long and allocated, no checks!
|
* @param[in] file Filename string pointer -- must be 14 bytes long and allocated
|
||||||
*/
|
*/
|
||||||
static void objectFilename(uint32_t obj_id, uint16_t obj_inst_id, uint8_t *filename)
|
static void objectFilename(uint32_t obj_id, uint16_t obj_inst_id, uint8_t *filename)
|
||||||
{
|
{
|
||||||
@ -61,7 +48,7 @@ static void objectFilename(uint32_t obj_id, uint16_t obj_inst_id, uint8_t *filen
|
|||||||
// skip least sig nibble since that is used for meta object id
|
// skip least sig nibble since that is used for meta object id
|
||||||
uint8_t suffix = obj_inst_id & 0xff;
|
uint8_t suffix = obj_inst_id & 0xff;
|
||||||
|
|
||||||
customSPrintf(filename, (uint8_t *)"%08X.o%02X", prefix, suffix);
|
snprintf((char *)filename, 13, "%08X.o%02X", prefix, suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user