summaryrefslogtreecommitdiff
path: root/hurd/porting
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@schwinge.name>2010-03-28 21:48:46 +0200
committerThomas Schwinge <thomas@schwinge.name>2010-03-28 21:48:46 +0200
commit4b35fc7bdd7ab723cb3db8e9122ed08d996f33b4 (patch)
treee4bb2ffadd136ab05b8abc3c0fa9f305f8c360fe /hurd/porting
parent34794c7002f679ab9c2d076284ff58288224c47d (diff)
parent96611f76b833159bafeab3443229dfa690178d92 (diff)
Merge commit '96611f76b833159bafeab3443229dfa690178d92' into master-news_next
Conflicts: news/2010-03-31.mdwn
Diffstat (limited to 'hurd/porting')
-rw-r--r--hurd/porting/guidelines.mdwn37
1 files changed, 37 insertions, 0 deletions
diff --git a/hurd/porting/guidelines.mdwn b/hurd/porting/guidelines.mdwn
index bcfc8dd5..8dd27a52 100644
--- a/hurd/porting/guidelines.mdwn
+++ b/hurd/porting/guidelines.mdwn
@@ -232,3 +232,40 @@ Not implemented, not POSIX. Try to disable the feature in the package.
## <a name="parport"> <linux/parport.h> <linux/ppdev.h> </a>
There is no programming interface for the parallel port on GNU/Hurd yet.
+
+## <a name="errno"> `errno` values </a>
+
+When dealing with `errno`, you should always use the predefined error codes defined with the `E*` constants, instead of manually comparing/assigning/etc with their values.
+
+For example (C/C++):
+
+ /* check whether it does not exist */
+ if (errno == 2)
+ ...
+
+or Python:
+
+ # check whether it does not exist
+ try:
+ ...
+ except OSError, err:
+ err.errno == 2:
+ ...
+
+This is wrong, as [the actual values of the `E*` are unspecified (per POSIX)](http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_03.html#tag_02_03). You must always use the predefined constants for the possible errors.
+
+For example (C/C++):
+
+ /* check whether it does not exist */
+ if (errno == ENOENT)
+ ...
+
+With Python, you can use the [`errno` module](http://docs.python.org/library/errno.html) for the various constants:
+
+ # check whether it does not exist
+ try:
+ ...
+ except OSError, err:
+ import errno
+ err.errno == errno.ENOENT:
+ ...