The pattern how I write C function is the following:
```c
int project_module_verb(module_t speaking_name, args) {
int rv = 0;
// If precondition checks fail, set just return
<preconditon checks>
// if something goes wrong here, set error code and goto out.
<alter state>
out:
if (rv < 0) {
<recover to error state>
}
<cleanup>
return rv;
}
```
`rv` stands for "return value", a pattern that I got used to while working on xbps.