Two common conventions for functions returning int that may fail: 1. Return non-negative value on success, -1 value on failure.
2. Return non-negative value on success, a negative errno error code on failure. Both work. But mixing them in the same function is not a good idea. Suspicious functions in block/sheepdog.c include: * read_write_object() May return 0, -EIO or the value of do_req(). do_req() returns srco.ret. do_co_req() may set it to the value of send_co_req(). I don't think that one returns -errno. * do_sd_create() May return 0, -EIO or the value of connect_to_sdog(). I don't think the latter returns -errno. I suspect there are more. Please audit the file for this kind of mistake. Good opportunity to document for each function what it's supposed to return.