[{"id":792,"web_url":"https://patchwork.libcamera.org/comment/792/","msgid":"<20190212224154.GY6279@pendragon.ideasonboard.com>","date":"2019-02-12T22:41:54","subject":"Re: [libcamera-devel] [PATCH 4/4] Documentation: coding-style:\n\tDiscourage move on shared_ptr<>","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Tue, Feb 12, 2019 at 11:20:21PM +0100, Jacopo Mondi wrote:\n> Using std::move() on return statement of a method or on the its returned\n> value prevents the compiler from implementing copy-elision. Discourage\n> that in the coding style document.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nI haven't explicitly given my SoB for this one, so please don't add it\nyourself. To record the advices I gave you, you could use Suggested-by.\n\nThis being said, I hereby give you my\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n:-)\n\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  Documentation/coding-style.rst | 4 ++++\n>  1 file changed, 4 insertions(+)\n> \n> diff --git a/Documentation/coding-style.rst b/Documentation/coding-style.rst\n> index 51afef27e9c1..065fbe0ab07b 100644\n> --- a/Documentation/coding-style.rst\n> +++ b/Documentation/coding-style.rst\n> @@ -151,6 +151,10 @@ reference for the duration of the operation that borrows it.\n>       never by reference. The caller can decide whether to transfer its ownership\n>       of the std::shared_ptr<> with std::move() or retain it. The callee shall\n>       use std::move() if it needs to store the shared pointer.\n> +   * Do not over-use std::move(), as it may prevent copy-elision. In particular\n> +     a function returning a std::shared_ptr<> value shall not use std::move() in\n> +     its return statements, and its callers shall not wrap the function call\n> +     with std::move().\n>     * Borrowed references to shared objects are passed as references to the\n>       objects themselves, not to the std::shared_ptr<>, with the same rules as\n>       for single owner objects.","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 91D7060B21\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Feb 2019 23:41:58 +0100 (CET)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 025A485;\n\tTue, 12 Feb 2019 23:41:57 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1550011318;\n\tbh=tRoS8w4ZldSAt5PzwrcKL4BhVUCsGS8XUetSQ4f04yU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=spCLMftU7anIRXKq9IJqWRM7ixy1dYBgs6uVqJVHArInXaa5hMZstxab/koik/nEd\n\t/J7XtMlyBC5Cw/NFNHKNTK+UTbFEGpb0YhjUfUp5U+4hXbiJO4CLTBzJGNknNhzU2c\n\tnvrF0RBuSC/StwDHukQB5H7PNdTOyWLY1GrvbtAo=","Date":"Wed, 13 Feb 2019 00:41:54 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190212224154.GY6279@pendragon.ideasonboard.com>","References":"<20190212222021.28517-1-jacopo@jmondi.org>\n\t<20190212222021.28517-5-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190212222021.28517-5-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 4/4] Documentation: coding-style:\n\tDiscourage move on shared_ptr<>","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":"Tue, 12 Feb 2019 22:41:58 -0000"}},{"id":804,"web_url":"https://patchwork.libcamera.org/comment/804/","msgid":"<20190213110246.GT31044@bigcity.dyn.berto.se>","date":"2019-02-13T11:02:46","subject":"Re: [libcamera-devel] [PATCH 4/4] Documentation: coding-style:\n\tDiscourage move on shared_ptr<>","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 work.\n\nOn 2019-02-12 23:20:21 +0100, Jacopo Mondi wrote:\n> Using std::move() on return statement of a method or on the its returned\n> value prevents the compiler from implementing copy-elision. Discourage\n> that in the coding style document.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  Documentation/coding-style.rst | 4 ++++\n>  1 file changed, 4 insertions(+)\n> \n> diff --git a/Documentation/coding-style.rst b/Documentation/coding-style.rst\n> index 51afef27e9c1..065fbe0ab07b 100644\n> --- a/Documentation/coding-style.rst\n> +++ b/Documentation/coding-style.rst\n> @@ -151,6 +151,10 @@ reference for the duration of the operation that borrows it.\n>       never by reference. The caller can decide whether to transfer its ownership\n>       of the std::shared_ptr<> with std::move() or retain it. The callee shall\n>       use std::move() if it needs to store the shared pointer.\n> +   * Do not over-use std::move(), as it may prevent copy-elision. In particular\n> +     a function returning a std::shared_ptr<> value shall not use std::move() in\n> +     its return statements, and its callers shall not wrap the function call\n> +     with std::move().\n>     * Borrowed references to shared objects are passed as references to the\n>       objects themselves, not to the std::shared_ptr<>, with the same rules as\n>       for single owner objects.\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-x141.google.com (mail-lf1-x141.google.com\n\t[IPv6:2a00:1450:4864:20::141])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EA0DB60DBB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Feb 2019 12:02:47 +0100 (CET)","by mail-lf1-x141.google.com with SMTP id n23so1444992lfl.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Feb 2019 03:02:47 -0800 (PST)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\tf140sm2611232lff.41.2019.02.13.03.02.46\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tWed, 13 Feb 2019 03:02:46 -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=3K+efAUo6fvkWPVFxIHGKPisIppwtOoEec50pTDgWuI=;\n\tb=dIMRjpOaA/WMmvo7eTnR6wJ8Y+0iOFJSa0r1432SGio5xV7pXxiNmNX93sA+a8xkYa\n\tKKVxXAIl25PkcHa7Dq8aVRcRc51FVLFcnvLklN6LUBPAVLcSUgttjAy2yUlX6MqFeISf\n\tZ5BE+UBiB5ok/aYifq3iHxROIEf6liblbXC81OqK7P1KrQH0ql1ncSp+fjNjyXzep9mG\n\tIB4j1BtzaEHpywUxMnr/XgF/mOkam7Gu6PqiDtZ8r5KeJCLYINJL7i9kjAuKNhumXqod\n\tt8PDKtMKMfp4zdPHH4sH2ykq0cjspK/erTglDp40WkGQ5ZNqLQiL2cdWsksvt6pZvB2W\n\tzITw==","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=3K+efAUo6fvkWPVFxIHGKPisIppwtOoEec50pTDgWuI=;\n\tb=PBoA4IiCWTs4I13JhIgVUw0jVP0cqq1B8IwIIBajvSUrhbZCA5K/lcaooQyrlsF/Ha\n\tO47e0wBL7j3GXKv935DB0chdhwVOjsG0vVL1s1A4xR4gXNP2eyLAjcv7mLjarcbCoXX0\n\tHsLkXrduxcK+Ff8zXBSURBg3H88awZLxX0Bh+ap1eHE5kwq2uUNqXEuGEysTweQ9QzRE\n\tMomhsacrNWsgKRWyLqgVi1axBE2RHvZwD5333tWUYLPk/jWvYZgOp58B+i133zvEKTwr\n\tWtiSTc69Rfug+OWIw1fEXrbgVGTdlcfiDyJs+hlaN2aPE5q5ItuQhO0/cbaEgZWbxTR9\n\tbNfA==","X-Gm-Message-State":"AHQUAua1Tqj9aeKlqPCC8ecYp1wr9RC9H/HsgKSGPDV70wRVQRRTr2DU\n\txaIXO+2HzfRLkDEd59H0Z+VbfBBZ+W4=","X-Google-Smtp-Source":"AHgI3IYYHa6PObmadS/5ffRT9lyQAlt0t4W/fcYtEtHKyvJRCVancyqnpZ6akDYRap2G8WnFKcKBqA==","X-Received":"by 2002:a19:260e:: with SMTP id\n\tm14mr5659473lfm.158.1550055767253; \n\tWed, 13 Feb 2019 03:02:47 -0800 (PST)","Date":"Wed, 13 Feb 2019 12:02:46 +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":"<20190213110246.GT31044@bigcity.dyn.berto.se>","References":"<20190212222021.28517-1-jacopo@jmondi.org>\n\t<20190212222021.28517-5-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":"<20190212222021.28517-5-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 4/4] Documentation: coding-style:\n\tDiscourage move on shared_ptr<>","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, 13 Feb 2019 11:02:48 -0000"}}]