Hi tech@,
Using the GREATSCOTT[1] pattern to output in the ktrace signal handler,
dropping the need for an snprintf and the 8k stack buffer.
Brought to attention by BlackFrog on #openbsd-daily
Feedback, OK's?
Regards,
Adam
[1] - https://marc.info/?l=openbsd-tech&m=149613049920485&w=2
Index: ktrace.c
===================================================================
RCS file: /cvs/src/usr.bin/ktrace/ktrace.c,v
retrieving revision 1.33
diff -u -p -r1.33 ktrace.c
--- ktrace.c 18 Jul 2016 09:36:50 -0000 1.33
+++ ktrace.c 11 Jun 2017 16:58:32 -0000
@@ -250,10 +250,7 @@ usage(void)
static void
no_ktrace(int signo)
{
- char buf[8192];
-
- snprintf(buf, sizeof(buf),
-"error:\tktrace() system call not supported in the running
kernel\n\tre-compile kernel with 'option KTRACE'\n");
- write(STDERR_FILENO, buf, strlen(buf));
+#define NO_KTRACE "error:\tktrace() system call not supported in the running
kernel\n\tre-compile kernel with 'option KTRACE'\n"
+ write(STDERR_FILENO, NO_KTRACE, sizeof(NO_KTRACE));
_exit(1);
}