libdasd: fix ioctl macro to return also positive return codes

In case of an error the ioctl macro only returns errno to the calling
function.
This misses positive returncodes from ioctls.
Change the macro to also return positive return codes.

Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Stefan Haberland
2022-10-27 15:51:00 +02:00
committed by Jan Höppner
parent 4e28047eb4
commit 3aa7f6e298

View File

@@ -28,11 +28,13 @@
#define RUN_IOCTL(fd, req, argp) \
do { \
if (ioctl(fd, req, argp) != 0) { \
int err = errno; \
if (err != EBADF) \
int rc = ioctl(fd, req, argp); \
if (rc != 0) { \
if (rc == -1) \
rc = errno; \
if (rc != EBADF) \
dasd_close_device(fd); \
return err; \
return rc; \
} \
} while (0)