examples/romfs/romfs_main.c: Appease nxstyle

This commit is contained in:
YAMAMOTO Takashi 2020-11-14 08:53:18 +09:00 committed by Xiang Xiao
parent fa727e08f1
commit 473fef4e58

View File

@ -244,6 +244,7 @@ static struct node_s *findindirectory(struct node_s *entry, const char *name)
return entry; return entry;
} }
} }
return NULL; return NULL;
} }
@ -266,7 +267,8 @@ static void checkattributes(const char *path, mode_t mode, size_t size)
if (mode != buf.st_mode) if (mode != buf.st_mode)
{ {
printf(" -- ERROR: Expected mode %08x, got %08x\n", mode, buf.st_mode); printf(" -- ERROR: Expected mode %08x, got %08x\n", mode,
buf.st_mode);
g_nerrors++; g_nerrors++;
} }
@ -322,8 +324,9 @@ static void checkfile(const char *path, struct node_s *node)
/* Memory map and verify the file contents */ /* Memory map and verify the file contents */
filedata = (char*)mmap(NULL, node->size, PROT_READ, MAP_SHARED|MAP_FILE, fd, 0); filedata = (char *)mmap(NULL, node->size, PROT_READ, MAP_SHARED | MAP_FILE,
if (!filedata || filedata == (char*)MAP_FAILED) fd, 0);
if (!filedata || filedata == (char *)MAP_FAILED)
{ {
printf(" -- ERROR: mmap of %s failed: %d\n", path, errno); printf(" -- ERROR: mmap of %s failed: %d\n", path, errno);
g_nerrors++; g_nerrors++;
@ -334,11 +337,13 @@ static void checkfile(const char *path, struct node_s *node)
{ {
memcpy(g_scratchbuffer, filedata, node->size); memcpy(g_scratchbuffer, filedata, node->size);
g_scratchbuffer[node->size] = '\0'; g_scratchbuffer[node->size] = '\0';
printf(" -- ERROR: Mapped file content read does not match expectation:\n"); printf(" -- ERROR: Mapped file content read does not match "
"expectation:\n");
printf(" -- Memory: [%s]\n", filedata); printf(" -- Memory: [%s]\n", filedata);
printf(" -- Expected: [%s]\n", node->u.filecontent); printf(" -- Expected: [%s]\n", node->u.filecontent);
g_nerrors++; g_nerrors++;
} }
munmap(filedata, node->size); munmap(filedata, node->size);
} }
@ -373,7 +378,8 @@ static void readdirectories(const char *path, struct node_s *entry)
for (direntry = readdir(dirp); direntry; direntry = readdir(dirp)) for (direntry = readdir(dirp); direntry; direntry = readdir(dirp))
{ {
if (strcmp(direntry->d_name, ".") == 0 || strcmp(direntry->d_name, "..") == 0) if (strcmp(direntry->d_name, ".") == 0 ||
strcmp(direntry->d_name, "..") == 0)
{ {
printf(" Skipping %s\n", direntry->d_name); printf(" Skipping %s\n", direntry->d_name);
continue; continue;
@ -421,6 +427,7 @@ static void readdirectories(const char *path, struct node_s *entry)
checkfile(fullpath, node); checkfile(fullpath, node);
} }
} }
free(fullpath); free(fullpath);
} }
@ -435,7 +442,7 @@ static void checkdirectories(struct node_s *entry)
{ {
for (; entry; entry = entry->peer) for (; entry; entry = entry->peer)
{ {
if (!entry->found ) if (!entry->found)
{ {
printf("ERROR: %s never found\n", entry->name); printf("ERROR: %s never found\n", entry->name);
g_nerrors++; g_nerrors++;
@ -458,12 +465,13 @@ static void checkdirectories(struct node_s *entry)
int main(int argc, FAR char *argv[]) int main(int argc, FAR char *argv[])
{ {
int ret; int ret;
/* Create a RAM disk for the test */ /* Create a RAM disk for the test */
ret = romdisk_register(CONFIG_EXAMPLES_ROMFS_RAMDEVNO, testdir_img, ret = romdisk_register(CONFIG_EXAMPLES_ROMFS_RAMDEVNO, testdir_img,
NSECTORS(testdir_img_len), CONFIG_EXAMPLES_ROMFS_SECTORSIZE); NSECTORS(testdir_img_len),
CONFIG_EXAMPLES_ROMFS_SECTORSIZE);
if (ret < 0) if (ret < 0)
{ {
printf("ERROR: Failed to create RAM disk\n"); printf("ERROR: Failed to create RAM disk\n");
@ -475,7 +483,8 @@ int main(int argc, FAR char *argv[])
printf("Mounting ROMFS filesystem at target=%s with source=%s\n", printf("Mounting ROMFS filesystem at target=%s with source=%s\n",
CONFIG_EXAMPLES_ROMFS_MOUNTPOINT, MOUNT_DEVNAME); CONFIG_EXAMPLES_ROMFS_MOUNTPOINT, MOUNT_DEVNAME);
ret = mount(MOUNT_DEVNAME, CONFIG_EXAMPLES_ROMFS_MOUNTPOINT, "romfs", MS_RDONLY, NULL); ret = mount(MOUNT_DEVNAME, CONFIG_EXAMPLES_ROMFS_MOUNTPOINT, "romfs",
MS_RDONLY, NULL);
if (ret < 0) if (ret < 0)
{ {
printf("ERROR: Mount failed: %d\n", errno); printf("ERROR: Mount failed: %d\n", errno);