strerror takes a non-negative integer
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 8 Jun 2010 12:27:50 +0000 (14:27 +0200)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 8 Jun 2010 12:33:10 +0000 (14:33 +0200)
Negative error codes were passed untouched to strerror which then
reported an unknown error. Use the positive error code instead.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
main.c
media.c

diff --git a/main.c b/main.c
index b07454a..c946f2d 100644 (file)
--- a/main.c
+++ b/main.c
@@ -244,7 +244,7 @@ static int set_format(struct media_entity_pad *pad, struct v4l2_mbus_framefmt *f
        ret = v4l2_subdev_set_format(pad->entity, format, pad->index,
                                     V4L2_SUBDEV_FORMAT_ACTIVE);
        if (ret < 0) {
-               printf("Unable to set format: %s(%u)", strerror(ret), ret);
+               printf("Unable to set format: %s (%d)\n", strerror(-ret), ret);
                return ret;
        }
 
diff --git a/media.c b/media.c
index f20f061..59a3a58 100644 (file)
--- a/media.c
+++ b/media.c
@@ -503,7 +503,7 @@ struct media_device *media_open(const char *name, int verbose)
        ret = media_enum_entities(media);
        if (ret < 0) {
                printf("%s: Unable to enumerate entities for device %s (%s)\n",
-                       __func__, name, strerror(ret));
+                       __func__, name, strerror(-ret));
                media_close(media);
                return NULL;
        }