diff mbox series

[3/4] libvduse: Pass positive value to strerror()

Message ID 20220627090203.87-4-xieyongji@bytedance.com (mailing list archive)
State New, archived
Headers show
Series Fix some coverity issues on VDUSE | expand

Commit Message

Yongji Xie June 27, 2022, 9:02 a.m. UTC
The value passed to strerror() should be positive.
So let's fix it.

Fixes: Coverity CID 1490226, 1490223
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
---
 subprojects/libvduse/libvduse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Richard Henderson June 28, 2022, 12:26 a.m. UTC | #1
On 6/27/22 14:32, Xie Yongji wrote:
> The value passed to strerror() should be positive.
> So let's fix it.
> 
> Fixes: Coverity CID 1490226, 1490223
> Signed-off-by: Xie Yongji<xieyongji@bytedance.com>
> ---
>   subprojects/libvduse/libvduse.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Markus Armbruster June 29, 2022, 9:38 a.m. UTC | #2
Xie Yongji <xieyongji@bytedance.com> writes:

> The value passed to strerror() should be positive.
> So let's fix it.
>
> Fixes: Coverity CID 1490226, 1490223
> Signed-off-by: Xie Yongji <xieyongji@bytedance.com>

Reviewed-by: Markus Armbruster <armbru@redhat.com>
diff mbox series

Patch

diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvduse.c
index 1e36227388..1a5981445c 100644
--- a/subprojects/libvduse/libvduse.c
+++ b/subprojects/libvduse/libvduse.c
@@ -1257,7 +1257,7 @@  VduseDev *vduse_dev_create_by_name(const char *name, uint16_t num_queues,
     ret = vduse_dev_init(dev, name, num_queues, ops, priv);
     if (ret < 0) {
         fprintf(stderr, "Failed to init vduse device %s: %s\n",
-                name, strerror(ret));
+                name, strerror(-ret));
         free(dev);
         return NULL;
     }
@@ -1331,7 +1331,7 @@  VduseDev *vduse_dev_create(const char *name, uint32_t device_id,
     ret = vduse_dev_init(dev, name, num_queues, ops, priv);
     if (ret < 0) {
         fprintf(stderr, "Failed to init vduse device %s: %s\n",
-                name, strerror(ret));
+                name, strerror(-ret));
         goto err;
     }