0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-08-23 10:33:50 -04:00

output/outelf32.c: code style simplification

1) nasm_free is safe against NULL passed so call
   it without test

2) dwarf32_output: check for debug_immcall early
   and get out of procedure if success. This allow
   us to move code blocks left removing indents.

3) dwarf32_findfile and dwarf32_findsect: no need
   for 'else' when 'if' target is plain return.
   Move code blocks left removing indents.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov 2009-09-03 20:16:28 +04:00
parent 6ae5903676
commit 7ea1ef1c84

View File

@ -1781,17 +1781,16 @@ static void stabs32_cleanup(void)
struct linelist *ptr, *del;
if (!stabslines)
return;
ptr = stabslines;
while (ptr) {
del = ptr;
ptr = ptr->next;
nasm_free(del);
}
if (stabbuf)
nasm_free(stabbuf);
if (stabrelbuf)
nasm_free(stabrelbuf);
if (stabstrbuf)
nasm_free(stabstrbuf);
}
@ -1831,7 +1830,9 @@ static void dwarf32_output(int type, void *param)
dwarf32_findsect(s->section);
/* do nothing unless line or file has changed */
if (debug_immcall) {
if (!debug_immcall)
return;
ln = currentline - dwarf_csect->line;
aa = s->offset - dwarf_csect->offset;
inx = dwarf_clist->line;
@ -1862,10 +1863,10 @@ static void dwarf32_output(int type, void *param)
dwarf_csect->line = currentline;
dwarf_csect->offset = s->offset;
}
/* show change handled */
debug_immcall = 0;
}
}
static void dwarf32_generate(void)
@ -2103,27 +2104,18 @@ static void dwarf32_generate(void)
static void dwarf32_cleanup(void)
{
if (arangesbuf)
nasm_free(arangesbuf);
if (arangesrelbuf)
nasm_free(arangesrelbuf);
if (pubnamesbuf)
nasm_free(pubnamesbuf);
if (infobuf)
nasm_free(infobuf);
if (inforelbuf)
nasm_free(inforelbuf);
if (abbrevbuf)
nasm_free(abbrevbuf);
if (linebuf)
nasm_free(linebuf);
if (linerelbuf)
nasm_free(linerelbuf);
if (framebuf)
nasm_free(framebuf);
if (locbuf)
nasm_free(locbuf);
}
static void dwarf32_findfile(const char * fname)
{
int finx;
@ -2132,8 +2124,8 @@ static void dwarf32_findfile(const char * fname)
/* return if fname is current file name */
if (dwarf_clist && !(strcmp(fname, dwarf_clist->filename)))
return;
/* search for match */
else {
match = 0;
if (dwarf_flist) {
match = dwarf_flist;
@ -2144,6 +2136,7 @@ static void dwarf32_findfile(const char * fname)
}
}
}
/* add file name to end of list */
dwarf_clist = (struct linelist *)nasm_malloc(sizeof(struct linelist));
dwarf_numfiles++;
@ -2158,7 +2151,7 @@ static void dwarf32_findfile(const char * fname)
dwarf_elist->next = dwarf_clist;
dwarf_elist = dwarf_clist;
}
}
}
static void dwarf32_findsect(const int index)
@ -2170,8 +2163,8 @@ static void dwarf32_findsect(const int index)
/* return if index is current section index */
if (dwarf_csect && (dwarf_csect->section == index))
return;
/* search for match */
else {
match = 0;
if (dwarf_fsect) {
match = dwarf_fsect;
@ -2183,6 +2176,7 @@ static void dwarf32_findsect(const int index)
match = match->next;
}
}
/* add entry to end of list */
dwarf_csect = (struct sectlist *)nasm_malloc(sizeof(struct sectlist));
dwarf_nsections++;
@ -2206,6 +2200,5 @@ static void dwarf32_findsect(const int index)
dwarf_esect = dwarf_csect;
}
}
}
#endif /* OF_ELF */