From patchwork Thu May 23 09:44:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Kotov X-Patchwork-Id: 10957175 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 870C96C5 for ; Thu, 23 May 2019 09:45:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CAA828179 for ; Thu, 23 May 2019 09:45:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 608AA2842D; Thu, 23 May 2019 09:45:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 09C0828179 for ; Thu, 23 May 2019 09:45:48 +0000 (UTC) Received: from localhost ([127.0.0.1]:60875 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTkIF-0006Fe-CJ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 May 2019 05:45:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTkHJ-0005a4-68 for qemu-devel@nongnu.org; Thu, 23 May 2019 05:44:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTkHI-0007JN-8l for qemu-devel@nongnu.org; Thu, 23 May 2019 05:44:49 -0400 Received: from forwardcorp1p.mail.yandex.net ([77.88.29.217]:47694) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTkHI-0007IN-2k for qemu-devel@nongnu.org; Thu, 23 May 2019 05:44:48 -0400 Received: from mxbackcorp2j.mail.yandex.net (mxbackcorp2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::119]) by forwardcorp1p.mail.yandex.net (Yandex) with ESMTP id 3029C2E0AF3; Thu, 23 May 2019 12:44:44 +0300 (MSK) Received: from smtpcorp1j.mail.yandex.net (smtpcorp1j.mail.yandex.net [2a02:6b8:0:1619::137]) by mxbackcorp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id v7QKV5QSmA-ih5isQT1; Thu, 23 May 2019 12:44:44 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1558604684; bh=SI0jxpLyVqp6a2uHfKYSeiX7vKJYR+MCO0k9TYvwkno=; h=Message-Id:Date:Subject:To:From:Cc; b=fSHGoPNtiqavFlkTxayfj7Rygy8eXW6cD7KqszxKVL7+dhXshywRSryjaifgJbfOk PYjEqnIXHRNSb8amCqHYHN3nY/kreGcsabDpUvPf6tuHyV7SCMHHxTBBFgmkuHbV8V mvk2M8/4XDJJC7irT8sgEHF2LxZf0EYoK4LX/Gm0= Authentication-Results: mxbackcorp2j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:d05b:c3b5:9878:7629]) by smtpcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id a66T7ncC5r-ih80rIK3; Thu, 23 May 2019 12:44:43 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Yury Kotov To: Markus Armbruster , Eric Blake , qemu-devel@nongnu.org Date: Thu, 23 May 2019 12:44:33 +0300 Message-Id: <20190523094433.30297-1-yury-kotov@yandex-team.ru> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 77.88.29.217 Subject: [Qemu-devel] [PATCH v3] monitor: Fix return type of monitor_fdset_dup_fd_find X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP monitor_fdset_dup_fd_find_remove() and monitor_fdset_dup_fd_find() return mon_fdset->id which is int64_t. Downcasting from int64_t to int leads to a bug with removing fd from fdset with id >= 2^32. So, fix return types for these function. Signed-off-by: Yury Kotov Reviewed-by: Markus Armbruster --- include/monitor/monitor.h | 2 +- monitor.c | 4 ++-- stubs/fdset.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 86656297f1..51f048d61f 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -45,6 +45,6 @@ AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id, int monitor_fdset_get_fd(int64_t fdset_id, int flags); int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd); void monitor_fdset_dup_fd_remove(int dup_fd); -int monitor_fdset_dup_fd_find(int dup_fd); +int64_t monitor_fdset_dup_fd_find(int dup_fd); #endif /* MONITOR_H */ diff --git a/monitor.c b/monitor.c index 6428eb3b7e..a0e637f7d6 100644 --- a/monitor.c +++ b/monitor.c @@ -2602,7 +2602,7 @@ err: return -1; } -static int monitor_fdset_dup_fd_find_remove(int dup_fd, bool remove) +static int64_t monitor_fdset_dup_fd_find_remove(int dup_fd, bool remove) { MonFdset *mon_fdset; MonFdsetFd *mon_fdset_fd_dup; @@ -2630,7 +2630,7 @@ err: return -1; } -int monitor_fdset_dup_fd_find(int dup_fd) +int64_t monitor_fdset_dup_fd_find(int dup_fd) { return monitor_fdset_dup_fd_find_remove(dup_fd, false); } diff --git a/stubs/fdset.c b/stubs/fdset.c index 4f3edf2ea4..a1b8f41f62 100644 --- a/stubs/fdset.c +++ b/stubs/fdset.c @@ -7,7 +7,7 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd) return -1; } -int monitor_fdset_dup_fd_find(int dup_fd) +int64_t monitor_fdset_dup_fd_find(int dup_fd) { return -1; }