Menu

#2 statuses and operation descriptors

next release
open
vitki
5
2008-06-22
2008-06-22
vitki
No

The status_t type is too oversimplified. Only two values are allowed: success (OK) or failure (ERROR). Therefore throughout the library we return errors in a separate output argument. The syntax

oret_t ret = owatchSomething(..., int *error_code_ptr)

is overly clumsy. We'd better follow the POSIX guidelines for thread-safe routines: the return value also indicates an error. If the value is 0, then success. If the value is negative, it is the error code. Positive values are not allowed.

Same thing with operation identifiers. They usually involve two calls: create operation and check operation, that is:

owop_t op = owatchCreateSomeOp(...)
oret_t owatchCheckOp(op, ..., int *error_code_ptr)

First of all, if the operation creation fails, we cannot return the reason code (or should we add the error_code_ptr to the creator prototype as well ?). It would be cool if owop_t could manifest errors. The rule for owop_t could be:

0 (OK)
just success
> 0
operation descriptor
< 0
error code, including:

* -1 (ERROR) - unspecified error
* < -1 - specific error code

Discussion


Log in to post a comment.