Skip to content

Feature/lock acquire simple #53

Closed
wants to merge 5 commits into from

2 participants

@estenberg
CFEngine member

New, simpler locking function that does not require cleanup, nor promise or attribute structs.
Currently depends on (includes) error.h from pull request #52.

@dottedmag

This approach has the following problems:

  • If function returns cf_errid, then it is potentially returns any of the errors defined in the enum. This works to the some extent in Unix tradition with errno, but only due to the fact every function documents all the errors that could be returned, and the reasons why the errors are returned.

  • handling errors with switch() statement will either have to use "default:" case, which is error-prone, or huge list of case CFERRID_THIS_ONE: FatalError("can't happen").

  • It breaks if(fun()) convention, as the only cf_errid value which evaluates to False is CFERRID_SUCCESS. Negative error codes would help though, if(fun() >= 0) is more-or-less accepted convention.

  • if (fun() == CFERRID_SUCCESS) is ugly.

@estenberg
CFEngine member

Removing error handling and pushing this directly

@estenberg estenberg closed this Apr 27, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.