[{"id":15118,"web_url":"https://patchwork.libcamera.org/comment/15118/","msgid":"<YCXhAEeESycyxt9i@pendragon.ideasonboard.com>","date":"2021-02-12T01:59:28","subject":"Re: [libcamera-devel] [PATCH v7 09/10] libcamera:\n\tIPCPipeUnixSocket: Check that insertion succeeds","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Thu, Feb 11, 2021 at 04:18:04PM +0900, Paul Elder wrote:\n> From: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> \n> Make sure the insertion succeeds. This was found by compile tests\n> with gcc7 which points out 'success' is not used.\n\nYou could squash this with the patch that introduces the problem to\navoid breaking bisection.\n\n> \n>   ../../src/libcamera/ipc_pipe_unixsocket.cpp:119:27: error: unused variable ‘success’ [-Werror=unused-variable]\n>     const auto [iter, success] = callData_.insert({ cookie, { response, false } });\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n>  src/libcamera/ipc_pipe_unixsocket.cpp | 5 +++++\n>  1 file changed, 5 insertions(+)\n> \n> diff --git a/src/libcamera/ipc_pipe_unixsocket.cpp b/src/libcamera/ipc_pipe_unixsocket.cpp\n> index 2bdce29e..cdb7eae0 100644\n> --- a/src/libcamera/ipc_pipe_unixsocket.cpp\n> +++ b/src/libcamera/ipc_pipe_unixsocket.cpp\n> @@ -118,6 +118,11 @@ int IPCPipeUnixSocket::call(const IPCUnixSocket::Payload &message,\n>  \n>  \tconst auto [iter, success] = callData_.insert({ cookie, { response, false } });\n>  \n> +\tif (!success) {\n> +\t\tLOG(IPCPipe, Error) << \"Failed to insert call data\";\n> +\t\treturn -EINVAL;\n> +\t}\n\nThis will only happen if the cookie is already present in the\ndictionary, which I don't think can happen. As the goal is to silence a\nwarning, you could instead write\n\n  \tconst auto result = callData_.insert({ cookie, { response, false } });\n  \tconst auto &iter = result.first;\n\n> +\n>  \tret = socket_->send(message);\n>  \tif (ret) {\n>  \t\tcallData_.erase(iter);","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 4DB88BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Feb 2021 01:59:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D26BA63753;\n\tFri, 12 Feb 2021 02:59:56 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6A5FB602FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Feb 2021 02:59:55 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EFE618B5;\n\tFri, 12 Feb 2021 02:59:53 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"imQJhK9+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1613095194;\n\tbh=RdoCFAWb5P7cjbfXFPBXw/eraECIkt0FRKL7BLjICAQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=imQJhK9+ndMenLPPyE/wZf0RVy6+mtLSvzo1fWEOXzQnnC/zabIjt2G/RGYuMSvZm\n\tjCZVY2J4X9UPNXzZtpEv+TF/BQxvi5Ll8XqipXSbuila656tJ7O3rCa2zlKXc7xi/t\n\tD5ZtwQfXxufU280TqfXZVF++7ZOFFK16j1BbL90A=","Date":"Fri, 12 Feb 2021 03:59:28 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Message-ID":"<YCXhAEeESycyxt9i@pendragon.ideasonboard.com>","References":"<20210211071805.34963-1-paul.elder@ideasonboard.com>\n\t<20210211071805.34963-10-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210211071805.34963-10-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v7 09/10] libcamera:\n\tIPCPipeUnixSocket: Check that insertion succeeds","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]