qbe

Internal scc patchset buffer for QBE
Log | Files | Refs | README | LICENSE

commit 011dfc839d40c735fb63474aa6d5e1412b823a3b
parent 6f45894c7f5f145208e0fce4344b2b87eb8ae722
Author: Quentin Carbonneaux <quentin@c9x.me>
Date:   Thu, 16 Mar 2023 16:22:11 +0100

silence format warning more reliably

Diffstat:
MMakefile | 3+--
Mall.h | 1+
Mamd64/sysv.c | 2+-
Marm64/abi.c | 2+-
Mrega.c | 2+-
Mutil.c | 10++++++++++
6 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile @@ -13,8 +13,7 @@ OBJ = $(COMMOBJ) $(AMD64OBJ) $(ARM64OBJ) $(RV64OBJ) SRCALL = $(OBJ:.o=.c) -CFLAGS = $(CPPFLAGS) -std=c99 -g \ - -Wall -Wextra -Wpedantic -Wno-format-truncation +CFLAGS = -std=c99 -g -Wall -Wextra -Wpedantic qbe: $(OBJ) $(CC) $(LDFLAGS) $(OBJ) -o $@ diff --git a/all.h b/all.h @@ -458,6 +458,7 @@ void freeall(void); void *vnew(ulong, size_t, Pool); void vfree(void *); void vgrow(void *, ulong); +void fmt(char *, char *, ...); uint32_t intern(char *); char *str(uint32_t); int argcls(Ins *, int); diff --git a/amd64/sysv.c b/amd64/sysv.c @@ -512,7 +512,7 @@ split(Fn *fn, Blk *b) idup(&bn->ins, curi, bn->nins); curi = &insb[NIns]; bn->visit = ++b->visit; - snprintf(bn->name, NString, "%s.%d", b->name, b->visit); + fmt(bn->name, "%s.%d", b->name, b->visit); bn->loop = b->loop; bn->link = b->link; b->link = bn; diff --git a/arm64/abi.c b/arm64/abi.c @@ -547,7 +547,7 @@ split(Fn *fn, Blk *b) idup(&bn->ins, curi, bn->nins); curi = &insb[NIns]; bn->visit = ++b->visit; - snprintf(bn->name, NString, "%s.%d", b->name, b->visit); + fmt(bn->name, "%s.%d", b->name, b->visit); bn->loop = b->loop; bn->link = b->link; b->link = bn; diff --git a/rega.c b/rega.c @@ -670,7 +670,7 @@ rega(Fn *fn) b1->link = blist; blist = b1; fn->nblk++; - snprintf(b1->name, NString, "%s_%s", b->name, s->name); + fmt(b1->name, "%s_%s", b->name, s->name); b1->nins = &insb[NIns] - curi; stmov += b1->nins; stblk += 1; diff --git a/util.c b/util.c @@ -154,6 +154,16 @@ vgrow(void *vp, ulong len) *(Vec **)vp = v1; } +void +fmt(char *dst, char *s, ...) +{ + va_list ap; + + va_start(ap, s); + vsnprintf(dst, NString, s, ap); + va_end(ap); +} + uint32_t intern(char *s) {