]> www.infradead.org Git - users/sagi/libnvme.git/commit
mi: make return values + errno consistent across error paths
authorJeremy Kerr <jk@codeconstruct.com.au>
Thu, 7 Jul 2022 07:06:19 +0000 (15:06 +0800)
committerJeremy Kerr <jk@codeconstruct.com.au>
Thu, 7 Jul 2022 08:19:15 +0000 (16:19 +0800)
commit44736619ff43a3bce63540044bf745060f98ae3e
tree4bf074c4342e6daf990141a9c172d911be3f1c78
parentb4a9b5248f2407bac22ffb44af4360a475d28236
mi: make return values + errno consistent across error paths

This change unifies and documents the error return values for the MI
implementation. This gives us the following semantics:

 - zero on success

 - -1 for errors in the MI communication with an endpoint, with errno
   set accordingly

 - positive values where the MI communication succeeded, but we received
   an error response from the endpoint. The return value will be that
   from the MI response status field, and should correspond to one of
   the nvme_mi_resp_status values.

We add these semantics to the file-level kdoc comments in mi.h.

Most of the changes here are replacing the negative-errno returns:

    return -EIO;

with:

    errno = EIO;
    return -1;

but there are a few slightly-more-involved changes where we need to
preserve errno across a cleanup/log that might clobber it.

For the dbus code in mi-mctp.c, we need to convert the sd_bus convention of
negative-errno values into errno; we can do most of these through the
dbus_err() helper.

Fixes: https://github.com/linux-nvme/libnvme/issues/417
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
src/nvme/mi-mctp.c
src/nvme/mi.c
src/nvme/mi.h