{"id":9706,"url":"https://patchwork.libcamera.org/api/patches/9706/?format=json","web_url":"https://patchwork.libcamera.org/patch/9706/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20200922133537.258098-2-paul.elder@ideasonboard.com>","date":"2020-09-22T13:35:00","name":"[libcamera-devel,01/38] Documentation: coding-style: Document global variable guidelines","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"d27927d996e61b66e0d46786049ca9064837e2b4","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9706/mbox/","series":[{"id":1309,"url":"https://patchwork.libcamera.org/api/series/1309/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1309","date":"2020-09-22T13:34:59","name":"IPA isolation implementation","version":1,"mbox":"https://patchwork.libcamera.org/series/1309/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9706/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9706/checks/","tags":{},"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 B110EC3B5B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Sep 2020 13:36:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7B04662FDF;\n\tTue, 22 Sep 2020 15:36:00 +0200 (CEST)","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 B8A5F6036A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Sep 2020 15:35:59 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0C981555;\n\tTue, 22 Sep 2020 15:35:52 +0200 (CEST)"],"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=\"vm5yfgT1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1600781754;\n\tbh=8uBsm2yGBXpzYPeq+AyKaw7ypGh+S7GYWG6E+RMnhrk=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=vm5yfgT1a78qiqWOeKSRSe1Ea9xKi8bXJxKy1CizNd0PnXi5dx5pujTxAnXBXL/U1\n\t93GyxH1i3Us5VppwOkiB2RzVsC6mk8IwvKBSzjzG2kP3yk7KTzD4b328QhJ90/BHnq\n\t1a+h+8FiCZB9Tppbr1D5kRCWQsPun2fwI3oi8fkM=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 22 Sep 2020 22:35:00 +0900","Message-Id":"<20200922133537.258098-2-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200922133537.258098-1-paul.elder@ideasonboard.com>","References":"<20200922133537.258098-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 01/38] Documentation: coding-style:\n\tDocument global variable guidelines","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>","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>"},"content":"Document the issue related to global variable dependencies and how to\navoid them.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nNew in v2\n---\n Documentation/coding-style.rst | 15 +++++++++++++++\n 1 file changed, 15 insertions(+)","diff":"diff --git a/Documentation/coding-style.rst b/Documentation/coding-style.rst\nindex 8af06d6a..967506db 100644\n--- a/Documentation/coding-style.rst\n+++ b/Documentation/coding-style.rst\n@@ -187,6 +187,21 @@ These rules match the `object ownership rules from the Chromium C++ Style Guide`\n    long term borrowing isn't marked through language constructs, it shall be\n    documented explicitly in details in the API.\n \n+Global Variables\n+~~~~~~~~~~~~~~~~\n+\n+The order of initialization and destructions of global variables cannot be\n+reasonably controlled. This can cause problems (segfaults) when global\n+variables depend on each other, or when non-globals depend on globals.\n+For example, if the declaration of a global variable calls a constructor,\n+which calls into another global variable that has yet to be initialized, that\n+is likely to segfault.\n+\n+The best solution is to avoid global variables when possible. If required,\n+such as for implementing factories with auto-registration, avoid dependencies\n+by running the minimum amount of code in the constructor and destructor,\n+and move code that contains dependencies to a later point of time.\n+\n C Compatibility Headers\n ~~~~~~~~~~~~~~~~~~~~~~~\n \n","prefixes":["libcamera-devel","01/38"]}