* 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.
+2012-02-05 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * 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.
+
2012-02-05 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/lib/i386/relocator16.S (grub_relocator16_start): Move switch
#include <stdarg.h>
#include <grub/i18n.h>
-#define GRUB_MAX_ERRMSG 256
#define GRUB_ERROR_STACK_SIZE 10
grub_err_t grub_errno;
char grub_errmsg[GRUB_MAX_ERRMSG];
int grub_err_printed_errors;
-static struct
-{
- grub_err_t errno;
- char errmsg[GRUB_MAX_ERRMSG];
-} grub_error_stack_items[GRUB_ERROR_STACK_SIZE];
+static struct grub_error_saved grub_error_stack_items[GRUB_ERROR_STACK_SIZE];
static int grub_error_stack_pos;
static int grub_error_stack_assert;
if (grub_error_stack_pos < GRUB_ERROR_STACK_SIZE)
{
/* Copy active error message to stack. */
- grub_error_stack_items[grub_error_stack_pos].errno = grub_errno;
+ grub_error_stack_items[grub_error_stack_pos].grub_errno = grub_errno;
grub_memcpy (grub_error_stack_items[grub_error_stack_pos].errmsg,
grub_errmsg,
sizeof (grub_errmsg));
/* Pop error message from error stack to current active error. */
grub_error_stack_pos--;
- grub_errno = grub_error_stack_items[grub_error_stack_pos].errno;
+ grub_errno = grub_error_stack_items[grub_error_stack_pos].grub_errno;
grub_memcpy (grub_errmsg,
grub_error_stack_items[grub_error_stack_pos].errmsg,
sizeof (grub_errmsg));
grub_uint64_t block;
grub_uint32_t block_size;
int have_oack;
+ struct grub_error_saved save_err;
grub_net_udp_socket_t sock;
grub_priority_queue_t pq;
} *tftp_data_t;
data->block = 0;
grub_netbuff_free (nb);
err = ack (data->sock, 0);
+ grub_error_save (&data->save_err);
if (err)
return err;
return GRUB_ERR_NONE;
}
return GRUB_ERR_NONE;
case TFTP_ERROR:
+ data->have_oack = 1;
grub_netbuff_free (nb);
- return grub_error (GRUB_ERR_IO, (char *) tftph->u.err.errmsg);
+ grub_error (GRUB_ERR_IO, (char *) tftph->u.err.errmsg);
+ grub_error_save (&data->save_err);
+ return GRUB_ERR_NONE;
default:
grub_netbuff_free (nb);
return GRUB_ERR_NONE;
}
if (!data->have_oack)
+ grub_error (GRUB_ERR_TIMEOUT, "Time out opening tftp.");
+ else
+ grub_error_load (&data->save_err);
+ if (grub_errno)
{
grub_net_udp_close (data->sock);
destroy_pq (data);
- return grub_error (GRUB_ERR_TIMEOUT, "Time out opening tftp.");
+ return grub_errno;
}
+
file->size = data->file_size;
return GRUB_ERR_NONE;
#include <grub/symbol.h>
+#define GRUB_MAX_ERRMSG 256
+
typedef enum
{
GRUB_ERR_NONE = 0,
}
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));
#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 */