binfmt/: More spacing/alignment fixes

This commit is contained in:
Gregory Nutt 2015-10-08 19:20:17 -06:00
parent fcb55102f9
commit 45eebacbb4
21 changed files with 61 additions and 54 deletions

View file

@ -159,7 +159,7 @@ int exec_module(FAR const struct binary_s *binp)
/* Allocate a TCB for the new task. */
tcb = (FAR struct task_tcb_s*)kmm_zalloc(sizeof(struct task_tcb_s));
tcb = (FAR struct task_tcb_s *)kmm_zalloc(sizeof(struct task_tcb_s));
if (!tcb)
{
err = ENOMEM;
@ -189,7 +189,7 @@ int exec_module(FAR const struct binary_s *binp)
* will need to change if/when we want to support dynamic stack allocation.
*/
stack = (FAR uint32_t*)kumm_malloc(binp->stacksize);
stack = (FAR uint32_t *)kumm_malloc(binp->stacksize);
if (!stack)
{
err = ENOMEM;

View file

@ -190,7 +190,7 @@ FAR char *exepath_next(EXEPATH_HANDLE handle, FAR const char *relpath)
* in the PATH variable have been considered.
*/
for (;;)
for (; ; )
{
/* Make sure that exepath->next points to the beginning of a string */
@ -244,7 +244,7 @@ FAR char *exepath_next(EXEPATH_HANDLE handle, FAR const char *relpath)
/* Verify that a regular file exists at this path */
ret = stat(fullpath, &buf);;
ret = stat(fullpath, &buf);
if (ret == OK && S_ISREG(buf.st_mode))
{
return fullpath;

View file

@ -84,7 +84,7 @@ FAR struct binary_s *g_unloadhead;
* pid - The task ID of the child task
* bin - This structure must have been allocated with kmm_malloc() and must
* persist until the task unloads
*
*
* Returned Value:
* None

View file

@ -198,7 +198,7 @@ static void elf_dumpentrypt(FAR struct binary_s *binp,
}
#endif
elf_dumpbuffer("Entry code", (FAR const uint8_t*)binp->entrypt,
elf_dumpbuffer("Entry code", (FAR const uint8_t *)binp->entrypt,
MIN(loadinfo->textsize - loadinfo->ehdr.e_entry, 512));
#ifdef CONFIG_ARCH_ADDRENV

View file

@ -113,7 +113,7 @@ static inline int elf_readrel(FAR struct elf_loadinfo_s *loadinfo,
/* And, finally, read the symbol table entry into memory */
return elf_read(loadinfo, (FAR uint8_t*)rel, sizeof(Elf32_Rel), offset);
return elf_read(loadinfo, (FAR uint8_t *)rel, sizeof(Elf32_Rel), offset);
}
/****************************************************************************

View file

@ -163,7 +163,7 @@ int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
{
/* Allocate memory to hold a copy of the .ctor section */
loadinfo->ctoralloc = (binfmt_ctor_t*)kumm_malloc(ctorsize);
loadinfo->ctoralloc = (binfmt_ctor_t *)kumm_malloc(ctorsize);
if (!loadinfo->ctoralloc)
{
bdbg("Failed to allocate memory for .ctors\n");
@ -174,7 +174,7 @@ int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
/* Read the section header table into memory */
ret = elf_read(loadinfo, (FAR uint8_t*)loadinfo->ctors, ctorsize,
ret = elf_read(loadinfo, (FAR uint8_t *)loadinfo->ctors, ctorsize,
shdr->sh_offset);
if (ret < 0)
{
@ -206,7 +206,7 @@ int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
* will be relocated via the normal mechanism.
*/
loadinfo->ctors = (binfmt_ctor_t*)shdr->sh_addr;
loadinfo->ctors = (binfmt_ctor_t *)shdr->sh_addr;
}
}

View file

@ -163,7 +163,7 @@ int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
{
/* Allocate memory to hold a copy of the .dtor section */
loadinfo->ctoralloc = (binfmt_dtor_t*)kumm_malloc(dtorsize);
loadinfo->ctoralloc = (binfmt_dtor_t *)kumm_malloc(dtorsize);
if (!loadinfo->ctoralloc)
{
bdbg("Failed to allocate memory for .dtors\n");
@ -174,7 +174,7 @@ int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
/* Read the section header table into memory */
ret = elf_read(loadinfo, (FAR uint8_t*)loadinfo->dtors, dtorsize,
ret = elf_read(loadinfo, (FAR uint8_t *)loadinfo->dtors, dtorsize,
shdr->sh_offset);
if (ret < 0)
{
@ -206,7 +206,7 @@ int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
* will be relocated via the normal mechanism.
*/
loadinfo->dtors = (binfmt_dtor_t*)shdr->sh_addr;
loadinfo->dtors = (binfmt_dtor_t *)shdr->sh_addr;
}
}

View file

@ -172,19 +172,19 @@ int elf_init(FAR const char *filename, FAR struct elf_loadinfo_s *loadinfo)
/* Read the ELF ehdr from offset 0 */
ret = elf_read(loadinfo, (FAR uint8_t*)&loadinfo->ehdr, sizeof(Elf32_Ehdr), 0);
ret = elf_read(loadinfo, (FAR uint8_t *)&loadinfo->ehdr, sizeof(Elf32_Ehdr), 0);
if (ret < 0)
{
bdbg("Failed to read ELF header: %d\n", ret);
return ret;
}
elf_dumpbuffer("ELF header", (FAR const uint8_t*)&loadinfo->ehdr, sizeof(Elf32_Ehdr));
elf_dumpbuffer("ELF header", (FAR const uint8_t *)&loadinfo->ehdr, sizeof(Elf32_Ehdr));
/* Verify the ELF header */
ret = elf_verifyheader(&loadinfo->ehdr);
if (ret <0)
if (ret < 0)
{
/* This may not be an error because we will be called to attempt loading
* EVERY binary. If elf_verifyheader() does not recognize the ELF header,

View file

@ -157,8 +157,8 @@ static inline int elf_loadfile(FAR struct elf_loadinfo_s *loadinfo)
/* Read each section into memory that is marked SHF_ALLOC + SHT_NOBITS */
bvdbg("Loaded sections:\n");
text = (FAR uint8_t*)loadinfo->textalloc;
data = (FAR uint8_t*)loadinfo->dataalloc;
text = (FAR uint8_t *)loadinfo->textalloc;
data = (FAR uint8_t *)loadinfo->dataalloc;
for (i = 0; i < loadinfo->ehdr.e_shnum; i++)
{

View file

@ -68,9 +68,9 @@
****************************************************************************/
#if defined(ELF_DUMP_READDATA)
static inline void elf_dumpreaddata(char *buffer, int buflen)
static inline void elf_dumpreaddata(FAR char *buffer, int buflen)
{
uint32_t *buf32 = (uint32_t*)buffer;
FAR uint32_t *buf32 = (FAR uint32_t *)buffer;
int i;
int j;

View file

@ -117,7 +117,7 @@ static inline int elf_sectname(FAR struct elf_loadinfo_s *loadinfo,
buffer = loadinfo->iobuffer;
bytesread = 0;
for (;;)
for (; ; )
{
/* Get the number of bytes to read */
@ -211,16 +211,18 @@ int elf_loadshdrs(FAR struct elf_loadinfo_s *loadinfo)
/* Allocate memory to hold a working copy of the sector header table */
loadinfo->shdr = (FAR Elf32_Shdr*)kmm_malloc(shdrsize);
loadinfo->shdr = (FAR FAR Elf32_Shdr *)kmm_malloc(shdrsize);
if (!loadinfo->shdr)
{
bdbg("Failed to allocate the section header table. Size: %ld\n", (long)shdrsize);
bdbg("Failed to allocate the section header table. Size: %ld\n",
(long)shdrsize);
return -ENOMEM;
}
/* Read the section header table into memory */
ret = elf_read(loadinfo, (FAR uint8_t*)loadinfo->shdr, shdrsize, loadinfo->ehdr.e_shoff);
ret = elf_read(loadinfo, (FAR uint8_t *)loadinfo->shdr, shdrsize,
loadinfo->ehdr.e_shoff);
if (ret < 0)
{
bdbg("Failed to read section header table: %d\n", ret);

View file

@ -107,7 +107,7 @@ static int elf_symname(FAR struct elf_loadinfo_s *loadinfo,
bytesread = 0;
for (;;)
for (; ; )
{
/* Get the number of bytes to read */
@ -239,7 +239,7 @@ int elf_readsym(FAR struct elf_loadinfo_s *loadinfo, int index,
/* And, finally, read the symbol table entry into memory */
return elf_read(loadinfo, (FAR uint8_t*)sym, sizeof(Elf32_Sym), offset);
return elf_read(loadinfo, (FAR uint8_t *)sym, sizeof(Elf32_Sym), offset);
}
/****************************************************************************

View file

@ -53,7 +53,10 @@
* Private Constant Data
****************************************************************************/
static const char g_elfmagic[EI_MAGIC_SIZE] = { 0x7f, 'E', 'L', 'F' };
static const char g_elfmagic[EI_MAGIC_SIZE] =
{
0x7f, 'E', 'L', 'F'
};
/****************************************************************************
* Private Functions

View file

@ -102,14 +102,14 @@
static inline int nxflat_bindrel32i(FAR struct nxflat_loadinfo_s *loadinfo,
uint32_t offset)
{
uint32_t *addr;
FAR uint32_t *addr;
bvdbg("NXFLAT_RELOC_TYPE_REL32I Offset: %08x I-Space: %p\n",
offset, loadinfo->ispace + sizeof(struct nxflat_hdr_s));
if (offset < loadinfo->dsize)
{
addr = (uint32_t*)(offset + loadinfo->dspace->region);
addr = (FAR uint32_t *)(offset + loadinfo->dspace->region);
bvdbg(" Before: %08x\n", *addr);
*addr += (uint32_t)(loadinfo->ispace + sizeof(struct nxflat_hdr_s));
bvdbg(" After: %08x\n", *addr);
@ -141,14 +141,14 @@ static inline int nxflat_bindrel32i(FAR struct nxflat_loadinfo_s *loadinfo,
static inline int nxflat_bindrel32d(FAR struct nxflat_loadinfo_s *loadinfo,
uint32_t offset)
{
uint32_t *addr;
FAR uint32_t *addr;
bvdbg("NXFLAT_RELOC_TYPE_REL32D Offset: %08x D-Space: %p\n",
offset, loadinfo->dspace->region);
if (offset < loadinfo->dsize)
{
addr = (uint32_t*)(offset + loadinfo->dspace->region);
addr = (FAR uint32_t *)(offset + loadinfo->dspace->region);
bvdbg(" Before: %08x\n", *addr);
*addr += (uint32_t)(loadinfo->dspace->region);
bvdbg(" After: %08x\n", *addr);
@ -183,14 +183,14 @@ static inline int nxflat_bindrel32d(FAR struct nxflat_loadinfo_s *loadinfo,
static inline int nxflat_bindrel32id(FAR struct nxflat_loadinfo_s *loadinfo,
uint32_t offset)
{
uint32_t *addr;
FAR uint32_t *addr;
bvdbg("NXFLAT_RELOC_TYPE_REL32D Offset: %08x D-Space: %p\n",
offset, loadinfo->dspace->region);
if (offset < loadinfo->dsize)
{
addr = (uint32_t*)(offset + loadinfo->dspace->region);
addr = (FAR uint32_t *)(offset + loadinfo->dspace->region);
bvdbg(" Before: %08x\n", *addr);
*addr += ((uint32_t)loadinfo->ispace - (uint32_t)(loadinfo->dspace->region));
bvdbg(" After: %08x\n", *addr);
@ -231,7 +231,7 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo)
/* The NXFLAT header is the first thing at the beginning of the ISpace. */
hdr = (FAR struct nxflat_hdr_s*)loadinfo->ispace;
hdr = (FAR struct nxflat_hdr_s *)loadinfo->ispace;
/* From this, we can get the offset to the list of relocation entries */
@ -348,8 +348,8 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo)
#ifdef CONFIG_NXFLAT_DUMPBUFFER
if (ret == OK && nrelocs > 0)
{
relocs = (FAR struct nxflat_reloc_s*)(offset - loadinfo->isize + loadinfo->dspace->region);
nxflat_dumpbuffer("GOT", (FAR const uint8_t*)relocs, nrelocs * sizeof(struct nxflat_reloc_s));
relocs = (FAR struct nxflat_reloc_s *)(offset - loadinfo->isize + loadinfo->dspace->region);
nxflat_dumpbuffer("GOT", (FAR const uint8_t *)relocs, nrelocs * sizeof(struct nxflat_reloc_s));
}
#endif
@ -397,7 +397,7 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
/* The NXFLAT header is the first thing at the beginning of the ISpace. */
hdr = (FAR struct nxflat_hdr_s*)loadinfo->ispace;
hdr = (FAR struct nxflat_hdr_s *)loadinfo->ispace;
/* From this, we can get the offset to the list of symbols imported by
* this module and the number of symbols imported by this module.
@ -440,7 +440,7 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
DEBUGASSERT(offset >= loadinfo->isize &&
offset < loadinfo->isize + loadinfo->dsize);
imports = (struct nxflat_import_s*)
imports = (FAR struct nxflat_import_s *)
(offset - loadinfo->isize + loadinfo->dspace->region);
/* Now, traverse the list of imported symbols and attempt to bind
@ -462,7 +462,7 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
offset = imports[i].i_funcname;
DEBUGASSERT(offset < loadinfo->isize);
symname = (char*)(offset + loadinfo->ispace + sizeof(struct nxflat_hdr_s));
symname = (FAR char *)(offset + loadinfo->ispace + sizeof(struct nxflat_hdr_s));
/* Find the exported symbol value for this this symbol name. */
@ -494,7 +494,7 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
#ifdef CONFIG_NXFLAT_DUMPBUFFER
if (nimports > 0)
{
nxflat_dumpbuffer("Imports", (FAR const uint8_t*)imports, nimports * sizeof(struct nxflat_import_s));
nxflat_dumpbuffer("Imports", (FAR const uint8_t *)imports, nimports * sizeof(struct nxflat_import_s));
}
#endif
@ -549,7 +549,7 @@ static inline int nxflat_clearbss(FAR struct nxflat_loadinfo_s *loadinfo)
/* Zero the BSS area */
memset((void*)(loadinfo->dspace->region + loadinfo->datasize), 0,
memset((FAR void *)(loadinfo->dspace->region + loadinfo->datasize), 0,
loadinfo->bsssize);
/* Restore the original address environment */

View file

@ -118,14 +118,15 @@ int nxflat_init(const char *filename, struct nxflat_loadinfo_s *loadinfo)
/* Read the NXFLAT header from offset 0 */
ret = nxflat_read(loadinfo, (char*)&loadinfo->header,
ret = nxflat_read(loadinfo, (FAR char *)&loadinfo->header,
sizeof(struct nxflat_hdr_s), 0);
if (ret < 0)
{
bdbg("Failed to read NXFLAT header: %d\n", ret);
return ret;
}
nxflat_dumpbuffer("NXFLAT header", (FAR const uint8_t*)&loadinfo->header,
nxflat_dumpbuffer("NXFLAT header", (FAR const uint8_t *)&loadinfo->header,
sizeof(struct nxflat_hdr_s));
/* Verify the NXFLAT header */

View file

@ -147,7 +147,7 @@ int nxflat_load(struct nxflat_loadinfo_s *loadinfo)
*/
loadinfo->ispace = (uint32_t)mmap(NULL, loadinfo->isize, PROT_READ,
MAP_SHARED|MAP_FILE, loadinfo->filfd, 0);
MAP_SHARED | MAP_FILE, loadinfo->filfd, 0);
if (loadinfo->ispace == (uint32_t)MAP_FAILED)
{
bdbg("Failed to map NXFLAT ISpace: %d\n", errno);
@ -189,7 +189,8 @@ int nxflat_load(struct nxflat_loadinfo_s *loadinfo)
* DSpace memory.
*/
ret = nxflat_read(loadinfo, (char*)loadinfo->dspace->region, dreadsize, doffset);
ret = nxflat_read(loadinfo, (FAR char *)loadinfo->dspace->region,
dreadsize, doffset);
if (ret < 0)
{
bdbg("Failed to read .data section: %d\n", ret);

View file

@ -69,9 +69,9 @@
****************************************************************************/
#if defined(NXFLAT_DUMP_READDATA)
static inline void nxflat_dumpreaddata(char *buffer, int buflen)
static inline void nxflat_dumpreaddata(FAR char *buffer, int buflen)
{
uint32_t *buf32 = (uint32_t*)buffer;
FAR uint32_t *buf32 = (FAR uint32_t *)buffer;
int i;
int j;

View file

@ -79,14 +79,14 @@
*
****************************************************************************/
int nxflat_unload(struct nxflat_loadinfo_s *loadinfo)
int nxflat_unload(FAR struct nxflat_loadinfo_s *loadinfo)
{
/* Release the memory segments */
/* Release the I-Space mmap'ed file */
if (loadinfo->ispace)
{
munmap((void*)loadinfo->ispace, loadinfo->isize);
munmap((FAR void *)loadinfo->ispace, loadinfo->isize);
loadinfo->ispace = 0;
}

View file

@ -187,7 +187,7 @@ static int nxflat_loadbinary(struct binary_s *binp)
*/
binp->entrypt = (main_t)(loadinfo.ispace + loadinfo.entryoffs);
binp->mapped = (void*)loadinfo.ispace;
binp->mapped = (FAR void *)loadinfo.ispace;
binp->mapsize = loadinfo.isize;
binp->stacksize = loadinfo.stacksize;
@ -202,7 +202,7 @@ static int nxflat_loadbinary(struct binary_s *binp)
#ifdef CONFIG_ARCH_ADDRENV
# warning "REVISIT"
#else
binp->alloc[0] = (void*)loadinfo.dspace;
binp->alloc[0] = (FAR void *)loadinfo.dspace;
#endif
#ifdef CONFIG_ARCH_ADDRENV
@ -213,7 +213,7 @@ static int nxflat_loadbinary(struct binary_s *binp)
up_addrenv_clone(&loadinfo.addrenv, &binp->addrenv);
#endif
nxflat_dumpbuffer("Entry code", (FAR const uint8_t*)binp->entrypt,
nxflat_dumpbuffer("Entry code", (FAR const uint8_t *)binp->entrypt,
MIN(loadinfo.isize - loadinfo.entryoffs, 512));
nxflat_uninit(&loadinfo);

View file

@ -352,7 +352,7 @@ static int pcode_load(struct binary_s *binp)
{
/* Set up for the next gulp */
DEBUGASSERT(nread > 0 && nread <=remaining);
DEBUGASSERT(nread > 0 && nread <= remaining);
remaining -= nread;
ptr += nread;
}

View file

@ -100,7 +100,7 @@ symtab_findorderedbyvalue(FAR const struct symtab_s *symtab,
*/
mid = (low + high) >> 1;
if ( value < symtab[mid].sym_value)
if (value < symtab[mid].sym_value)
{
high = mid - 1;
}