From: Denis Vlasenko <vda@ilport.com.ua>
To: "linux-os \(Dick Johnson\)" <linux-os@analogic.com>
Cc: "moreau francis" <francis_moreau2000@yahoo.fr>,
"Linux kernel" <linux-kernel@vger.kernel.org>
Subject: Re: Use enum to declare errno values
Date: Thu, 24 Nov 2005 09:19:52 +0200 [thread overview]
Message-ID: <200511240919.52650.vda@ilport.com.ua> (raw)
In-Reply-To: <Pine.LNX.4.61.0511230958550.18085@chaos.analogic.com>
On Wednesday 23 November 2005 17:00, linux-os (Dick Johnson) wrote:
> On Wed, 23 Nov 2005, Denis Vlasenko wrote:
> > On Wednesday 23 November 2005 16:19, linux-os (Dick Johnson) wrote:
> >>> I'm just wondering why not declaring errno values using enumaration ?
> >>> It is just more convenient when debuging the kernel.
> >>
> >> There is an attempt to keep kernel errno values similar to
> >> user-mode errno values. This simplifies the user-kernel
> >> interface where the kernel will return -ERRNO and the user-mode
> >> code negates it and puts it into the user errno then sets the
> >> return value to -1 (a Unix convention).
> >>
> >> The user-mode errno's therefore must correspond. You can't
> >> expect the 'C' runtime libraries to be rebuilt and/or all the
> >> programs recompiled just because the kernel got changed so
> >> the errno's are hard-coded. 0 will always mean "no error" and
> >> 1 will always be EPERM, etc. There are error-codes that are
> >> the same number also, EWOULDBLOCK and EAGAIN are examples.
> >>
> >> So, you can't just auto-enumerate. If auto-enumeration isn't
> >> possible, then you might just as well use #define, which is
> >> what is done.
> >
> > ?!!
> >
> > enum {
> > one,
> > two,
> > ten = 10
> > };
>
> Did you BOTHER to read or you just picking a fight??
I was trying to say that since enum supports non-contiguous numbering,
any sequence of integer #defines can be trivially converted to enum
declaration:
...
#define ERESTARTSYS 512
#define ERESTARTNOINTR 513
#define ERESTARTNOHAND 514 /* restart if no handler.. */
#define ENOIOCTLCMD 515 /* No ioctl command */
#define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */
...
enum {
...
ERESTARTSYS = 512,
ERESTARTNOINTR = 513,
ERESTARTNOHAND = 514, /* restart if no handler.. */
ENOIOCTLCMD = 515, /* No ioctl command */
ERESTART_RESTARTBLOCK = 516, /* restart by calling sys_restart_syscall */
...
};
--
vda
next prev parent reply other threads:[~2005-11-24 7:20 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-23 13:24 moreau francis
2005-11-23 14:19 ` linux-os (Dick Johnson)
2005-11-23 14:24 ` Denis Vlasenko
2005-11-23 15:00 ` linux-os (Dick Johnson)
2005-11-24 7:19 ` Denis Vlasenko [this message]
2005-11-24 7:30 ` Paul Jackson
2005-11-24 7:37 ` Paul Jackson
2005-12-01 20:01 ` linux-os (Dick Johnson)
2005-12-02 6:49 ` Denis Vlasenko
2005-12-02 9:27 ` Coywolf Qi Hunt
2005-12-02 12:07 ` Denis Vlasenko
2005-12-02 12:18 ` Pekka Enberg
2005-12-02 12:56 ` Coywolf Qi Hunt
2005-12-02 13:20 ` Denis Vlasenko
2005-12-02 13:34 ` Pekka Enberg
2005-12-02 16:02 ` Bill Davidsen
2005-12-02 16:32 ` Coywolf Qi Hunt
2005-12-02 16:56 ` Vadim Lobanov
2005-12-04 13:10 ` Denis Vlasenko
2005-12-02 16:15 ` Bill Davidsen
2005-12-02 17:07 ` Coywolf Qi Hunt
2005-12-02 17:51 ` Steven Rostedt
2005-12-02 18:15 ` Bill Davidsen
2005-12-02 18:30 ` Horst von Brand
2005-11-23 14:27 ` Denis Vlasenko
2005-11-23 14:31 ` Denis Vlasenko
2005-11-23 15:15 ` Alan Cox
2005-11-23 15:44 ` moreau francis
2005-11-23 15:55 ` Nikita Danilov
2005-11-23 16:05 ` moreau francis
2005-11-23 16:24 ` Nikita Danilov
2005-11-23 16:42 ` moreau francis
2005-11-23 16:54 ` Nikita Danilov
2005-11-24 7:22 ` Denis Vlasenko
2005-11-23 17:35 ` Bill Davidsen
2005-11-24 9:43 ` Giuliano Pochini
2005-11-28 23:19 ` Bill Davidsen
2005-11-24 17:11 ` Ben Pfaff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200511240919.52650.vda@ilport.com.ua \
--to=vda@ilport.com.ua \
--cc=francis_moreau2000@yahoo.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-os@analogic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome