diff --git a/asm/assemble.c b/asm/assemble.c index e71e907a..aef9b796 100644 --- a/asm/assemble.c +++ b/asm/assemble.c @@ -1317,7 +1317,7 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, break; default: - nasm_panic(0, "internal instruction table corrupt" + nasm_panic("internal instruction table corrupt" ": instruction code \\%o (0x%02X) given", c, c); break; } @@ -1548,7 +1548,7 @@ static int emit_prefix(struct out_data *data, const int bits, insn *ins) case P_none: break; default: - nasm_panic(0, "invalid instruction prefix"); + nasm_panic("invalid instruction prefix"); } if (c) { if (data) @@ -1866,7 +1866,7 @@ static void gencode(struct out_data *data, insn *ins) case 0340: if (ins->oprs[0].segment != NO_SEG) - nasm_panic(0, "non-constant BSS size in pass two"); + nasm_panic("non-constant BSS size in pass two"); out_reserve(data, ins->oprs[0].offset); break; @@ -1976,7 +1976,7 @@ static void gencode(struct out_data *data, insn *ins) break; default: - nasm_panic(0, "internal instruction table corrupt" + nasm_panic("internal instruction table corrupt" ": instruction code \\%o (0x%02X) given", c, c); break; } @@ -1986,14 +1986,14 @@ static void gencode(struct out_data *data, insn *ins) static opflags_t regflag(const operand * o) { if (!is_register(o->basereg)) - nasm_panic(0, "invalid operand passed to regflag()"); + nasm_panic("invalid operand passed to regflag()"); return nasm_reg_flags[o->basereg]; } static int32_t regval(const operand * o) { if (!is_register(o->basereg)) - nasm_panic(0, "invalid operand passed to regval()"); + nasm_panic("invalid operand passed to regval()"); return nasm_regvals[o->basereg]; } @@ -2003,7 +2003,7 @@ static int op_rexflags(const operand * o, int mask) int val; if (!is_register(o->basereg)) - nasm_panic(0, "invalid operand passed to op_rexflags()"); + nasm_panic("invalid operand passed to op_rexflags()"); flags = nasm_reg_flags[o->basereg]; val = nasm_regvals[o->basereg]; diff --git a/asm/directiv.c b/asm/directiv.c index 68a74a12..13ef5eb7 100644 --- a/asm/directiv.c +++ b/asm/directiv.c @@ -395,7 +395,7 @@ bool process_directives(char *directive) } else if (passn == 1) absolute.offset = 0x100; /* don't go near zero in case of / */ else - nasm_panic(0, "invalid ABSOLUTE address " + nasm_panic("invalid ABSOLUTE address " "in pass two"); in_absolute = true; location.segment = NO_SEG; diff --git a/asm/error.c b/asm/error.c index 3fdaa027..116e871b 100644 --- a/asm/error.c +++ b/asm/error.c @@ -88,7 +88,16 @@ void nasm_error(int severity, const char *fmt, ...) va_end(ap); } -fatal_func nasm_fatal(int flags, const char *fmt, ...) +fatal_func nasm_fatal(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + nasm_verror(ERR_FATAL, fmt, ap); + abort(); /* We should never get here */ +} + +fatal_func nasm_fatal_fl(int flags, const char *fmt, ...) { va_list ap; @@ -97,7 +106,16 @@ fatal_func nasm_fatal(int flags, const char *fmt, ...) abort(); /* We should never get here */ } -fatal_func nasm_panic(int flags, const char *fmt, ...) +fatal_func nasm_panic(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + nasm_verror(ERR_PANIC, fmt, ap); + abort(); /* We should never get here */ +} + +fatal_func nasm_panic_fl(int flags, const char *fmt, ...) { va_list ap; @@ -108,12 +126,12 @@ fatal_func nasm_panic(int flags, const char *fmt, ...) fatal_func nasm_panic_from_macro(const char *file, int line) { - nasm_panic(ERR_NOFILE, "Internal error at %s:%d\n", file, line); + nasm_panic("internal error at %s:%d\n", file, line); } fatal_func nasm_assert_failed(const char *file, int line, const char *msg) { - nasm_panic(0, "assertion %s failed at %s:%d", msg, file, line); + nasm_panic("assertion %s failed at %s:%d", msg, file, line); } /* diff --git a/asm/eval.c b/asm/eval.c index 1a6680f2..c4ea4fde 100644 --- a/asm/eval.c +++ b/asm/eval.c @@ -752,7 +752,7 @@ static int64_t eval_ifunc(int64_t val, enum ifunc func) break; default: - nasm_panic(0, "invalid IFUNC token %d", func); + nasm_panic("invalid IFUNC token %d", func); rv = 0; break; } diff --git a/asm/float.c b/asm/float.c index fd66ef38..dcf69fea 100644 --- a/asm/float.c +++ b/asm/float.c @@ -732,11 +732,7 @@ static int to_float(const char *str, int s, uint8_t *result, const int bits = fmt->bytes * 8; const char *strend; - if (!str[0]) { - nasm_panic(0, - "internal errror: empty string passed to float_const"); - return 0; - } + nasm_assert(str[0]); strend = strchr(str, '\0'); if (strend[-1] == 'P' || strend[-1] == 'p') @@ -916,7 +912,7 @@ int float_const(const char *number, int sign, uint8_t *result, int bytes) case 16: return to_float(number, sign, result, &ieee_128); default: - nasm_panic(0, "strange value %d passed to float_const", bytes); + nasm_panic("strange value %d passed to float_const", bytes); return 0; } } diff --git a/asm/nasm.c b/asm/nasm.c index 6299831f..3b987727 100644 --- a/asm/nasm.c +++ b/asm/nasm.c @@ -463,7 +463,7 @@ int main(int argc, char **argv) } else { dfmt = dfmt_find(ofmt, debug_format); if (!dfmt) { - nasm_fatal(ERR_NOFILE | ERR_USAGE, + nasm_fatal_fl(ERR_NOFILE | ERR_USAGE, "unrecognized debug format `%s' for" " output format `%s'", debug_format, ofmt->shortname); @@ -505,7 +505,7 @@ int main(int argc, char **argv) if (outname) { ofile = nasm_open_write(outname, NF_TEXT); if (!ofile) - nasm_fatal(ERR_NOFILE, + nasm_fatal_fl(ERR_NOFILE, "unable to open output file `%s'", outname); } else @@ -550,7 +550,7 @@ int main(int argc, char **argv) if (operating_mode & OP_NORMAL) { ofile = nasm_open_write(outname, (ofmt->flags & OFMT_TEXT) ? NF_TEXT : NF_BINARY); if (!ofile) - nasm_fatal(ERR_NOFILE, + nasm_fatal_fl(ERR_NOFILE, "unable to open output file `%s'", outname); /* @@ -623,7 +623,7 @@ static char *get_param(char *p, char *q, bool *advance) static void copy_filename(const char **dst, const char *src, const char *what) { if (*dst) - nasm_fatal(0, "more than one %s file specified: %s\n", what, src); + nasm_fatal("more than one %s file specified: %s\n", what, src); *dst = nasm_strdup(src); } @@ -854,7 +854,7 @@ static bool process_arg(char *p, char *q, int pass) if (pass == 1) { ofmt = ofmt_find(param, &ofmt_alias); if (!ofmt) { - nasm_fatal(ERR_NOFILE | ERR_USAGE, + nasm_fatal_fl(ERR_NOFILE | ERR_USAGE, "unrecognised output format `%s' - " "use -hf for a list", param); } @@ -895,8 +895,7 @@ static bool process_arg(char *p, char *q, int pass) break; default: - nasm_fatal(0, - "unknown optimization option -O%c\n", + nasm_fatal("unknown optimization option -O%c\n", *param); break; } @@ -955,7 +954,7 @@ static bool process_arg(char *p, char *q, int pass) else if (nasm_stricmp("gnu", param) == 0) nasm_set_verror(nasm_verror_gnu); else - nasm_fatal(ERR_NOFILE | ERR_USAGE, + nasm_fatal_fl(ERR_NOFILE | ERR_USAGE, "unrecognized error reporting format `%s'", param); } @@ -1354,19 +1353,19 @@ static void parse_cmdline(int argc, char **argv, int pass) return; if (!inname) - nasm_fatal(ERR_NOFILE | ERR_USAGE, "no input file specified"); + nasm_fatal_fl(ERR_NOFILE | ERR_USAGE, "no input file specified"); else if ((errname && !strcmp(inname, errname)) || (outname && !strcmp(inname, outname)) || (listname && !strcmp(inname, listname)) || (depend_file && !strcmp(inname, depend_file))) - nasm_fatal(ERR_USAGE, "will not overwrite input file"); + nasm_fatal_fl(ERR_USAGE, "will not overwrite input file"); if (errname) { error_file = nasm_open_write(errname, NF_TEXT); if (!error_file) { error_file = stderr; /* Revert to default! */ - nasm_fatal(ERR_NOFILE | ERR_USAGE, + nasm_fatal_fl(ERR_NOFILE | ERR_USAGE, "cannot open file `%s' for error messages", errname); } @@ -1386,11 +1385,11 @@ static void assemble_file(const char *fname, StrList **depend_ptr) break; case 32: if (!iflag_cpu_level_ok(&cmd_cpu, IF_386)) - nasm_fatal(0, "command line: 32-bit segment size requires a higher cpu"); + nasm_fatal("command line: 32-bit segment size requires a higher cpu"); break; case 64: if (!iflag_cpu_level_ok(&cmd_cpu, IF_X86_64)) - nasm_fatal(0, "command line: 64-bit segment size requires a higher cpu"); + nasm_fatal("command line: 64-bit segment size requires a higher cpu"); break; default: panic(); @@ -1434,8 +1433,7 @@ static void assemble_file(const char *fname, StrList **depend_ptr) while ((line = preproc->getline())) { if (++globallineno > nasm_limit[LIMIT_LINES]) - nasm_fatal(0, - "overall line count exceeds the maximum %"PRId64"\n", + nasm_fatal("overall line count exceeds the maximum %"PRId64"\n", nasm_limit[LIMIT_LINES]); /* diff --git a/asm/parser.c b/asm/parser.c index 40188410..d5a45753 100644 --- a/asm/parser.c +++ b/asm/parser.c @@ -98,7 +98,7 @@ static int prefix_slot(int prefix) case P_VEX2: return PPS_VEX; default: - nasm_panic(0, "Invalid value %d passed to prefix_slot()", prefix); + nasm_panic("Invalid value %d passed to prefix_slot()", prefix); return -1; } } diff --git a/asm/preproc-nop.c b/asm/preproc-nop.c index 6f7aaf9e..ee690063 100644 --- a/asm/preproc-nop.c +++ b/asm/preproc-nop.c @@ -70,7 +70,7 @@ static void nop_reset(const char *file, int pass, StrList **deplist) nop_fp = nasm_open_read(file, NF_TEXT); if (!nop_fp) - nasm_fatal(ERR_NOFILE, "unable to open input file `%s'", file); + nasm_fatal_fl(ERR_NOFILE, "unable to open input file `%s'", file); (void)pass; /* placate compilers */ nasm_add_string_to_strlist(deplist, file); diff --git a/asm/preproc.c b/asm/preproc.c index 8e1e6369..fbdfedb7 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -1607,7 +1607,7 @@ static FILE *inc_fopen(const char *file, if (!path) { if (omode == INC_NEEDED) - nasm_fatal(0, "unable to open include file `%s'", file); + nasm_fatal("unable to open include file `%s'", file); if (found_path) *found_path = NULL; @@ -2821,7 +2821,7 @@ issue_error: nasm_error(ERR_WARNING|ERR_PASS1|ERR_PP_PRECOND, "trailing garbage after `%%else' ignored"); if (!istk->conds) - nasm_fatal(0, "`%%else: no matching `%%if'"); + nasm_fatal("`%%else: no matching `%%if'"); switch(istk->conds->state) { case COND_IF_TRUE: case COND_DONE: @@ -4986,7 +4986,7 @@ pp_reset(const char *file, int apass, StrList **deplist) src_set(0, file); istk->lineinc = 1; if (!istk->fp) - nasm_fatal(ERR_NOFILE, "unable to open input file `%s'", file); + nasm_fatal_fl(ERR_NOFILE, "unable to open input file `%s'", file); defining = NULL; nested_mac_count = 0; nested_rep_count = 0; @@ -5094,9 +5094,9 @@ static char *pp_getline(void) */ if (defining) { if (defining->name) - nasm_panic(0, "defining with name in expansion"); + nasm_panic("defining with name in expansion"); else if (istk->mstk->name) - nasm_fatal(0, "`%%rep' without `%%endrep' within" + nasm_fatal("`%%rep' without `%%endrep' within" " expansion of macro `%s'", istk->mstk->name); } @@ -5171,8 +5171,7 @@ static char *pp_getline(void) fclose(i->fp); if (i->conds) { /* nasm_error can't be conditionally suppressed */ - nasm_fatal(0, - "expected `%%endif' before end of file"); + nasm_fatal("expected `%%endif' before end of file"); } /* only set line and file name if there's a next node */ if (i->next) diff --git a/include/error.h b/include/error.h index 83b28da0..ae336de9 100644 --- a/include/error.h +++ b/include/error.h @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2017 The NASM Authors - All Rights Reserved + * Copyright 1996-2018 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -44,8 +44,10 @@ * An error reporting function should look like this. */ void printf_func(2, 3) nasm_error(int severity, const char *fmt, ...); -fatal_func printf_func(2, 3) nasm_fatal(int flags, const char *fmt, ...); -fatal_func printf_func(2, 3) nasm_panic(int flags, const char *fmt, ...); +fatal_func printf_func(1, 2) nasm_fatal(const char *fmt, ...); +fatal_func printf_func(1, 2) nasm_panic(const char *fmt, ...); +fatal_func printf_func(2, 3) nasm_fatal_fl(int flags, const char *fmt, ...); +fatal_func printf_func(2, 3) nasm_panic_fl(int flags, const char *fmt, ...); fatal_func nasm_panic_from_macro(const char *file, int line); #define panic() nasm_panic_from_macro(__FILE__, __LINE__); diff --git a/nasmlib/file.c b/nasmlib/file.c index c0b4e781..c7bd1a62 100644 --- a/nasmlib/file.c +++ b/nasmlib/file.c @@ -37,9 +37,9 @@ void nasm_read(void *ptr, size_t size, FILE *f) { size_t n = fread(ptr, 1, size, f); if (ferror(f)) { - nasm_fatal(0, "unable to read input: %s", strerror(errno)); + nasm_fatal("unable to read input: %s", strerror(errno)); } else if (n != size || feof(f)) { - nasm_fatal(0, "fatal short read on input"); + nasm_fatal("fatal short read on input"); } } @@ -47,7 +47,7 @@ void nasm_write(const void *ptr, size_t size, FILE *f) { size_t n = fwrite(ptr, 1, size, f); if (n != size || ferror(f) || feof(f)) - nasm_fatal(0, "unable to write output: %s", strerror(errno)); + nasm_fatal("unable to write output: %s", strerror(errno)); } void fwriteint16_t(uint16_t data, FILE * fp) @@ -119,7 +119,7 @@ FILE *nasm_open_read(const char *filename, enum file_flags flags) f = fopen(filename, (flags & NF_TEXT) ? "rt" : "rb"); if (!f && (flags & NF_FATAL)) - nasm_fatal(ERR_NOFILE, "unable to open input file: `%s': %s", + nasm_fatal_fl(ERR_NOFILE, "unable to open input file: `%s': %s", filename, strerror(errno)); return f; @@ -132,7 +132,7 @@ FILE *nasm_open_write(const char *filename, enum file_flags flags) f = fopen(filename, (flags & NF_TEXT) ? "wt" : "wb"); if (!f && (flags & NF_FATAL)) - nasm_fatal(ERR_NOFILE, "unable to open output file: `%s': %s", + nasm_fatal_fl(ERR_NOFILE, "unable to open output file: `%s': %s", filename, strerror(errno)); return f; diff --git a/nasmlib/malloc.c b/nasmlib/malloc.c index ccbc0c75..1e643185 100644 --- a/nasmlib/malloc.c +++ b/nasmlib/malloc.c @@ -44,7 +44,7 @@ static no_return nasm_alloc_failed(void) { - nasm_fatal(0, "out of memory"); + nasm_fatal("out of memory"); } static inline void *validate_ptr(void *p) diff --git a/output/codeview.c b/output/codeview.c index 15561793..0fbdcab7 100644 --- a/output/codeview.c +++ b/output/codeview.c @@ -480,7 +480,7 @@ static void register_reloc(struct coff_Section *const sect, return; } } - nasm_panic(0, "codeview: relocation for unregistered symbol: %s", sym); + nasm_panic("codeview: relocation for unregistered symbol: %s", sym); } static inline void section_write32(struct coff_Section *sect, uint32_t val) diff --git a/output/outas86.c b/output/outas86.c index 3a84fc07..13578f06 100644 --- a/output/outas86.c +++ b/output/outas86.c @@ -498,7 +498,7 @@ static void as86_set_rsize(int size) fputc(0x03, ofile); break; default: - nasm_panic(0, "bizarre relocation size %d", size); + nasm_panic("bizarre relocation size %d", size); break; } } diff --git a/output/outbin.c b/output/outbin.c index 86af5a83..ea49abb5 100644 --- a/output/outbin.c +++ b/output/outbin.c @@ -267,9 +267,8 @@ static void bin_cleanup(void) if (s->flags & (START_DEFINED | ALIGN_DEFINED | FOLLOWS_DEFINED)) { /* Check for a mixture of real and virtual section attributes. */ if (s->flags & (VSTART_DEFINED | VALIGN_DEFINED | VFOLLOWS_DEFINED)) - nasm_fatal(0, - "cannot mix real and virtual attributes" - " in nobits section (%s)", s->name); + nasm_fatal("cannot mix real and virtual attributes" + " in nobits section (%s)", s->name); /* Real and virtual attributes mean the same thing for nobits sections. */ if (s->flags & START_DEFINED) { s->vstart = s->start; @@ -338,11 +337,11 @@ static void bin_cleanup(void) s && strcmp(s->name, g->follows); sp = &s->next, s = s->next) ; if (!s) - nasm_fatal(0, "section %s follows an invalid or" + nasm_fatal("section %s follows an invalid or" " unknown section (%s)", g->name, g->follows); if (s->next && (s->next->flags & FOLLOWS_DEFINED) && !strcmp(s->name, s->next->follows)) - nasm_fatal(0, "sections %s and %s can't both follow" + nasm_fatal("sections %s and %s can't both follow" " section %s", g->name, s->next->name, s->name); /* Find the end of the current follows group (gs). */ for (gsp = &g->next, gs = g->next; @@ -386,7 +385,7 @@ static void bin_cleanup(void) if (sections->flags & START_DEFINED) { /* Make sure this section doesn't begin before the origin. */ if (sections->start < origin) - nasm_fatal(0, "section %s begins" + nasm_fatal("section %s begins" " before program origin", sections->name); } else if (sections->flags & ALIGN_DEFINED) { sections->start = ALIGN(origin, sections->align); @@ -442,13 +441,13 @@ static void bin_cleanup(void) /* Check for section overlap. */ if (s) { if (s->start < origin) - nasm_fatal(0, "section %s beings before program origin", + nasm_fatal("section %s beings before program origin", s->name); if (g->start > s->start) - nasm_fatal(0, "sections %s ~ %s and %s overlap!", + nasm_fatal("sections %s ~ %s and %s overlap!", gs->name, g->name, s->name); if (pend > s->start) - nasm_fatal(0, "sections %s and %s overlap!", + nasm_fatal("sections %s and %s overlap!", g->name, s->name); } /* Remember this section as the latest >0 length section. */ @@ -477,9 +476,8 @@ static void bin_cleanup(void) for (s = sections; s && strcmp(g->vfollows, s->name); s = s->next) ; if (!s) - nasm_fatal(0, - "section %s vfollows unknown section (%s)", - g->name, g->vfollows); + nasm_fatal("section %s vfollows unknown section (%s)", + g->name, g->vfollows); } else if (g->prev != NULL) for (s = sections; s && (s != g->prev); s = s->next) ; /* The .bss section is the only one with prev = NULL. @@ -516,7 +514,7 @@ static void bin_cleanup(void) } } if (h) - nasm_fatal(0, "circular vfollows path detected"); + nasm_fatal("circular vfollows path detected"); #ifdef DEBUG nasm_error(ERR_DEBUG, @@ -740,7 +738,7 @@ static void bin_out(int32_t segto, const void *data, /* Find the segment we are targeting. */ s = find_section_by_index(segto); if (!s) - nasm_panic(0, "code directed to nonexistent segment?"); + nasm_panic("code directed to nonexistent segment?"); /* "Smart" section-type adaptation code. */ if (!(s->flags & TYPE_DEFINED)) { diff --git a/output/outcoff.c b/output/outcoff.c index eed80a8d..d26e2985 100644 --- a/output/outcoff.c +++ b/output/outcoff.c @@ -569,7 +569,7 @@ static void coff_out(int32_t segto, const void *data, if (!s) { int tempint; /* ignored */ if (segto != coff_section_names(".text", 2, &tempint)) - nasm_panic(0, "strange segment conditions in COFF driver"); + nasm_panic("strange segment conditions in COFF driver"); else s = coff_sects[coff_nsects - 1]; } @@ -658,7 +658,7 @@ static void coff_out(int32_t segto, const void *data, " relocations"); } else if (type == OUT_REL4ADR) { if (segment == segto && !(win64)) /* Acceptable for RIP-relative */ - nasm_panic(0, "intra-segment OUT_REL4ADR"); + nasm_panic("intra-segment OUT_REL4ADR"); else if (segment == NO_SEG && win32) nasm_error(ERR_NONFATAL, "Win32 COFF does not correctly support" " relative references to absolute addresses"); @@ -861,8 +861,7 @@ static inline void coff_adjust_relocs(struct coff_Section *s) else { if (ofmt == &of_coff) - nasm_fatal(0, - "Too many relocations (%d) for section `%s'", + nasm_fatal("Too many relocations (%d) for section `%s'", s->nrelocs, s->name); } #endif diff --git a/output/outelf.c b/output/outelf.c index 123bf45e..d8a55416 100644 --- a/output/outelf.c +++ b/output/outelf.c @@ -554,7 +554,7 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset, /* we have to be sure at least text section is there */ int tempint; if (segment != elf_section_names(".text", 2, &tempint)) - nasm_panic(0, "strange segment conditions in ELF driver"); + nasm_panic("strange segment conditions in ELF driver"); } for (i = 0; i < nsects; i++) { if (segment == sects[i]->index) { @@ -808,7 +808,7 @@ static void elf32_out(int32_t segto, const void *data, if (!s) { int tempint; /* ignored */ if (segto != elf_section_names(".text", 2, &tempint)) - nasm_panic(0, "strange segment conditions in ELF driver"); + nasm_panic("strange segment conditions in ELF driver"); else { s = sects[nsects - 1]; i = nsects - 1; @@ -963,7 +963,7 @@ rel12adr: case OUT_REL4ADR: addr = *(int64_t *)data - size; if (segment == segto) - nasm_panic(0, "intra-segment OUT_REL4ADR"); + nasm_panic("intra-segment OUT_REL4ADR"); if (segment != NO_SEG && segment % 2) { nasm_error(ERR_NONFATAL, "ELF format does not support" " segment base references"); @@ -1015,7 +1015,7 @@ static void elf64_out(int32_t segto, const void *data, if (!s) { int tempint; /* ignored */ if (segto != elf_section_names(".text", 2, &tempint)) - nasm_panic(0, "strange segment conditions in ELF driver"); + nasm_panic("strange segment conditions in ELF driver"); else { s = sects[nsects - 1]; i = nsects - 1; @@ -1049,7 +1049,7 @@ static void elf64_out(int32_t segto, const void *data, case OUT_RAWDATA: if (segment != NO_SEG) - nasm_panic(0, "OUT_RAWDATA with other than NO_SEG"); + nasm_panic("OUT_RAWDATA with other than NO_SEG"); elf_sect_write(s, data, size); break; @@ -1086,7 +1086,7 @@ static void elf64_out(int32_t segto, const void *data, elf_add_reloc(s, segment, addr, R_X86_64_64); break; default: - nasm_panic(0, "internal error elf64-hpa-871"); + nasm_panic("internal error elf64-hpa-871"); break; } addr = 0; @@ -1154,7 +1154,7 @@ static void elf64_out(int32_t segto, const void *data, addr = 0; break; default: - nasm_panic(0, "internal error elf64-hpa-903"); + nasm_panic("internal error elf64-hpa-903"); break; } } else if (wrt == elf_plt_sect + 1) { @@ -1182,7 +1182,7 @@ static void elf64_out(int32_t segto, const void *data, rel12adr: addr = *(int64_t *)data - size; if (segment == segto) - nasm_panic(0, "intra-segment OUT_REL1ADR"); + nasm_panic("intra-segment OUT_REL1ADR"); if (segment == NO_SEG) { /* Do nothing */ } else if (segment % 2) { @@ -1203,7 +1203,7 @@ rel12adr: case OUT_REL4ADR: addr = *(int64_t *)data - size; if (segment == segto) - nasm_panic(0, "intra-segment OUT_REL4ADR"); + nasm_panic("intra-segment OUT_REL4ADR"); if (segment == NO_SEG) { /* Do nothing */ } else if (segment % 2) { @@ -1241,7 +1241,7 @@ rel12adr: case OUT_REL8ADR: addr = *(int64_t *)data - size; if (segment == segto) - nasm_panic(0, "intra-segment OUT_REL8ADR"); + nasm_panic("intra-segment OUT_REL8ADR"); if (segment == NO_SEG) { /* Do nothing */ } else if (segment % 2) { @@ -1295,7 +1295,7 @@ static void elfx32_out(int32_t segto, const void *data, if (!s) { int tempint; /* ignored */ if (segto != elf_section_names(".text", 2, &tempint)) - nasm_panic(0, "strange segment conditions in ELF driver"); + nasm_panic("strange segment conditions in ELF driver"); else { s = sects[nsects - 1]; i = nsects - 1; @@ -1329,7 +1329,7 @@ static void elfx32_out(int32_t segto, const void *data, case OUT_RAWDATA: if (segment != NO_SEG) - nasm_panic(0, "OUT_RAWDATA with other than NO_SEG"); + nasm_panic("OUT_RAWDATA with other than NO_SEG"); elf_sect_write(s, data, size); break; @@ -1366,7 +1366,7 @@ static void elfx32_out(int32_t segto, const void *data, elf_add_reloc(s, segment, addr, R_X86_64_64); break; default: - nasm_panic(0, "internal error elfx32-hpa-871"); + nasm_panic("internal error elfx32-hpa-871"); break; } addr = 0; @@ -1424,7 +1424,7 @@ static void elfx32_out(int32_t segto, const void *data, addr = 0; break; default: - nasm_panic(0, "internal error elfx32-hpa-903"); + nasm_panic("internal error elfx32-hpa-903"); break; } } else if (wrt == elf_plt_sect + 1) { @@ -1452,7 +1452,7 @@ static void elfx32_out(int32_t segto, const void *data, rel12adr: addr = *(int64_t *)data - size; if (segment == segto) - nasm_panic(0, "intra-segment OUT_REL1ADR"); + nasm_panic("intra-segment OUT_REL1ADR"); if (segment == NO_SEG) { /* Do nothing */ } else if (segment % 2) { @@ -1473,7 +1473,7 @@ rel12adr: case OUT_REL4ADR: addr = *(int64_t *)data - size; if (segment == segto) - nasm_panic(0, "intra-segment OUT_REL4ADR"); + nasm_panic("intra-segment OUT_REL4ADR"); if (segment == NO_SEG) { /* Do nothing */ } else if (segment % 2) { diff --git a/output/outieee.c b/output/outieee.c index f2ff61f1..211cdaba 100644 --- a/output/outieee.c +++ b/output/outieee.c @@ -405,7 +405,7 @@ static void ieee_out(int32_t segto, const void *data, if (!any_segs) { int tempint; /* ignored */ if (segto != ieee_segment("__NASMDEFSEG", 2, &tempint)) - nasm_panic(0, "strange segment conditions in IEEE driver"); + nasm_panic("strange segment conditions in IEEE driver"); } /* @@ -415,7 +415,7 @@ static void ieee_out(int32_t segto, const void *data, if (seg->index == segto) break; if (!seg) - nasm_panic(0, "code directed to nonexistent segment?"); + nasm_panic("code directed to nonexistent segment?"); if (type == OUT_RAWDATA) { ucdata = data; @@ -521,8 +521,7 @@ static void ieee_write_fixup(int32_t segment, int32_t wrt, } } else - nasm_panic(0, - "unrecognised WRT value in ieee_write_fixup"); + nasm_panic("unrecognised WRT value in ieee_write_fixup"); } else nasm_error(ERR_NONFATAL, "target of WRT must be a section "); } @@ -563,8 +562,7 @@ static void ieee_write_fixup(int32_t segment, int32_t wrt, */ if (eb) { if (realtype == OUT_REL2ADR || realtype == OUT_REL4ADR) { - nasm_panic(0, - "Segment of a rel not supported in ieee_write_fixup"); + nasm_panic("Segment of a rel not supported in ieee_write_fixup"); } else { /* If we want the segment */ s.ftype = FT_EXTSEG; @@ -574,8 +572,7 @@ static void ieee_write_fixup(int32_t segment, int32_t wrt, } else /* If we get here the seg value doesn't make sense */ - nasm_panic(0, - "unrecognised segment value in ieee_write_fixup"); + nasm_panic("unrecognised segment value in ieee_write_fixup"); } } else { @@ -629,8 +626,7 @@ static void ieee_write_fixup(int32_t segment, int32_t wrt, } else /* If we get here the seg value doesn't make sense */ - nasm_panic(0, - "unrecognised segment value in ieee_write_fixup"); + nasm_panic("unrecognised segment value in ieee_write_fixup"); } } if (size != 2 && s.ftype == FT_SEG) @@ -969,7 +965,7 @@ static void ieee_write_file(void) if (seg->index == ieee_entry_seg) break; if (!seg) - nasm_panic(0, "Start address records are incorrect"); + nasm_panic("Start address records are incorrect"); else ieee_putascii("ASG,R%X,%lX,+.\n", seg->ieee_index, ieee_entry_ofs); @@ -1332,7 +1328,7 @@ static void dbgls_linnum(const char *lnfname, int32_t lineno, int32_t segto) if (!any_segs) { int tempint; /* ignored */ if (segto != ieee_segment("__NASMDEFSEG", 2, &tempint)) - nasm_panic(0, "strange segment conditions in OBJ driver"); + nasm_panic("strange segment conditions in OBJ driver"); } /* @@ -1342,7 +1338,7 @@ static void dbgls_linnum(const char *lnfname, int32_t lineno, int32_t segto) if (seg->index == segto) break; if (!seg) - nasm_panic(0, "lineno directed to nonexistent segment?"); + nasm_panic("lineno directed to nonexistent segment?"); for (fn = fnhead; fn; fn = fn->next) { if (!nasm_stricmp(lnfname, fn->name)) diff --git a/output/outmacho.c b/output/outmacho.c index 4d41a1f7..ddb362d6 100644 --- a/output/outmacho.c +++ b/output/outmacho.c @@ -643,7 +643,7 @@ static void macho_output(int32_t secto, const void *data, /* should never happen */ if (!s) - nasm_panic(0, "text section not found"); + nasm_panic("text section not found"); } /* debug code generation only for sections tagged with @@ -1146,7 +1146,7 @@ static void macho_symdef(char *name, int32_t section, int64_t offset, /* give an error on unfound section if it's not an ** external or common symbol (assemble_file() does a ** seg_alloc() on every call for them) */ - nasm_panic(0, "in-file index for section %d not found, is_global = %d", section, is_global); + nasm_panic("in-file index for section %d not found, is_global = %d", section, is_global); break; } } @@ -1339,7 +1339,7 @@ static void macho_calculate_sizes (void) } if (seg_nsects > MAX_SECT) { - nasm_fatal(0, "MachO output is limited to %d sections\n", + nasm_fatal("MachO output is limited to %d sections\n", MAX_SECT); } diff --git a/output/outobj.c b/output/outobj.c index eda28e6a..347e96f9 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -839,7 +839,7 @@ static void obj_deflabel(char *name, int32_t segment, if (!any_segs && segment == first_seg) { int tempint; /* ignored */ if (segment != obj_segment("__NASMDEFSEG", 2, &tempint)) - nasm_panic(0, "strange segment conditions in OBJ driver"); + nasm_panic("strange segment conditions in OBJ driver"); } for (seg = seghead; seg && is_global; seg = seg->next) @@ -1035,7 +1035,7 @@ static void obj_out(int32_t segto, const void *data, if (!any_segs) { int tempint; /* ignored */ if (segto != obj_segment("__NASMDEFSEG", 2, &tempint)) - nasm_panic(0, "strange segment conditions in OBJ driver"); + nasm_panic("strange segment conditions in OBJ driver"); } /* @@ -1045,7 +1045,7 @@ static void obj_out(int32_t segto, const void *data, if (seg->index == segto) break; if (!seg) - nasm_panic(0, "code directed to nonexistent segment?"); + nasm_panic("code directed to nonexistent segment?"); orp = seg->orp; orp->parm[0] = seg->currentpos; @@ -1213,7 +1213,7 @@ static void obj_write_fixup(ObjRecord * orp, int bytes, locat = FIX_16_SELECTOR; seg--; if (bytes != 2) - nasm_panic(0, "OBJ: 4-byte segment base fixup got" + nasm_panic("OBJ: 4-byte segment base fixup got" " through sanity check"); } else { base = false; @@ -1259,8 +1259,7 @@ static void obj_write_fixup(ObjRecord * orp, int bytes, if (eb) method = 6, e = eb->exts[i], tidx = e->index; else - nasm_panic(0, - "unrecognised segment value in obj_write_fixup"); + nasm_panic("unrecognised segment value in obj_write_fixup"); } } @@ -1318,8 +1317,7 @@ static void obj_write_fixup(ObjRecord * orp, int bytes, if (eb) method |= 0x20, fidx = eb->exts[i]->index; else - nasm_panic(0, - "unrecognised WRT value in obj_write_fixup"); + nasm_panic("unrecognised WRT value in obj_write_fixup"); } } } @@ -1467,7 +1465,7 @@ static int32_t obj_segment(char *name, int pass, int *bits) if (!strcmp(grp->name, "FLAT")) break; if (!grp) - nasm_panic(0, "failure to define FLAT?!"); + nasm_panic("failure to define FLAT?!"); } seg->grp = grp; } else if (!nasm_strnicmp(p, "class=", 6)) @@ -2518,7 +2516,7 @@ static void dbgbi_linnum(const char *lnfname, int32_t lineno, int32_t segto) if (!any_segs) { int tempint; /* ignored */ if (segto != obj_segment("__NASMDEFSEG", 2, &tempint)) - nasm_panic(0, "strange segment conditions in OBJ driver"); + nasm_panic("strange segment conditions in OBJ driver"); } /* @@ -2528,7 +2526,7 @@ static void dbgbi_linnum(const char *lnfname, int32_t lineno, int32_t segto) if (seg->index == segto) break; if (!seg) - nasm_panic(0, "lineno directed to nonexistent segment?"); + nasm_panic("lineno directed to nonexistent segment?"); /* for (fn = fnhead; fn; fn = fnhead->next) */ for (fn = fnhead; fn; fn = fn->next) /* fbk - Austin Lunnen - John Fine */ diff --git a/output/outrdf2.c b/output/outrdf2.c index fa0886a7..456d1bdf 100644 --- a/output/outrdf2.c +++ b/output/outrdf2.c @@ -145,9 +145,8 @@ static void rdf2_init(void) segdata = seg_alloc(); segbss = seg_alloc(); if (segtext != 0 || segdata != 2 || segbss != 4) - nasm_panic(0, - "rdf segment numbers not allocated as expected (%d,%d,%d)", - segtext, segdata, segbss); + nasm_panic("rdf segment numbers not allocated as expected (%d,%d,%d)", + segtext, segdata, segbss); bsslength = 0; headerlength = 0; } @@ -227,7 +226,7 @@ static int32_t rdf2_section_names(char *name, int pass, int *bits) code = 3; } if (nsegments == RDF_MAXSEGS) { - nasm_fatal(0, "reached compiled-in maximum segment limit (%d)", + nasm_fatal("reached compiled-in maximum segment limit (%d)", RDF_MAXSEGS); return NO_SEG; } @@ -235,7 +234,7 @@ static int32_t rdf2_section_names(char *name, int pass, int *bits) segments[nsegments].segname = nasm_strdup(name); i = seg_alloc(); if (i % 2 != 0) - nasm_panic(0, "seg_alloc() returned odd number"); + nasm_panic("seg_alloc() returned odd number"); segments[nsegments].segnumber = i >> 1; segments[nsegments].segtype = code; segments[nsegments].segreserved = reserved; @@ -497,7 +496,7 @@ static void membufwrite(int segment, const void *data, int bytes) break; } if (i == nsegments) - nasm_panic(0, "can't find segment %d", segment); + nasm_panic("can't find segment %d", segment); if (bytes < 0) { b = buf; @@ -520,7 +519,7 @@ static int getsegmentlength(int segment) break; } if (i == nsegments) - nasm_panic(0, "can't find segment %d", segment); + nasm_panic("can't find segment %d", segment); return segments[i].seglength; } @@ -596,7 +595,7 @@ static void rdf2_out(int32_t segto, const void *data, membufwrite(segto, databuf, asize); } else if (type == OUT_REL2ADR) { if (segment == segto) - nasm_panic(0, "intra-segment OUT_REL2ADR"); + nasm_panic("intra-segment OUT_REL2ADR"); rr.reclen = 8; rr.offset = getsegmentlength(segto); /* current offset */ @@ -628,9 +627,9 @@ static void rdf2_out(int32_t segto, const void *data, membufwrite(segto, &rr.offset, -2); } else if (type == OUT_REL4ADR) { if ((segment == segto) && (globalbits != 64)) - nasm_panic(0, "intra-segment OUT_REL4ADR"); + nasm_panic("intra-segment OUT_REL4ADR"); if (segment != NO_SEG && segment % 2) { - nasm_panic(0, "erm... 4 byte segment base ref?"); + nasm_panic("erm... 4 byte segment base ref?"); } rr.type = RDFREC_RELOC; /* type signature */ diff --git a/rdoff/rdflib.c b/rdoff/rdflib.c index b85b383f..8dbff4af 100644 --- a/rdoff/rdflib.c +++ b/rdoff/rdflib.c @@ -374,7 +374,7 @@ int main(int argc, char **argv) /* check against desired name */ if (!strcmp(buf, argv[3])) { if (fread(p = rdbuf, 1, sizeof(rdbuf), fptmp) < 10) { - nasm_fatal(0, "short read on input"); + nasm_fatal("short read on input"); } l = *(int32_t *)(p + 6); fseek(fptmp, l, SEEK_CUR); diff --git a/stdlib/vsnprintf.c b/stdlib/vsnprintf.c index 5a600fc7..ea83921c 100644 --- a/stdlib/vsnprintf.c +++ b/stdlib/vsnprintf.c @@ -26,15 +26,14 @@ int vsnprintf(char *str, size_t size, const char *format, va_list ap) int rv, bytes; if (size > BUFFER_SIZE) { - nasm_panic(ERR_NOFILE, - "vsnprintf: size (%d) > BUFFER_SIZE (%d)", + nasm_panic("vsnprintf: size (%d) > BUFFER_SIZE (%d)", size, BUFFER_SIZE); size = BUFFER_SIZE; } rv = vsprintf(snprintf_buffer, format, ap); if (rv >= BUFFER_SIZE) - nasm_panic(ERR_NOFILE, "vsnprintf buffer overflow"); + nasm_panic("vsnprintf buffer overflow"); if (size > 0) { if ((size_t)rv < size-1)