nxstyle fixes for PR 170

This commit is contained in:
Gregory Nutt
2020-04-11 12:56:24 -06:00
committed by Abdelatif Guettouche
parent 05f2253a33
commit 3e73991857
15 changed files with 285 additions and 173 deletions

View File

@@ -57,16 +57,21 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* The default is to use the RAM MTD device at drivers/mtd/rammtd.c. But
* an architecture-specific MTD driver can be used instead by defining
* CONFIG_EXAMPLES_CONFIGDATA_ARCHINIT. In this case, the initialization logic
* will call configdata_archinitialize() to obtain the MTD driver instance.
* CONFIG_EXAMPLES_CONFIGDATA_ARCHINIT. In this case, the initialization
* logic will call configdata_archinitialize() to obtain the MTD driver
* instance.
*/
#ifndef CONFIG_EXAMPLES_CONFIGDATA_ARCHINIT
/* This must exactly match the default configuration in drivers/mtd/rammtd.c */
/* This must exactly match the default configuration in
* drivers/mtd/rammtd.c
*/
# ifndef CONFIG_RAMMTD_ERASESIZE
# define CONFIG_RAMMTD_ERASESIZE 4096
@@ -119,19 +124,24 @@ struct configdata_entrydesc_s
/****************************************************************************
* Private Data
****************************************************************************/
/* Pre-allocated simulated flash */
#ifndef CONFIG_EXAMPLES_CONFIGDATA_ARCHINIT
static uint8_t g_simflash[EXAMPLES_CONFIGDATA_BUFSIZE<<1];
static uint8_t g_simflash[EXAMPLES_CONFIGDATA_BUFSIZE << 1];
#endif
static uint8_t g_entryimage[CONFIG_EXAMPLES_CONFIGDATA_MAXSIZE];
static struct configdata_entrydesc_s g_entries[CONFIG_EXAMPLES_CONFIGDATA_MAXENTRIES];
static struct configdata_entrydesc_s
g_entries[CONFIG_EXAMPLES_CONFIGDATA_MAXENTRIES];
static int g_nentries;
static int g_ndeleted;
static int g_fd;
static int g_ntests, g_nverified;
static int g_ntotalalloc, g_ntotaldelete;
static int g_ntests;
static int g_nverified;
static int g_ntotalalloc;
static int g_ntotaldelete;
static struct mallinfo g_mmbefore;
static struct mallinfo g_mmafter;
@@ -216,7 +226,7 @@ static inline uint16_t configdata_randid(void)
int value;
retry:
value = rand() & 0x7FFF;
value = rand() & 0x7fff;
if (value == 0)
{
value = 100;
@@ -275,7 +285,8 @@ static void configdata_freeentry(FAR struct configdata_entrydesc_s *entry)
* Name: configdata_wrentry
****************************************************************************/
static inline int configdata_wrentry(FAR struct configdata_entrydesc_s *entry)
static inline int
configdata_wrentry(FAR struct configdata_entrydesc_s *entry)
{
size_t x;
int ret;
@@ -291,7 +302,7 @@ static inline int configdata_wrentry(FAR struct configdata_entrydesc_s *entry)
for (x = 0; x < entry->len; x++)
{
g_entryimage[x] = rand() & 0xFF;
g_entryimage[x] = rand() & 0xff;
}
/* Calculate the crc32 for the data */
@@ -357,7 +368,8 @@ static int configdata_fillconfig(void)
* Name: configdata_rdentry
****************************************************************************/
static inline int configdata_rdentry(FAR struct configdata_entrydesc_s *entry)
static inline int
configdata_rdentry(FAR struct configdata_entrydesc_s *entry)
{
struct config_data_s config;
uint32_t crc;
@@ -435,7 +447,9 @@ static int configdata_verifyconfig(void)
}
else
{
/* Check if this entry has been deleted and should report an error */
/* Check if this entry has been deleted and should report an
* error.
*/
if (entry->deleted)
{
@@ -448,7 +462,8 @@ static int configdata_verifyconfig(void)
{
g_nverified++;
#if CONFIG_EXAMPLES_CONFIGDATA_VERBOSE != 0
printf(" Verifed entry %04X, %d\n", entry->id, entry->instance);
printf(" Verifed entry %04X, %d\n",
entry->id, entry->instance);
#endif
}
}
@@ -493,7 +508,7 @@ static int configdata_delentries(void)
/* And delete the next undeleted file after that random index */
for (j = ndx + 1; j != ndx;)
for (j = ndx + 1; j != ndx; )
{
entry = &g_entries[j];
if (entry->id && !entry->deleted)
@@ -504,7 +519,7 @@ static int configdata_delentries(void)
ret = ioctl(g_fd, CFGDIOC_SETCONFIG, (unsigned long) &hdr);
if (ret < 0)
{
printf("ERROR: Delete %d failed: %d\n", i+1, errno);
printf("ERROR: Delete %d failed: %d\n", i + 1, errno);
printf(" Entry id: %04X\n", entry->id);
printf(" Entry size: %d\n", entry->len);
printf(" Entry index: %d\n", j);
@@ -569,7 +584,9 @@ static void configdata_cleardeleted(void)
{
/* Find next non-deleted entry after the deleted one */
for (x = nextdeleted + 1; x < CONFIG_EXAMPLES_CONFIGDATA_MAXENTRIES; x++)
for (x = nextdeleted + 1;
x < CONFIG_EXAMPLES_CONFIGDATA_MAXENTRIES;
x++)
{
if (g_entries[x].id && !g_entries[x].deleted)
{
@@ -594,6 +611,7 @@ static void configdata_cleardeleted(void)
else
{
/* Just remove the entry */
g_entries[nextdeleted].id = 0;
g_entries[nextdeleted].deleted = FALSE;
}
@@ -683,9 +701,9 @@ int main(int argc, FAR char *argv[])
for (i = 1; i <= CONFIG_EXAMPLES_CONFIGDATA_NLOOPS; i++)
#endif
{
/* Write config data to the /dev/config device until either (1) all of the
* open file structures are utilized or until (2) CONFIGDATA reports an error
* (hopefully that the /dev/config device is full)
/* Write config data to the /dev/config device until either (1) all of
* the open file structures are utilized or until (2) CONFIGDATA
* reports an error (hopefully that the /dev/config device is full)
*/
#ifndef CONFIG_EXAMPLES_CONFIGDATA_SILENT
@@ -774,9 +792,12 @@ int main(int argc, FAR char *argv[])
#endif
}
#if 0
/* Delete all files then show memory usage again */
//configdata_delallfiles();
configdata_delallfiles();
#endif
configdata_endmemusage();
fflush(stdout);
return 0;