From nobody Thu Nov 13 03:20:25 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576517000; cv=none; d=zohomail.com; s=zohoarc; b=YkmbcL7yYbIMMBnw/mVkP4hYEp0KubwHPJC4vEYfFLzCxptvnCL0KYx8bUWLHqJPE+cR46XTChxGb4G8h5aZo50hzYfW06kisfHROqHi/+Jvz3yGuBza0niUWuvkr0dwf/03bW+x6c0KA4Y/FCAmGEJCLB78T3AT+nS+J4A/3BA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576517000; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uHPnz/CuhNDw7Q8yQgUAYEh1mPj3Ixi1rl2oxYokSDY=; b=OwPFZnB+nx11H41uPE4KpJBxabG0etzSva06131mEXE25Woy9MzEFk2wciPjBPW9KAfBJJenW/IV0W8YqnLYclUBB7dtqXdBU42vR2aBQfNwFTdqstVkad626znLFp0Q306sy96KZN4lS8E48ns/KAnlxzBKC7EuWxsvwYrYvb4= 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 1576517000901571.5129242875969; Mon, 16 Dec 2019 09:23:20 -0800 (PST) Received: from localhost ([::1]:57378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1igu5X-00063L-L9 for importer@patchew.org; Mon, 16 Dec 2019 12:23:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57455) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1igtFj-0005xe-03 for qemu-devel@nongnu.org; Mon, 16 Dec 2019 11:29:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1igtFh-0000Z7-8L for qemu-devel@nongnu.org; Mon, 16 Dec 2019 11:29:46 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:53209) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1igtFg-0000U8-Uw for qemu-devel@nongnu.org; Mon, 16 Dec 2019 11:29:45 -0500 Received: by mail-wm1-x334.google.com with SMTP id p9so7444714wmc.2 for ; Mon, 16 Dec 2019 08:29:44 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id q68sm19962334wme.14.2019.12.16.08.29.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Dec 2019 08:29:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uHPnz/CuhNDw7Q8yQgUAYEh1mPj3Ixi1rl2oxYokSDY=; b=D91lpF6xCIs2UwubdoVbaMhMcJUquR5iq9fKhXDSIxdqXz+j8CmGQyCAd786XV8Xiu lqfHbzyWrthj1omOEfxPQBPpP8b89JQHWqm/GMWnpNdSL9bavjEP5uW3+42p3tN9sqWD tgmmg9eR15imc7DW489Ko6+GJrY5SSp5R3kjgZD+GHimT5PfewcUYMR5m39Lam5XrsCH 8jgTeNWJ9GPE/g7+5x454X5Lsq1UuBKYVVJi6iSFNVqtj1TmlBI9uHrGnwe08c5TqEBI Tyg44tVceGWIh6JPicEb6BaAwfOtd7sDWYEMvDjkv8PKXWS+tDJC+ddqbko7Z/RT1dJU t3Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=uHPnz/CuhNDw7Q8yQgUAYEh1mPj3Ixi1rl2oxYokSDY=; b=uA+IJfD7bxDUI2XYnYraRZLTACN8MRRCZ2CjctIOPocIwIEvFZMuDu//HMo2kthvAr hpDJKnK4tFbiSDalUbs6CsEaLrM+sZoX68obegcdkklvdGoL8UvvArn4itFzC2x3D090 yC98MZciyMWxZhssHv8M6mBwUXVnw7zKeFOGodRp2UqJgRLFkGPeX7mXS4Ag6QksBxcV d5xQEWJXXG2Tg5G9SttESTd2TUTzpU9cDJT6pD5v6PEGHkf0n2puW2n2oBIeaD+wVQgg ArLATccRs4qxwcdSdC5QzUDLOUcaLR5WdYpqyQYvnMGE4VyVj0fbUo3U1ePfqJpSza9V O5kA== X-Gm-Message-State: APjAAAXpyHmoy3Wk2pzJf7qMXwFDtp3GrQ39c0Buhws8CuN6YL9Zy4LW cuM7CqS6VyZ0GPrPhPRFagwHDJ8l X-Google-Smtp-Source: APXvYqxlNkhMRGRSG5eg4Xb4h3Pazx89IawPB0tefPb4zoIoepgnLNIzxI8LbZztjcwhCH5fbUwkfQ== X-Received: by 2002:a7b:cc82:: with SMTP id p2mr32501204wma.159.1576513782919; Mon, 16 Dec 2019 08:29:42 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 55/62] hw/isa/isa-bus: cleanup irq functions Date: Mon, 16 Dec 2019 17:28:39 +0100 Message-Id: <1576513726-53700-56-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1576513726-53700-1-git-send-email-pbonzini@redhat.com> References: <1576513726-53700-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::334 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The irq number is unsigned; we reject negative values. But -1 is used for the isairq array, which is declared unsigned! And since we have a definition for the number of ISA IRQs, use it. Based on a patch by Philippe Mathieu-Daud=C3=A9. Signed-off-by: Paolo Bonzini --- hw/isa/isa-bus.c | 11 +++++++---- include/hw/isa/isa.h | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index 3888006..798dd91 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -82,24 +82,27 @@ void isa_bus_irqs(ISABus *bus, qemu_irq *irqs) * This function is only for special cases such as the 'ferr', and * temporary use for normal devices until they are converted to qdev. */ -qemu_irq isa_get_irq(ISADevice *dev, int isairq) +qemu_irq isa_get_irq(ISADevice *dev, unsigned isairq) { assert(!dev || ISA_BUS(qdev_get_parent_bus(DEVICE(dev))) =3D=3D isabus= ); - if (isairq < 0 || isairq > 15) { + if (isairq >=3D ISA_NUM_IRQS) { hw_error("isa irq %d invalid", isairq); } return isabus->irqs[isairq]; } =20 -void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq) +void isa_init_irq(ISADevice *dev, qemu_irq *p, unsigned isairq) { assert(dev->nirqs < ARRAY_SIZE(dev->isairq)); + if (isairq >=3D ISA_NUM_IRQS) { + hw_error("isa irq %d invalid", isairq); + } dev->isairq[dev->nirqs] =3D isairq; *p =3D isa_get_irq(dev, isairq); dev->nirqs++; } =20 -void isa_connect_gpio_out(ISADevice *isadev, int gpioirq, int isairq) +void isa_connect_gpio_out(ISADevice *isadev, int gpioirq, unsigned isairq) { qemu_irq irq; isa_init_irq(isadev, &irq, isairq); diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h index 79f703f..e9ac1f1 100644 --- a/include/hw/isa/isa.h +++ b/include/hw/isa/isa.h @@ -88,7 +88,7 @@ struct ISADevice { DeviceState parent_obj; /*< public >*/ =20 - uint32_t isairq[2]; + int8_t isairq[2]; /* -1 =3D unassigned */ int nirqs; int ioport_id; }; @@ -96,9 +96,9 @@ struct ISADevice { ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space, MemoryRegion *address_space_io, Error **errp); void isa_bus_irqs(ISABus *bus, qemu_irq *irqs); -qemu_irq isa_get_irq(ISADevice *dev, int isairq); -void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq); -void isa_connect_gpio_out(ISADevice *isadev, int gpioirq, int isairq); +qemu_irq isa_get_irq(ISADevice *dev, unsigned isairq); +void isa_init_irq(ISADevice *dev, qemu_irq *p, unsigned isairq); +void isa_connect_gpio_out(ISADevice *isadev, int gpioirq, unsigned isairq); void isa_bus_dma(ISABus *bus, IsaDma *dma8, IsaDma *dma16); IsaDma *isa_get_dma(ISABus *bus, int nchan); MemoryRegion *isa_address_space(ISADevice *dev); --=20 1.8.3.1