{"id":133,"url":"https://patchwork.libcamera.org/api/1.1/patches/133/?format=json","web_url":"https://patchwork.libcamera.org/patch/133/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190102120256.7769-1-jacopo@jmondi.org>","date":"2019-01-02T12:02:55","name":"[libcamera-devel,1/2] libcamera: media_device: Minor cleanup in findInterface()","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"25d2718639719e45fcd2922812722b2ea54833dc","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/133/mbox/","series":[{"id":50,"url":"https://patchwork.libcamera.org/api/1.1/series/50/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=50","date":"2019-01-02T12:02:55","name":"[libcamera-devel,1/2] libcamera: media_device: Minor cleanup in findInterface()","version":1,"mbox":"https://patchwork.libcamera.org/series/50/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/133/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/133/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C595A60B0C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  2 Jan 2019 13:02:56 +0100 (CET)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 5B21BC0007;\n\tWed,  2 Jan 2019 12:02:56 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  2 Jan 2019 13:02:55 +0100","Message-Id":"<20190102120256.7769-1-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.20.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 1/2] libcamera: media_device: Minor\n\tcleanup in findInterface()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Wed, 02 Jan 2019 12:02:56 -0000"},"content":"Do not compare an usigned int with -1 to avoid going through cast.\nAlso align function parameters and long assignement lines while at there.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/media_device.cpp | 17 ++++++++---------\n 1 file changed, 8 insertions(+), 9 deletions(-)\n\n--\n2.20.1","diff":"diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex 4ff9ffe..34206c8 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -379,13 +379,14 @@ void MediaDevice::clear()\n  * \\return A pointer to the interface if found, or nullptr otherwise\n  */\n struct media_v2_interface *MediaDevice::findInterface(const struct media_v2_topology &topology,\n-\t\t\t       unsigned int entityId)\n+\t\t\t\t\t\t      unsigned int entityId)\n {\n \tstruct media_v2_link *links = reinterpret_cast<struct media_v2_link *>\n-\t\t\t\t\t\t(topology.ptr_links);\n-\tunsigned int ifaceId = -1;\n+\t\t\t\t\t\t      (topology.ptr_links);\n+\tunsigned int ifaceId;\n+\tunsigned int i;\n\n-\tfor (unsigned int i = 0; i < topology.num_links; ++i) {\n+\tfor (i = 0; i < topology.num_links; ++i) {\n \t\t/* Search for the interface to entity link. */\n \t\tif (links[i].sink_id != entityId)\n \t\t\tcontinue;\n@@ -397,14 +398,12 @@ struct media_v2_interface *MediaDevice::findInterface(const struct media_v2_topo\n \t\tifaceId = links[i].source_id;\n \t\tbreak;\n \t}\n-\n-\tif (ifaceId == static_cast<unsigned int>(-1))\n+\tif (i == topology.num_links)\n \t\treturn nullptr;\n\n \tstruct media_v2_interface *ifaces = reinterpret_cast<struct media_v2_interface *>\n-\t\t\t\t\t\t(topology.ptr_interfaces);\n-\n-\tfor (unsigned int i = 0; i < topology.num_interfaces; ++i) {\n+\t\t\t\t\t\t            (topology.ptr_interfaces);\n+\tfor (i = 0; i < topology.num_interfaces; ++i) {\n \t\tif (ifaces[i].id == ifaceId)\n \t\t\treturn &ifaces[i];\n \t}\n","prefixes":["libcamera-devel","1/2"]}