[{"id":184,"web_url":"https://patchwork.libcamera.org/comment/184/","msgid":"<20190102224803.GA19161@bigcity.dyn.berto.se>","date":"2019-01-02T22:48:03","subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: media_device: Minor\n\tcleanup in findInterface()","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nThanks for your patch.\n\nOn 2019-01-02 13:02:55 +0100, Jacopo Mondi wrote:\n> Do not compare an usigned int with -1 to avoid going through cast.\n> Also align function parameters and long assignement lines while at there.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/media_device.cpp | 17 ++++++++---------\n>  1 file changed, 8 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\n> index 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> --\n> 2.20.1\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lf1-x143.google.com (mail-lf1-x143.google.com\n\t[IPv6:2a00:1450:4864:20::143])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A80A560B2F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  2 Jan 2019 23:48:06 +0100 (CET)","by mail-lf1-x143.google.com with SMTP id i26so22046184lfc.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 02 Jan 2019 14:48:06 -0800 (PST)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\t1-v6sm11177677lju.61.2019.01.02.14.48.03\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tWed, 02 Jan 2019 14:48:04 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=Tooaz21Wy0o5nghGsYa7aTciVhverIurPOllluzrzEI=;\n\tb=j/TUc0eUQ4i2mwTyXpzy4AV4vbgpWgnaa+Tb6+t/yCaUk3CexpYjrXOz0ZhBvIvRXa\n\tMmHBDU7ZKq8qNXVHNbKBDAbWeKbuDKggUhQYtXPydpfgEj6FZ28A/lR+jdMOwF5fExLj\n\tJaFhGxSF7ZR/AlYkGIMN4QzL5Y6mjgj1CtJl4Yn8iRzDhCoogtuwJB+QdGRfrfSWLVvl\n\thy7NWPx2NQnx80BUoVo2Uua9UCUSj05Ekw+AvVeCZj4RgveqUCcqBZJelLBZ7V6Dn0o6\n\tb/IWGr5mfWdoMK0SsSDEKr7VfYE6H6ry1LReVN38y0zYryckTwYAN4XQPokDK1vRQOV2\n\te0JA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=Tooaz21Wy0o5nghGsYa7aTciVhverIurPOllluzrzEI=;\n\tb=imycLkXv4/UzefXrdwWmuVBhkTMJ9Mv8GuDVoE+CuKdiVfFbx5Xktm8CXYkU7qkvb4\n\tNU6lHtJo741RL+/741l7IiZO+G1sLCc3YHj3TkoMKJXOrD/mB6jen/MsY8Zs6xBVlqWC\n\tmTMbHHlPDrY1iXw25sm2s4/yfHpFfE+ycJPXKRrevqqEfnKmXIzU2sS2q8/Ld+nfL5vX\n\tViGmh0uN7nFbbB9NyLoYy3ucoRM98+wVhrtqWJfrOfdcsr5ubebHqJIAZOYU/8LnO2nD\n\tXSyjOBIf5vIcIZmtxU+46PcrQrdGbMpWfrW7uv1hfQou9kgGWWFI+5hUE0pheUN+zVQr\n\tOWiA==","X-Gm-Message-State":"AA+aEWaP3QzQSU8/iV0or12nZeXaOJmh82S/7RyRKSaBNmzWm4xAqpaS\n\tqnxLFn/t/HKCRe7fSVS07hsI/Q==","X-Google-Smtp-Source":"AFSGD/UjQme1r61Q/IX0Mzd+edlc+Rka+Uj0nNZYrGCA81Fr7jkrO7E+qZ3nN3dGedZY1ICkCXeBUA==","X-Received":"by 2002:a19:2755:: with SMTP id\n\tn82mr21116164lfn.94.1546469284781; \n\tWed, 02 Jan 2019 14:48:04 -0800 (PST)","Date":"Wed, 2 Jan 2019 23:48:03 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190102224803.GA19161@bigcity.dyn.berto.se>","References":"<20190102120256.7769-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190102120256.7769-1-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [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 22:48:06 -0000"}}]