From patchwork Wed Jul 6 09:56:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 1652909 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance-com.20210112.gappssmtp.com header.i=@bytedance-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=NgiFbY6e; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LdFy96g11z9s07 for ; Wed, 6 Jul 2022 20:24:01 +1000 (AEST) Received: from localhost ([::1]:45916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o92CN-0007Lb-Og for incoming@patchwork.ozlabs.org; Wed, 06 Jul 2022 06:23:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o91mJ-00048K-Fw for qemu-devel@nongnu.org; Wed, 06 Jul 2022 05:57:03 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:36662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o91mH-0004Pq-8v for qemu-devel@nongnu.org; Wed, 06 Jul 2022 05:57:03 -0400 Received: by mail-pj1-x1036.google.com with SMTP id z12-20020a17090a7b8c00b001ef84000b8bso9473852pjc.1 for ; Wed, 06 Jul 2022 02:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BREgwYiOvCEeIa/yhLtMhZ9xErLR13wbXi2KZC1QjzQ=; b=NgiFbY6e8msIWEHpuIPwylDeVBPYVwHyAiwIkiD+vGt6YMndQyQvtxiPHdkIezd4Pb SdpKcAB0AIOZl57luVmi6SsgVrBbDOVT3WbJg3SbnFRsEpyIG26ppzvFpA9qkTBDKoey hGW7sSVNWNSjdxorekBaWe9fXDkV8E67yvhfaaLSKmq91dpdt5qZ/9K8VjPAFJXMsPj5 J8ON5d4UXLNIuxFtq+GLSZyt7X1U/A//rIWXrAKGs0p55zsladSdy25teW9Lj+Q1+JrJ yfW4WyVnM5cdcMnOgTBaJA0CvSi9x/csSASpJfBYQqDMP+KDz/N93KXBjUMkD7KvhG2O txOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BREgwYiOvCEeIa/yhLtMhZ9xErLR13wbXi2KZC1QjzQ=; b=aQQz1EoN2u+KVRj0caLtrnXHqRLr+Dx50jNR3gk/mlLirwcYcurTT1WooRv421Zy2A s/D9VksZwPCbvPv8FKy1cSWQsKyh70+zLV/ObWonTswECBKz0Wedg4hsFB+qpryze6vq Y96EZBeFgBNlJP/tr9q2ESmQ7ezSkAiAfHa7C0tskFJVM8oWlWq00oJH/nIpgllItcpJ nC9u8cfcOUN9A+f/Ga67Rf6qR9uF1Q9/QZ4a878oqTKezpNzr+2tZ47yQoHuje4QkZo3 CdHxxVsV+poO07VMkhV5Grgd4UbbGUS5+qyBi8BXPh5Na1mKmGGJFnG8T7N1btJo805H J0wQ== X-Gm-Message-State: AJIora+7ve5k7sBu0tsL2jckjC9zTw1c5XxTXoNDOUlS3JXMuqVw6Fnr ShCWCLVAt53dGNK+poSrSvS3 X-Google-Smtp-Source: AGRyM1v8QKLPp55ybnTYZTyBA98JLg0u4fuOmIJMRi+X7QJTinZ7Fn20A7befer5PI/MYgL1xxDSww== X-Received: by 2002:a17:903:1248:b0:168:c5a3:b296 with SMTP id u8-20020a170903124800b00168c5a3b296mr45695629plh.146.1657101420018; Wed, 06 Jul 2022 02:57:00 -0700 (PDT) Received: from localhost ([139.177.225.253]) by smtp.gmail.com with ESMTPSA id q15-20020a17090311cf00b0016a61e965f0sm17584916plh.280.2022.07.06.02.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 02:56:59 -0700 (PDT) From: Xie Yongji To: kwolf@redhat.com, stefanha@redhat.com, armbru@redhat.com, richard.henderson@linaro.org Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 1/3] libvduse: Fix the incorrect function name Date: Wed, 6 Jul 2022 17:56:22 +0800 Message-Id: <20220706095624.328-2-xieyongji@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220706095624.328-1-xieyongji@bytedance.com> References: <20220706095624.328-1-xieyongji@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=xieyongji@bytedance.com; helo=mail-pj1-x1036.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" In vduse_name_is_valid(), we actually check whether the name is invalid or not. So let's change the function name to vduse_name_is_invalid() to match the behavior. Signed-off-by: Xie Yongji Reviewed-by: Markus Armbruster --- subprojects/libvduse/libvduse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvduse.c index 9a2bcec282..6374933881 100644 --- a/subprojects/libvduse/libvduse.c +++ b/subprojects/libvduse/libvduse.c @@ -1193,7 +1193,7 @@ static int vduse_dev_init(VduseDev *dev, const char *name, return 0; } -static inline bool vduse_name_is_valid(const char *name) +static inline bool vduse_name_is_invalid(const char *name) { return strlen(name) >= VDUSE_NAME_MAX || strstr(name, ".."); } @@ -1242,7 +1242,7 @@ VduseDev *vduse_dev_create_by_name(const char *name, uint16_t num_queues, VduseDev *dev; int ret; - if (!name || vduse_name_is_valid(name) || !ops || + if (!name || vduse_name_is_invalid(name) || !ops || !ops->enable_queue || !ops->disable_queue) { fprintf(stderr, "Invalid parameter for vduse\n"); return NULL; @@ -1276,7 +1276,7 @@ VduseDev *vduse_dev_create(const char *name, uint32_t device_id, struct vduse_dev_config *dev_config; size_t size = offsetof(struct vduse_dev_config, config); - if (!name || vduse_name_is_valid(name) || + if (!name || vduse_name_is_invalid(name) || !has_feature(features, VIRTIO_F_VERSION_1) || !config || !config_size || !ops || !ops->enable_queue || !ops->disable_queue) { fprintf(stderr, "Invalid parameter for vduse\n"); From patchwork Wed Jul 6 09:56:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 1652910 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance-com.20210112.gappssmtp.com header.i=@bytedance-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=rUfwym+2; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LdG3D4NdNz9s07 for ; Wed, 6 Jul 2022 20:28:23 +1000 (AEST) Received: from localhost ([::1]:54896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o92GY-0005yM-DY for incoming@patchwork.ozlabs.org; Wed, 06 Jul 2022 06:28:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o91mM-0004Af-K1 for qemu-devel@nongnu.org; Wed, 06 Jul 2022 05:57:08 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:38867) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o91mL-0004QY-4F for qemu-devel@nongnu.org; Wed, 06 Jul 2022 05:57:06 -0400 Received: by mail-pf1-x435.google.com with SMTP id o12so365886pfp.5 for ; Wed, 06 Jul 2022 02:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wRDKSi3770K/JU0FuB6T8ubSTJN1+dOqkAdD6Kmc4sI=; b=rUfwym+28XIlqihk4lmcWFDYLnhZrRpKH8EbXftUWWGNkKzroethHQPviyFe5ClYDH zc8ulM5hiskjdZNld7Hl5E/qKEFrLAheL03L96wL/hOf1yQHi1kRypMEwo1aCznM4u1A U3qajFXtzB9nEFHiOFW/2hQWj390h++0JtZqcGXu9qBPqYxlqh4RymlfGAODpRGwlvet x+zZa+OHN8zLfmiuy3RWG+wI+1KfJuBlez4OFNhutW3OxsrcCGm4Q5w7J8hgpue38F0F YADrpPHTgAikSgq8fTTn77l2vTXsjcp/0F++2z27iBTXvHLJw6EXm4B2fmRkVQos+sdc 9AKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wRDKSi3770K/JU0FuB6T8ubSTJN1+dOqkAdD6Kmc4sI=; b=JeT6wtJbUGuBRPxkyXHr0zP8fSGWBzU+/ZDJL57mmfxgvYXlBAy/vl++NECMfK2+oG VAetW936sd5qJHnlMe0WZtkjWyOl+WzbxdWmHxE5adcx3jDDIh5A3YM5IhlMoWn266hh KMpdF8OuCOMcH3dPVdxWqiRWNvnINg8rIzzUdJoaQcW81jlBwdcpyg4h64l3hqVga4B0 W5nmRNr53tyXarMoqAjfys/r5urH6wzWFmlNQMPjqVet4wE03PDknqIyUwGG1LnHUDli fd/1yo2cPTIEpoocGJ444ejU7eRatU/wcgjSDtCu8Wv9KBrQZ7CqTVynvPvKujI8LMMS U3RA== X-Gm-Message-State: AJIora+CpAN0GrGeVH66eqQhnQrw4l0/DXlnIE8VSRH/+jyvR+I/UqBd yPB9VILZWAqcasm1S+7IpbMakaV/X9w2DKo= X-Google-Smtp-Source: AGRyM1srqoGoHBj3K1O1PcHNwAQom3W0yBkp4laHGQNyOYOdgItcI2iknjv+EqQlvN1JvhGkGeFjeA== X-Received: by 2002:aa7:82ce:0:b0:528:bf80:3e08 with SMTP id f14-20020aa782ce000000b00528bf803e08mr1206499pfn.65.1657101423908; Wed, 06 Jul 2022 02:57:03 -0700 (PDT) Received: from localhost ([139.177.225.253]) by smtp.gmail.com with ESMTPSA id u15-20020aa7838f000000b0052592a8ef62sm21496919pfm.110.2022.07.06.02.57.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 02:57:03 -0700 (PDT) From: Xie Yongji To: kwolf@redhat.com, stefanha@redhat.com, armbru@redhat.com, richard.henderson@linaro.org Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 2/3] libvduse: Replace strcpy() with strncpy() Date: Wed, 6 Jul 2022 17:56:23 +0800 Message-Id: <20220706095624.328-3-xieyongji@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220706095624.328-1-xieyongji@bytedance.com> References: <20220706095624.328-1-xieyongji@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=xieyongji@bytedance.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Coverity reported a string overflow issue since we copied "name" to "dev_config->name" without checking the length. This should be a false positive since we already checked the length of "name" in vduse_name_is_invalid(). But anyway, let's replace strcpy() with strncpy() (as a general library, we'd like to minimize dependencies on other libraries, so we didn't use g_strlcpy() here) to fix the coverity complaint. Fixes: Coverity CID 1490224 Signed-off-by: Xie Yongji Reviewed-by: Markus Armbruster --- subprojects/libvduse/libvduse.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvduse.c index 6374933881..1e36227388 100644 --- a/subprojects/libvduse/libvduse.c +++ b/subprojects/libvduse/libvduse.c @@ -1309,7 +1309,8 @@ VduseDev *vduse_dev_create(const char *name, uint32_t device_id, goto err_dev; } - strcpy(dev_config->name, name); + strncpy(dev_config->name, name, VDUSE_NAME_MAX); + dev_config->name[VDUSE_NAME_MAX - 1] = '\0'; dev_config->device_id = device_id; dev_config->vendor_id = vendor_id; dev_config->features = features; From patchwork Wed Jul 6 09:56:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 1652911 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance-com.20210112.gappssmtp.com header.i=@bytedance-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=H0cLjfxZ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LdG6969Bhz9s07 for ; Wed, 6 Jul 2022 20:30:57 +1000 (AEST) Received: from localhost ([::1]:33750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o92J4-0004KW-8c for incoming@patchwork.ozlabs.org; Wed, 06 Jul 2022 06:30:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o91mX-0004Tz-AV for qemu-devel@nongnu.org; Wed, 06 Jul 2022 05:57:17 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:44622) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o91mP-0004Qz-9P for qemu-devel@nongnu.org; Wed, 06 Jul 2022 05:57:16 -0400 Received: by mail-pj1-x1032.google.com with SMTP id o3-20020a17090a744300b001ef8f7f3dddso6803955pjk.3 for ; Wed, 06 Jul 2022 02:57:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sVKbdw8f+CQLlZAGWV2XYYE+jc2PlvWSVTp4LW5WggU=; b=H0cLjfxZBbdTS2AcnHOVI4LWcoEKv6YRMiZgiz47Cq2i9wVSv8BOGrxDf9bOQawtzO YYc8AlsUHi5AHx96YnBeRcEb+FFyl3eNAAWo0BTVNQTnEVIGerwiXJnsaCV5ZEvAvI78 wPILbBm0Xn2T6uLn1golq5sWm5HFN941o+7yBIO6dOGc3wO04wOug+Y5XVEp09T8kk/1 ic9R8Wz7xSZD2dLPeyPixWOTHudgvHzmHNhUiC+TDNYo5Uz/irGS8iqeVGQlj4ShRF7z ETQ3hxcA406Rdc+KV26dMbt+Sf/lthN3EIvqVY07czfWKu9b/HIklvRUjW2/uKEEGNK0 p+tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sVKbdw8f+CQLlZAGWV2XYYE+jc2PlvWSVTp4LW5WggU=; b=xKx1q2USHU2mzlb4YndNg04fOaS4JYKCr58lcZkdlzhfuYaOKWpz0xPRTIZNQYqaTc MM5JkrqEYvKL9V5lXCBmGmGeu7d2dcItTX1+f7xuPsFtqoTTv7fQ3C2JLlgZE7rmgKlw ioco4B+9KDHIzz6+pEgP7Yf0c4WO/RK0yBvNjf2YB6kUxueyuUKepCJNZPOG4U6W1/aI k9Y8gcFFPTVra9M7e41amfgMibv6KczaYsz0MyULzEfU2fXbbn7WI0EkO5wkQbuEqdZG KRj/Fp7bR+RChe32JL+43Yov3mmMLMY8mnckMO5SWGaMfCfJwQMOLZsw0qs7UDGkdyas ODnA== X-Gm-Message-State: AJIora+SHkRmb8V/2ZSzFqpsnq7noYMjPUpjqVZ4vK7XWeWNLMKeAZht LYfK23fBVDwZjWYvR9aBvdY0VauJSQAv8SI= X-Google-Smtp-Source: AGRyM1u5GjyeTSHrIIHNtmuRMOafHfohpt7ryuJH7bV7z48WZERSe6JxFvTAmGVhu60uCPuYGwrgrw== X-Received: by 2002:a17:902:f78c:b0:169:b76f:2685 with SMTP id q12-20020a170902f78c00b00169b76f2685mr45976712pln.41.1657101428113; Wed, 06 Jul 2022 02:57:08 -0700 (PDT) Received: from localhost ([139.177.225.253]) by smtp.gmail.com with ESMTPSA id v6-20020aa799c6000000b00527f5aee1a4sm14473002pfi.33.2022.07.06.02.57.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 02:57:07 -0700 (PDT) From: Xie Yongji To: kwolf@redhat.com, stefanha@redhat.com, armbru@redhat.com, richard.henderson@linaro.org Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 3/3] libvduse: Pass positive value to strerror() Date: Wed, 6 Jul 2022 17:56:24 +0800 Message-Id: <20220706095624.328-4-xieyongji@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220706095624.328-1-xieyongji@bytedance.com> References: <20220706095624.328-1-xieyongji@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=xieyongji@bytedance.com; helo=mail-pj1-x1032.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The value passed to strerror() should be positive. So let's fix it. Fixes: Coverity CID 1490226, 1490223 Signed-off-by: Xie Yongji Reviewed-by: Richard Henderson Reviewed-by: Markus Armbruster --- subprojects/libvduse/libvduse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; }