am7xxx: return EINVAL instead of ENOTSUP in am7xxx_get_device_info()
authorAntonio Ospite <ao2@ao2.it>
Tue, 27 Feb 2018 17:41:44 +0000 (18:41 +0100)
committerAntonio Ospite <ao2@ao2.it>
Tue, 27 Feb 2018 22:21:06 +0000 (23:21 +0100)
All the other error paths about invalid results or unsupported
operations return EINVAL, so remove the only instance of ENOTSUP.

Since the API documentation makes no promises on the actual negative
value of the returned error, this little change of behavior should be
fine.

src/am7xxx.c

index 4bf9abb..8573a59 100644 (file)
@@ -1240,8 +1240,8 @@ AM7XXX_PUBLIC int am7xxx_get_device_info(am7xxx_device *dev,
        if (h.packet_type != AM7XXX_PACKET_TYPE_DEVINFO) {
                error(dev->ctx, "expected packet type: %d, got %d instead!\n",
                      AM7XXX_PACKET_TYPE_DEVINFO, h.packet_type);
-               errno = ENOTSUP;
-               return -ENOTSUP;
+               errno = EINVAL;
+               return -EINVAL;
        }
 
        dev->device_info = malloc(sizeof(*dev->device_info));