2 * libefiboot - library for the manipulation of EFI boot variables
3 * Copyright 2012-2015 Red Hat, Inc.
4 * Copyright (C) 2000-2001 Dell Computer Corporation <Matt_Domsch@dell.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of the
9 * License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see
18 * <http://www.gnu.org/licenses/>.
22 #include "fix_coverity.h"
34 * GCC/Clang complains that we check for null if we have a nonnull attribute,
35 * even though older or other compilers might just ignore that attribute if
36 * they don't support it. Ugh.
38 #if defined(__clang__)
39 #pragma clang diagnostic ignored "-Wpointer-bool-conversion"
40 #elif defined(__GNUC__) && __GNUC__ >= 6
41 #pragma GCC diagnostic ignored "-Wnonnull-compare"
52 static error_table_entry *error_table;
53 static unsigned int current;
55 int PUBLIC NONNULL(2, 3, 4, 5, 6)
56 efi_error_get(unsigned int n,
57 char ** const filename,
58 char ** const function,
60 char ** const message,
64 if (!filename || !function || !line || !message || !error) {
72 *filename = error_table[n].filename;
73 *function = error_table[n].function;
74 *line = error_table[n].line;
75 *message = error_table[n].message;
76 *error = error_table[n].error;
81 int PUBLIC NONNULL(1, 2, 5) PRINTF(5, 6)
82 efi_error_set(const char *filename,
88 error_table_entry et = { 0, };
89 error_table_entry *table;
92 table = realloc(error_table, sizeof(et) * (current +1));
99 tmp = filename ? strdup(filename) : NULL;
104 tmp = function ? strdup(function) : NULL;
116 rc = vasprintf(&tmp, fmt, ap);
125 memcpy(&error_table[current], &et, sizeof(et));
139 void PUBLIC DESTRUCTOR
140 efi_error_clear(void)
143 for (unsigned int i = 0; i < current; i++) {
144 error_table_entry *et = &error_table[i];
153 memset(et, '\0', sizeof(*et));
161 static int efi_verbose;
162 static FILE *efi_errlog;
165 efi_get_logfile(void)
173 efi_set_verbose(int verbosity, FILE *errlog)
175 efi_verbose = verbosity;
181 efi_get_verbose(void)