From 031e5cce385d3f96b1caa1d53495332a7eb03749 Mon Sep 17 00:00:00 2001 From: Steve McIntyre Date: Tue, 23 Mar 2021 23:49:46 +0000 Subject: New upstream version 15.3 --- errlog.c | 61 +++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 24 deletions(-) (limited to 'errlog.c') diff --git a/errlog.c b/errlog.c index 18be4822..cc6a89f5 100644 --- a/errlog.c +++ b/errlog.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: BSD-2-Clause-Patent /* * errlog.c - * Copyright 2017 Peter Jones - * - * Distributed under terms of the GPLv3 license. + * Copyright Peter Jones */ #include "shim.h" @@ -10,34 +9,42 @@ static CHAR16 **errs = NULL; static UINTN nerrs = 0; -EFI_STATUS -VLogError(const char *file, int line, const char *func, CHAR16 *fmt, va_list args) +EFI_STATUS EFIAPI +vdprint_(const CHAR16 *fmt, const char *file, int line, const char *func, + ms_va_list args) { - va_list args2; - UINTN size = 0, size2; - CHAR16 **newerrs; + ms_va_list args2; + EFI_STATUS efi_status = EFI_SUCCESS; + + if (verbose) { + ms_va_copy(args2, args); + console_print(L"%a:%d:%a() ", file, line, func); + efi_status = VPrint(fmt, args2); + ms_va_end(args2); + } + return efi_status; +} - size = SPrint(NULL, 0, L"%a:%d %a() ", file, line, func); - va_copy(args2, args); - size2 = VSPrint(NULL, 0, fmt, args2); - va_end(args2); +EFI_STATUS EFIAPI +VLogError(const char *file, int line, const char *func, const CHAR16 *fmt, + ms_va_list args) +{ + ms_va_list args2; + CHAR16 **newerrs; newerrs = ReallocatePool(errs, (nerrs + 1) * sizeof(*errs), (nerrs + 3) * sizeof(*errs)); if (!newerrs) return EFI_OUT_OF_RESOURCES; - newerrs[nerrs] = AllocatePool(size*2+2); + newerrs[nerrs] = PoolPrint(L"%a:%d %a() ", file, line, func); if (!newerrs[nerrs]) return EFI_OUT_OF_RESOURCES; - newerrs[nerrs+1] = AllocatePool(size2*2+2); + ms_va_copy(args2, args); + newerrs[nerrs+1] = VPoolPrint(fmt, args2); if (!newerrs[nerrs+1]) return EFI_OUT_OF_RESOURCES; - - SPrint(newerrs[nerrs], size*2+2, L"%a:%d %a() ", file, line, func); - va_copy(args2, args); - VSPrint(newerrs[nerrs+1], size2*2+2, fmt, args2); - va_end(args2); + ms_va_end(args2); nerrs += 2; newerrs[nerrs] = NULL; @@ -46,19 +53,25 @@ VLogError(const char *file, int line, const char *func, CHAR16 *fmt, va_list arg return EFI_SUCCESS; } -EFI_STATUS -LogError_(const char *file, int line, const char *func, CHAR16 *fmt, ...) +EFI_STATUS EFIAPI +LogError_(const char *file, int line, const char *func, const CHAR16 *fmt, ...) { - va_list args; + ms_va_list args; EFI_STATUS efi_status; - va_start(args, fmt); + ms_va_start(args, fmt); efi_status = VLogError(file, line, func, fmt, args); - va_end(args); + ms_va_end(args); return efi_status; } +VOID +LogHexdump_(const char *file, int line, const char *func, const void *data, size_t sz) +{ + hexdumpat(file, line, func, data, sz, 0); +} + VOID PrintErrors(VOID) { -- cgit v1.2.3