* grub-core/kern/err.c (GRUB_MAX_ERRMSG): Move to ...

* include/grub/err.h (GRUB_MAX_ERRMSG): ... here.
	* include/grub/err.h (grub_error_saved): New struct.
	(grub_errmsg): Make array size explicit.
	* include/grub/misc.h (grub_error_save): New function.
	(grub_error_load): Likewise.
	* grub-core/kern/err.c (grub_error_stack_items): Use grub_error_saved.
	(grub_error_push): Update `errno' member name.
	(grub_error_pop): Likewise
	* grub-core/net/tftp.c (tftp_data): New member save_err.
	(tftp_receive): Save error.
	(tftp_open): Restore error.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-02-05 10:24:53 +01:00
parent a51dab1328
commit aca002f7e4
5 changed files with 54 additions and 11 deletions

View file

@ -22,6 +22,8 @@
#include <grub/symbol.h>
#define GRUB_MAX_ERRMSG 256
typedef enum
{
GRUB_ERR_NONE = 0,
@ -70,8 +72,14 @@ typedef enum
}
grub_err_t;
struct grub_error_saved
{
grub_err_t grub_errno;
char errmsg[GRUB_MAX_ERRMSG];
};
extern grub_err_t EXPORT_VAR(grub_errno);
extern char EXPORT_VAR(grub_errmsg)[];
extern char EXPORT_VAR(grub_errmsg)[GRUB_MAX_ERRMSG];
grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *fmt, ...);
void EXPORT_FUNC(grub_fatal) (const char *fmt, ...) __attribute__ ((noreturn));

View file

@ -424,4 +424,19 @@ extern int EXPORT_VAR(grub_no_autoload);
#define grub_no_autoload 0
#endif
static inline void
grub_error_save (struct grub_error_saved *save)
{
grub_memcpy (save->errmsg, grub_errmsg, sizeof (save->errmsg));
save->grub_errno = grub_errno;
save->grub_errno = GRUB_ERR_NONE;
}
static inline void
grub_error_load (const struct grub_error_saved *save)
{
grub_memcpy (grub_errmsg, save->errmsg, sizeof (grub_errmsg));
grub_errno = save->grub_errno;
}
#endif /* ! GRUB_MISC_HEADER */