Fork us on GitHub Follow us on Google+ Follow us on Facebook Follow us on Twitter

Opened 5 years ago

Closed 14 months ago

Last modified 14 months 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 Changed 5 years ago by Jiri Svoboda

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 Changed 3 years ago by Jiri Svoboda

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 Changed 14 months ago by Jiří Zárevúcky

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

comment:4 Changed 14 months ago by Jiří Zárevúcky

Milestone: 0.7.2
Resolution: fixed
Status: acceptedclosed

comment:5 Changed 14 months ago by Jiri Svoboda

Note: See TracTickets for help on using tickets.