Don't use printf %n.

Reported by naddy@

This is the last known offender at *build time*.  We now need runtime
reports.
This commit is contained in:
jca 2021-08-31 18:01:10 +00:00
parent 0cd5071fba
commit 234bdcd461
2 changed files with 31 additions and 2 deletions

View File

@ -1,11 +1,11 @@
# $OpenBSD: Makefile,v 1.14 2021/08/17 20:22:02 naddy Exp $
# $OpenBSD: Makefile,v 1.15 2021/08/31 18:01:10 jca Exp $
# Should work on all other archs.
NOT_FOR_ARCHS = aarch64 m88k mips64 powerpc64 riscv64
COMMENT = GNU Pascal compiler
DISTNAME = gpc-20070904
REVISION = 9
REVISION = 10
CATEGORIES = lang
HOMEPAGE = https://www.gnu-pascal.de/gpc/h-index.html

View File

@ -0,0 +1,29 @@
$OpenBSD: patch-gcc_genmodes_c,v 1.1 2021/08/31 18:01:10 jca Exp $
Don't use printf %n.
Index: gcc/genmodes.c
--- gcc/genmodes.c.orig
+++ gcc/genmodes.c
@@ -786,7 +786,9 @@ calc_wider_mode (void)
#define tagged_printf(FMT, ARG, TAG) do { \
int count_; \
- printf (" " FMT ",%n", ARG, &count_); \
+ count_ = printf (" " FMT ",", ARG); \
+ if (count_ < 0) \
+ count_ = 0; \
printf ("%*s/* %s */\n", 27 - count_, "", TAG); \
} while (0)
@@ -821,7 +823,9 @@ enum machine_mode\n{");
for (m = modes[c]; m; m = m->next)
{
int count_;
- printf (" %smode,%n", m->name, &count_);
+ count_ = printf (" %smode,", m->name);
+ if (count_ < 0)
+ count_ = 0;
printf ("%*s/* %s:%d */\n", 27 - count_, "",
trim_filename (m->file), m->line);
}