From nobody Sat Nov 1 22:30:12 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527563196369473.45309056622625; Mon, 28 May 2018 20:06:36 -0700 (PDT) Received: from localhost ([::1]:58707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNUxu-0007Te-FS for importer@patchew.org; Mon, 28 May 2018 23:06:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNUwt-000798-VE for qemu-devel@nongnu.org; Mon, 28 May 2018 23:05:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNUwq-0003Xh-R2 for qemu-devel@nongnu.org; Mon, 28 May 2018 23:05:23 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:40677) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fNUwq-0003X9-MB; Mon, 28 May 2018 23:05:20 -0400 Received: by mail-qt0-x241.google.com with SMTP id h2-v6so16971859qtp.7; Mon, 28 May 2018 20:05:20 -0700 (PDT) Received: from tristan-dev-vm.mshome.net (c-73-123-117-162.hsd1.nh.comcast.net. [73.123.117.162]) by smtp.gmail.com with ESMTPSA id f3-v6sm23181422qtb.51.2018.05.28.20.05.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 20:05:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=t6ykDpGRIOZ5vgUjy9sife1smKLOmUTTxZDyhSYoKUg=; b=nqAEHKwMUj3v1iyycjuht7OYwD4IfuhPQU5BwrDzzEkwFIA83lJIraESDth8sjGsEB s58grgNvP7tOdUbm/IzEYxo7TP07mNCb78PjyEuD3gCXOttyCpk2GSpflq0iayAa/+Bt va47F+5GrAyUHK4TfPKEH8KnwPY3PcpPLdrfVtSPwD4L52Ne5bYV41GT4nZ7veFsieRC XNaVkHwZQYQDN3lGYO3ouLbfWevQORBy+gFq0v6hL6RFXxRqDKIpVrnwvdDsBonrl3k1 hv33U31i52e/kmmXqU1nbUjxcfTBJFaKt1X1ugCDfZHm8IbQ5XRgHx93axyg9ZC2eKqs I5GA== 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; bh=t6ykDpGRIOZ5vgUjy9sife1smKLOmUTTxZDyhSYoKUg=; b=sMRmDlVWMsZOV+7JBJCfcJu7cSZ2RD6GxT0F1N82lHQE8eLUFaeRvjyCRgTssGc3vo sgnDZgn2D4zr7BqLKDLc1lgi3VKlYXqH3WlIU0JJFvr7MXVV0asILsr6hRPXq1J/3hH+ miUY4h5R2OSxhXwzJ2B8WR98gspm0rSHpnO0AjHVPCjg0vf1XVHgOgzDghxNY8Vfz+Om 6d7YenwTQS2OZG5y8lciHUF7HgBzq3Tg0lx/cbo/sAUFxOAHVlYmFo9MuTLsdLUId+7I G77cwrXA8wYBTvefLCfP3aF503jxLXKwvleAmFZbXfUVEsekspNQWz1uLsWtPU8vz/aj 7AQg== X-Gm-Message-State: ALKqPwft7491ex08K2Xi0BHwyNOiiXALLnTMYVtwTI45iiMMzafRyLpM vEZhaaENzXSj3m3jo0nGBUEksW5knQc= X-Google-Smtp-Source: ADUXVKJlrJGAzp+kPqEmEETCJOol9JWZDP+tWZgVr7U2uguqJ2mGvoxs/DfAQdlc3W7mw1xZlOENJw== X-Received: by 2002:ac8:10d:: with SMTP id e13-v6mr14082096qtg.403.1527563119901; Mon, 28 May 2018 20:05:19 -0700 (PDT) From: Tristan Burgess To: qemu-devel@nongnu.org Date: Mon, 28 May 2018 23:04:45 -0400 Message-Id: <20180529030445.177867-1-tburgessdev@gmail.com> X-Mailer: git-send-email 2.17.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::241 Subject: [Qemu-devel] [PATCH] memory: bug 1720969: Make operations using MemoryRegionIoeventfd struct pass by pointer. 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: qemu-trivial@nongnu.org, Paolo Bonzini , tburgessdev@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This changes the functions memory_region_ioeventfd_equal, memory_region_ioe= ventfd_before, and their callers, to pass the MemoryRegionIoeventfd struct via pointer, instead of directly p= assing the struct. This saves on stack space and is considered safe practice. Signed-off-by: Tristan Burgess --- memory.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/memory.c b/memory.c index fc7f9b782b..a2b9bb88f3 100644 --- a/memory.c +++ b/memory.c @@ -173,38 +173,38 @@ struct MemoryRegionIoeventfd { EventNotifier *e; }; =20 -static bool memory_region_ioeventfd_before(MemoryRegionIoeventfd a, - MemoryRegionIoeventfd b) +static bool memory_region_ioeventfd_before(MemoryRegionIoeventfd *a, + MemoryRegionIoeventfd *b) { - if (int128_lt(a.addr.start, b.addr.start)) { + if (int128_lt(a->addr.start, b->addr.start)) { return true; - } else if (int128_gt(a.addr.start, b.addr.start)) { + } else if (int128_gt(a->addr.start, b->addr.start)) { return false; - } else if (int128_lt(a.addr.size, b.addr.size)) { + } else if (int128_lt(a->addr.size, b->addr.size)) { return true; - } else if (int128_gt(a.addr.size, b.addr.size)) { + } else if (int128_gt(a->addr.size, b->addr.size)) { return false; - } else if (a.match_data < b.match_data) { + } else if (a->match_data < b->match_data) { return true; - } else if (a.match_data > b.match_data) { + } else if (a->match_data > b->match_data) { return false; - } else if (a.match_data) { - if (a.data < b.data) { + } else if (a->match_data) { + if (a->data < b->data) { return true; - } else if (a.data > b.data) { + } else if (a->data > b->data) { return false; } } - if (a.e < b.e) { + if (a->e < b->e) { return true; - } else if (a.e > b.e) { + } else if (a->e > b->e) { return false; } return false; } =20 -static bool memory_region_ioeventfd_equal(MemoryRegionIoeventfd a, - MemoryRegionIoeventfd b) +static bool memory_region_ioeventfd_equal(MemoryRegionIoeventfd *a, + MemoryRegionIoeventfd *b) { return !memory_region_ioeventfd_before(a, b) && !memory_region_ioeventfd_before(b, a); @@ -791,8 +791,8 @@ static void address_space_add_del_ioeventfds(AddressSpa= ce *as, while (iold < fds_old_nb || inew < fds_new_nb) { if (iold < fds_old_nb && (inew =3D=3D fds_new_nb - || memory_region_ioeventfd_before(fds_old[iold], - fds_new[inew]))) { + || memory_region_ioeventfd_before(&fds_old[iold], + &fds_new[inew]))) { fd =3D &fds_old[iold]; section =3D (MemoryRegionSection) { .fv =3D address_space_to_flatview(as), @@ -804,8 +804,8 @@ static void address_space_add_del_ioeventfds(AddressSpa= ce *as, ++iold; } else if (inew < fds_new_nb && (iold =3D=3D fds_old_nb - || memory_region_ioeventfd_before(fds_new[inew], - fds_old[iold]))) { + || memory_region_ioeventfd_before(&fds_new[inew], + &fds_old[iold])))= { fd =3D &fds_new[inew]; section =3D (MemoryRegionSection) { .fv =3D address_space_to_flatview(as), @@ -1443,7 +1443,7 @@ static bool memory_region_dispatch_write_eventfds(Mem= oryRegion *mr, ioeventfd.match_data =3D mr->ioeventfds[i].match_data; ioeventfd.e =3D mr->ioeventfds[i].e; =20 - if (memory_region_ioeventfd_equal(ioeventfd, mr->ioeventfds[i])) { + if (memory_region_ioeventfd_equal(&ioeventfd, &mr->ioeventfds[i]))= { event_notifier_set(ioeventfd.e); return true; } @@ -2213,7 +2213,7 @@ void memory_region_add_eventfd(MemoryRegion *mr, } memory_region_transaction_begin(); for (i =3D 0; i < mr->ioeventfd_nb; ++i) { - if (memory_region_ioeventfd_before(mrfd, mr->ioeventfds[i])) { + if (memory_region_ioeventfd_before(&mrfd, &mr->ioeventfds[i])) { break; } } @@ -2248,7 +2248,7 @@ void memory_region_del_eventfd(MemoryRegion *mr, } memory_region_transaction_begin(); for (i =3D 0; i < mr->ioeventfd_nb; ++i) { - if (memory_region_ioeventfd_equal(mrfd, mr->ioeventfds[i])) { + if (memory_region_ioeventfd_equal(&mrfd, &mr->ioeventfds[i])) { break; } } --=20 2.17.0