From nobody Fri Apr 26 12:03:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584981846; cv=none; d=zohomail.com; s=zohoarc; b=WRSkgW+GiHSX2ALVnk1T4lswzgDzSP/CfWxA1CB8FnIWjpntHqAu5eTfU2YWNTu7MvH6j9dur8uMNKFwoaXbbQ3yGFsVlFfZA+EVcXVywkBfBG6Ybu5sv7PSqheXCdxoQuI31FgqN2tTZhaostEsiBInBJNROPyhm9UErXCMMF8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584981846; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=/n6IqjRnzQwn9OgJiIphU3qnPEgngPDRG3PtfiwJ4qk=; b=EZUiRl29ZLamC/6M1+izQ4OvigzRLWTDL+k37t9wiE6Tfw9RI2Hg0PYYzopVwjjgoOBclB7s0bw0XTY0ipwsDLf5ISUq5ZmYkY0KWlSZB0mMucz7mahrJsO/HAmKJiytSKhI3wCZQ5mIof1II67zqn/BD96TjyBk/NAdoVXkNho= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584981846505688.0815173031326; Mon, 23 Mar 2020 09:44:06 -0700 (PDT) Received: from localhost ([::1]:36906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGQBJ-0000Fj-6i for importer@patchew.org; Mon, 23 Mar 2020 12:44:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41050) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGQAe-0008EI-V2 for qemu-devel@nongnu.org; Mon, 23 Mar 2020 12:43:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jGQAd-0005lz-Ju for qemu-devel@nongnu.org; Mon, 23 Mar 2020 12:43:24 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:39079) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jGQAc-0005lF-RD for qemu-devel@nongnu.org; Mon, 23 Mar 2020 12:43:23 -0400 Received: by mail-wr1-x441.google.com with SMTP id p10so5532509wrt.6 for ; Mon, 23 Mar 2020 09:43:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id k3sm167767wmf.16.2020.03.23.09.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2020 09:43:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/n6IqjRnzQwn9OgJiIphU3qnPEgngPDRG3PtfiwJ4qk=; b=NRxjntSKnhh9cuYpICqvqbe+5VDzXuLAOjYJ5Vb/FaXOe+Vntbb+vKct0kXsLg6Tv0 QWkBpP3UmWolQDRckN3ukCTsNnKo08mHxum4mzpw6tG/JjH7/LDftIBFpx9gM2ZorH5x Mhe1Rv4a53jXiRby8HHP5xNaiXInzhaCpfJyRDe/zH2bhfYRPp0O+7Do7+RNINvhajV5 dljhVMYNAYdqpn2s5o4oWBMNnyXftom+ctI5zzNztzh2yuuO2fC6axL35HhzsAMMar7c 1bu6pvUhIFN5uPeItM6P1li2m7hzTC6m9bXE1vX5VZiray6gPwTUrU5N4X4H9ora+9He l/iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/n6IqjRnzQwn9OgJiIphU3qnPEgngPDRG3PtfiwJ4qk=; b=EWd+Uxu5Yyh9kc4WYFDTY7Cvrdh7ujVxUG+6a9nvkp3RNqSkPLpDiXcQ7XfOwBa5ar O4+hH7UbztH2HsXLCgOtGLNPdI3wnvUtOh6Cnb1C3d709j/YGfLR6qByIlcfqh8PzMrZ s6ZTNqbY4/1A6LPyXuWt94qVJ1PwTbk0h0C5gJWfiVVN679aZ0mIDMvet8CxhAnzhSMk cI6d9ekcnlVIRc46x3W8YDLUR2tuRj1LA/nTRDA7fRnHMpHWXWsPQpCroIk/bN9gf0qQ 0TXNYbyyjcgaRy8hXfse/JXsJMlGcB2xhsH8+3rtpoXfpICFA1Qi9jPaPTlnVusMxoUe d2vw== X-Gm-Message-State: ANhLgQ3Yud5Vg8Ai6/a3qwKpi5RThwHnxTcCWnAYPw2pBEQ5D+/Tpk1U RamdmGCQ/a7owOa+UXimJOKI5HczgQNY1g== X-Google-Smtp-Source: ADFU+vuKOy8jajjJhmhzqHPvB3MT8/sixoy6pVIJWxEIeLGqaKFXu7CbBFTVuUuDcyuYaC4GIyK2Qg== X-Received: by 2002:adf:e98b:: with SMTP id h11mr11516307wrm.409.1584981800964; Mon, 23 Mar 2020 09:43:20 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [RFC] hw/usb/xen-usb.c: Pass struct usbback_req* to usbback_packet_complete() Date: Mon, 23 Mar 2020 16:43:18 +0000 Message-Id: <20200323164318.26567-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anthony Perard , xen-devel@lists.xenproject.org, Stefano Stabellini , Gerd Hoffmann , Paul Durrant Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The function usbback_packet_complete() currently takes a USBPacket*, which must be a pointer to the packet field within a struct usbback_req; the function uses container_of() to get the struct usbback_req* given the USBPacket*. This is unnecessarily confusing (and in particular it confuses the Coverity Scan analysis, resulting in the false positive CID 1421919 where it thinks that we write off the end of the structure). Since both callsites already have the pointer to the struct usbback_req, just pass that in directly. Signed-off-by: Peter Maydell Acked-by: Gerd Hoffmann Reviewed-by: Anthony PERARD --- This is an RFC because: * I'm not very familiar with the Xen bits of QEMU * the main rationale here is to change something that's confusing Coverity -- the code as it stands isn't wrong * the only testing I've done is "make check" Still, the change seems like a good thing to me as a human reader... PS: QEMU's MAINTAINERS file stanza for Xen doesn't pick up that this file is Xen related, so it could use an extra F: line. hw/usb/xen-usb.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/usb/xen-usb.c b/hw/usb/xen-usb.c index 1fc2f32ce93..961190d0f78 100644 --- a/hw/usb/xen-usb.c +++ b/hw/usb/xen-usb.c @@ -347,13 +347,11 @@ static int32_t usbback_xlat_status(int status) return -ESHUTDOWN; } =20 -static void usbback_packet_complete(USBPacket *packet) +static void usbback_packet_complete(struct usbback_req *usbback_req) { - struct usbback_req *usbback_req; + USBPacket *packet =3D &usbback_req->packet; int32_t status; =20 - usbback_req =3D container_of(packet, struct usbback_req, packet); - QTAILQ_REMOVE(&usbback_req->stub->submit_q, usbback_req, q); =20 status =3D usbback_xlat_status(packet->status); @@ -566,7 +564,7 @@ static void usbback_dispatch(struct usbback_req *usbbac= k_req) =20 usb_handle_packet(usbback_req->stub->dev, &usbback_req->packet); if (usbback_req->packet.status !=3D USB_RET_ASYNC) { - usbback_packet_complete(&usbback_req->packet); + usbback_packet_complete(usbback_req); } return; =20 @@ -993,7 +991,7 @@ static void xen_bus_complete(USBPort *port, USBPacket *= packet) =20 usbif =3D usbback_req->usbif; TR_REQ(&usbif->xendev, "\n"); - usbback_packet_complete(packet); + usbback_packet_complete(usbback_req); } =20 static USBPortOps xen_usb_port_ops =3D { --=20 2.20.1