[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

errno handling

From: Carles Pina i Estany
Subject: errno handling
Date: Sun, 22 Nov 2009 17:19:19 +0000
User-agent: Mutt/1.5.20 (2009-06-14)


Last night I spent some time with a confussion that maybe it can be
avoided (or maybe not).

Let's say that a module calls grub_file_open and it fails (file doesn't
exist or whatever). grub_errno is setted up.

This module is not resetting grub_errno and makes another call to
grub_file_open with a valid file. But grub_file_open does:

  device_name = grub_file_get_device_name (name);
  if (grub_errno)
    return 0;
(without resetting grub_errno before or in grub_file_get_device_name)

So caling grub_file_open with an invalid file name and then with valid
one returns error two times.

I was expecting the library functions to setup errno if there is
some error. But not that the functions behaves different in 
function of the previous errno. Mainly because this can cause
some strange effects changing the code (adding some call before
that changes errno and the user is not resetting)

I would reset errno at beginning of grub_file_open, and other places.

I've search some documentation about the errno standard without
succeeding, I'm sure that here there is people who is more
familiar with it.

Carles Pina i Estany

reply via email to

[Prev in Thread] Current Thread [Next in Thread]