I think there is a 'bug' in the example. Or maybe I'm missing something.

On 17 Prosinec 2005, 18:40, Vesa Jääskeläinen napsal(a):
....
> ---
> /* Save possible old error message.  */
> grub_error_push ();
>
> /* Do your stuff here.  */
> call_possibly_failing_function ();
>
> if (grub_errno != GRUB_ERR_NONE)
>   {
>     /* Inform rest of the code that there is error (grub_errno
>        is set). */
>     return;
>   }
>
> /* Restore old error state by popping previous item from stack. */
> grub_error_pop ();
> ---
....

When grub_errno != GRUB_ERR_NONE (branching into the 'if'), then
there is no grub_error_pop() in the example.
If the whole thing will be called in a loop, then unwanted
stack overflow can simply occur.
There are two options how to solve this:
 * pop the stack (and choose which error should stay in grub_errno,
   handle (report) the other one)
 * write with BIG LETTERS to documentation of the function, that it
   may push and not pop grub_errno when it fails. And check all calls
   of this function, that this is handled properly (in code and/or in
   documentation).

-- 
                                            Tomas 'Ebi' Ebenlendr
                                            http://get.to/ebik



_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to