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