From e7ec655415dfacc8dacdc56bc28ee723cb8056d0 Mon Sep 17 00:00:00 2001 From: Scott Haseley Date: Mon, 29 Feb 2016 16:43:35 -0500 Subject: [PATCH] Removed printsf, an unused secure testing printf variant. This variant does not apply now that each test has its own secret. Fixed unused variable in libtest161 in kernel compiles. --- common/libc/printf/tprintf.c | 29 ++++++---------------------- common/libtest161/test161.c | 4 +++- userland/include/stdio.h | 1 - userland/lib/hostcompat/hostcompat.h | 2 -- 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/common/libc/printf/tprintf.c b/common/libc/printf/tprintf.c index f754453..06290bd 100644 --- a/common/libc/printf/tprintf.c +++ b/common/libc/printf/tprintf.c @@ -16,9 +16,9 @@ tprintf(const char *fmt, ...) int chars; va_list ap; - if (strcmp(SECRET, "") != 0) { - return 0; - } +#ifdef SECRET_TESTING + return 0; +#endif va_start(ap, fmt); chars = vprintf(fmt, ap); @@ -34,9 +34,9 @@ nprintf(const char *fmt, ...) int chars; va_list ap; - if (strcmp(SECRET, "") == 0) { - return 0; - } +#ifndef SECRET_TESTING + return 0; +#endif va_start(ap, fmt); chars = vprintf(fmt, ap); @@ -44,20 +44,3 @@ nprintf(const char *fmt, ...) return chars; } - -/* printf variant that prepends the kernel secret */ -int -printsf(const char *fmt, ...) -{ - int chars; - va_list ap; - - if (strcmp(SECRET, "") != 0) { - printf("%s: ", SECRET); - } - va_start(ap, fmt); - chars = vprintf(fmt, ap); - va_end(ap); - - return chars; -} diff --git a/common/libtest161/test161.c b/common/libtest161/test161.c index a3152df..1404229 100644 --- a/common/libtest161/test161.c +++ b/common/libtest161/test161.c @@ -19,13 +19,15 @@ // Hack for allocating userspace memory without malloc. #define BUFFER_SIZE 4096 + +#ifndef _KERNEL static char temp_buffer[BUFFER_SIZE]; static char write_buffer[BUFFER_SIZE]; +#endif static inline void * _alloc(size_t size) { #ifdef _KERNEL - (void)temp_buffer; return kmalloc(size); #else (void)size; diff --git a/userland/include/stdio.h b/userland/include/stdio.h index 772277f..e8518ea 100644 --- a/userland/include/stdio.h +++ b/userland/include/stdio.h @@ -60,7 +60,6 @@ int vsnprintf(char *buf, size_t len, const char *fmt, __va_list ap); int tprintf(const char *fmt, ...); int nprintf(const char *fmt, ...); -int printsf(const char *fmt, ...); /* Print the argument string and then a newline. Returns 0 or -1 on error. */ int puts(const char *); diff --git a/userland/lib/hostcompat/hostcompat.h b/userland/lib/hostcompat/hostcompat.h index 1f25af9..8e37e7b 100644 --- a/userland/lib/hostcompat/hostcompat.h +++ b/userland/lib/hostcompat/hostcompat.h @@ -39,8 +39,6 @@ time_t __time(time_t *secs, unsigned long *nsecs); int tprintf(const char *fmt, ...); int nprintf(const char *fmt, ...); -int printsf(const char *fmt, ...); - #ifdef DECLARE_NTOHLL uint64_t ntohll(uint64_t);