[{"id":14020,"web_url":"https://patchwork.libcamera.org/comment/14020/","msgid":"<20201201181643.GA3085@pendragon.ideasonboard.com>","date":"2020-12-01T18:16:43","subject":"Re: [libcamera-devel] [PATCH v2 1/4] simple-cam: Make return codes\n\tconsistent for main()","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nThank you for the patch.\n\nOn Tue, Dec 01, 2020 at 11:13:11PM +0530, Umang Jain wrote:\n> Use EXIT_FAILURE or EXIT_SUCCESS to indicate program execution\n> status. These are the return codes that should be used for main()\n> as per the C++ standard.\n> \n> Signed-off-by: Umang Jain <email@uajain.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  simple-cam.cpp | 10 +++++-----\n>  1 file changed, 5 insertions(+), 5 deletions(-)\n> \n> diff --git a/simple-cam.cpp b/simple-cam.cpp\n> index 727bb6d..e88fb85 100644\n> --- a/simple-cam.cpp\n> +++ b/simple-cam.cpp\n> @@ -184,7 +184,7 @@ int main()\n>  \tint ret = camera->configure(config.get());\n>  \tif (ret) {\n>  \t\tstd::cout << \"CONFIGURATION FAILED!\" << std::endl;\n> -\t\treturn -1;\n> +\t\treturn EXIT_FAILURE;\n>  \t}\n>  #endif\n>  \n> @@ -217,7 +217,7 @@ int main()\n>  \t\tint ret = allocator->allocate(cfg.stream());\n>  \t\tif (ret < 0) {\n>  \t\t\tstd::cerr << \"Can't allocate buffers\" << std::endl;\n> -\t\t\treturn -ENOMEM;\n> +\t\t\treturn EXIT_FAILURE;\n>  \t\t}\n>  \n>  \t\tunsigned int allocated = allocator->buffers(cfg.stream()).size();\n> @@ -250,7 +250,7 @@ int main()\n>  \t\tif (!request)\n>  \t\t{\n>  \t\t\tstd::cerr << \"Can't create request\" << std::endl;\n> -\t\t\treturn -ENOMEM;\n> +\t\t\treturn EXIT_FAILURE;\n>  \t\t}\n>  \n>  \t\tconst std::unique_ptr<FrameBuffer> &buffer = buffers[i];\n> @@ -259,7 +259,7 @@ int main()\n>  \t\t{\n>  \t\t\tstd::cerr << \"Can't set buffer for request\"\n>  \t\t\t\t  << std::endl;\n> -\t\t\treturn ret;\n> +\t\t\treturn EXIT_FAILURE;\n>  \t\t}\n>  \n>  \t\t/*\n> @@ -341,5 +341,5 @@ int main()\n>  \tcamera.reset();\n>  \tcm->stop();\n>  \n> -\treturn 0;\n> +\treturn EXIT_SUCCESS;\n>  }","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 3A820BE177\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Dec 2020 18:16:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C287B63501;\n\tTue,  1 Dec 2020 19:16:54 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7A36463460\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Dec 2020 19:16:52 +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 027A0DBD;\n\tTue,  1 Dec 2020 19:16:51 +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=\"Q8KD+3p8\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1606846612;\n\tbh=54ktZJLu7yRa+P8TV1jHE/oOS63z3INhFU9drLX6zJU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Q8KD+3p8QCnoZAbuOr+UqMnrkbGrgqhZ3A28J7hFwzmqZOS5rTfpfxUpgyLJobUra\n\tD10HRlSal5xLmo2AuRaPw919kkCNzIThaXqpuFKqah9re+SaKUalxvKu4DmeF7I6b0\n\tGqoih5EFRBp5Z3oJYG0qlOROxK5oTkSIBl3hTj3s=","Date":"Tue, 1 Dec 2020 20:16:43 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Umang Jain <email@uajain.com>","Message-ID":"<20201201181643.GA3085@pendragon.ideasonboard.com>","References":"<20201201174314.12774-1-email@uajain.com>\n\t<20201201174314.12774-2-email@uajain.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201201174314.12774-2-email@uajain.com>","Subject":"Re: [libcamera-devel] [PATCH v2 1/4] simple-cam: Make return codes\n\tconsistent for main()","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=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]