Noticed this while reviewing the extensions-write-zeroes branch: we probably ought to audit errno usage, as I spotted several places that use an undefined value of errno. For example: if(expwrite(req->from, pkg->data, req->len, client, fua)) { DEBUG("Write failed: %m"); rep.error = nbd_errno(errno); This is assuming that expwrite() left a sane errno value, and that DEBUG() didn't clobber it. But a quick look at DEBUG() shows that it (can) call printf() (which can clobber errno), and a close look at expwrite() shows that there are error paths where errno is indeterminate (for example, expwrite() can return -1 if rawread_fully() fails, but rawread_fully() can call close() in between read() and returning a value, where close() can clobber errno). It may be smarter to have functions return an actual error value (or negative error value) instead of -1 on failure, rather than relying on errno remaining unchanged through all the interim code. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature