Opened 11 years ago

Closed 7 years ago

Last modified 7 years ago

#568 closed defect (fixed)

Errno error codes should not be negative

Reported by: Jiri Svoboda Owned by: Jiří Zárevúcky
Priority: major Milestone: 0.7.2
Component: helenos/unspecified Version: mainline
Keywords: Cc:
Blocker for: Depends on:
See also:

Description

In HelenOS errno.h (both kernel and user-space) defines error codes as negative (and EOK as zero). This conflicts with C standard errno.h that defines (many of the same) error codes as positive.

Since the goal is to try to align HelenOS kernel environment with C standard freestanding env. and userspace with C standard hosted env, this should be fixed.

Change History (5)

comment:1 by Jiri Svoboda, 11 years ago

This does not mean replacing every occurence of Exxx with -Exxx. On the contrary.

  • C-standard and POSIX-standard functions that return integer indicate error as -1/EOF and return the specific error via errno. errno is set to Exxx (not -Exxx)! The sign does not matter.
  • typical HelenOS functions indicate success by returning zero (EOK) and error by returing non-zero (Exxx). The sign does not matter.

The sign of error codes makes difference in two cases:

  • Error check in the form rc < 0 which should really be rc != 0/EOK. This just can happen in ported software (and thus we must change it to be compliant with standard), but we can fix it in original HelenOS code, if it is present anywhere (and thus we can change it).
  • A function that returns ≥0 for success and <0 for failure. I believe such design flawed. HelenOS native functions should split the ≥0 information into a separate output argument. I don't think it occurs much in HelenOS beyond VFS's open() et al. open() et. al should be fixed (make them either unix-conformant or create alternative, non-conflicting native interface)

comment:2 by Jiri Svoboda, 9 years ago

Applications compiled in POSIX compatibility mode (i.e. using libposix) have a big problem: Their Exxxx macros are nonnegative. Yet if they called a function from libc (or a function from libposix which just calls a function from libc) and an error occurs, errno will be set to a negative value. Then checks such as errno == Exxx will always fail, trying to human-print the errno value might fail too.

comment:3 by Jiří Zárevúcky, 7 years ago

Owner: set to Jiří Zárevúcky
Status: newaccepted

comment:4 by Jiří Zárevúcky, 7 years ago

Milestone: 0.7.2
Resolution: fixed
Status: acceptedclosed

comment:5 by Jiri Svoboda, 7 years ago

Note: See TracTickets for help on using tickets.