/* err.c - error handling routines */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2005,2007,2008 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdarg.h>
static struct
{
static int grub_error_stack_pos;
static int grub_error_stack_assert;
{
grub_errno = n;
return n;
}
void
{
grub_abort ();
}
void
grub_error_push (void)
{
/* Only add items to stack, if there is enough room. */
{
/* Copy active error message to stack. */
sizeof (grub_errmsg));
/* Advance to next error stack position. */
}
else
{
/* There is no room for new error message. Discard new error message
and mark error stack assertion flag. */
}
/* Allow further operation of other components by resetting
active errno to GRUB_ERR_NONE. */
}
int
grub_error_pop (void)
{
if (grub_error_stack_pos > 0)
{
/* Pop error message from error stack to current active error. */
sizeof (grub_errmsg));
return 1;
}
else
{
/* There is no more items on error stack, reset to no error state. */
return 0;
}
}
void
grub_print_error (void)
{
/* Print error messages in reverse order. First print active error message
and then empty error stack. */
do
{
if (grub_errno != GRUB_ERR_NONE)
{
}
}
while (grub_error_pop ());
/* If there was an assert while using error stack, report about it. */
{
grub_err_printf ("assert: error stack overflow detected!\n");
}
}