Patch Detail
Show a patch.
GET /api/patches/151/?format=api
{ "id": 151, "url": "https://patchwork.libcamera.org/api/patches/151/?format=api", "web_url": "https://patchwork.libcamera.org/patch/151/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20190106023328.10989-2-laurent.pinchart@ideasonboard.com>", "date": "2019-01-06T02:33:19", "name": "[libcamera-devel,02/11] libcamera: log: Add an ASSERT macro", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "fff92096bb036fc19de37a2cc7621d3cd816a060", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/151/mbox/", "series": [ { "id": 53, "url": "https://patchwork.libcamera.org/api/series/53/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=53", "date": "2019-01-06T02:33:18", "name": "[libcamera-devel,01/11] libcamera: log: Add a LogFatal log level", "version": 1, "mbox": "https://patchwork.libcamera.org/series/53/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/151/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/151/checks/", "tags": {}, "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 4135260B2E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 6 Jan 2019 03:32:27 +0100 (CET)", "from avalon.bb.dnainternet.fi\n\t(dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C3E2198C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 6 Jan 2019 03:32:26 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1546741946;\n\tbh=0XeIsh/ltcYJ77DUd2giB2BsNTR17n8e+KhSX8engPE=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=J7qOj624zfagj9Mcgl0NVk5dYO6Jjo6juyH33s8O7m09c/PSUHsAP7vxMJcnnWNEq\n\ttCPHnVKPQ56DWhlDtcu8rLsNjND+IUWmHfJ+qnW3VMMiWHgw+MPa1Z81TKNzIQuBG+\n\ttH9UtAsBt4d6OOxv45fKMGu8sRP2BQ6MN/RReFvo=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sun, 6 Jan 2019 04:33:19 +0200", "Message-Id": "<20190106023328.10989-2-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.19.2", "In-Reply-To": "<20190106023328.10989-1-laurent.pinchart@ideasonboard.com>", "References": "<20190106023328.10989-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 02/11] libcamera: log: Add an ASSERT macro", "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": "Sun, 06 Jan 2019 02:32:27 -0000" }, "content": "The ASSERT() macro is similar to the assert() macro defined by the C\nstandard, but uses the libcamera logging infrastructure.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/include/log.h | 9 +++++++++\n src/libcamera/log.cpp | 16 ++++++++++++++++\n 2 files changed, 25 insertions(+)", "diff": "diff --git a/src/libcamera/include/log.h b/src/libcamera/include/log.h\nindex 03842be02d0e..774916f04274 100644\n--- a/src/libcamera/include/log.h\n+++ b/src/libcamera/include/log.h\n@@ -36,6 +36,15 @@ private:\n \n #define LOG(severity) LogMessage(__FILE__, __LINE__, Log##severity).stream()\n \n+#ifdef NDEBUG\n+#define ASSERT(condition) static_cast<void>({\t\t\t\t\\\n+\tif (condition)\t\t\t\t\t\t\t\\\n+\t\tLOG(Fatal) << \"assertion \\\"\" #condition \"\\\" failed\";\t\\\n+})\n+#else\n+#define ASSERT(condition) static_cast<void>(false && (condition))\n+#endif\n+\n } /* namespace libcamera */\n \n #endif /* __LIBCAMERA_LOG_H__ */\ndiff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp\nindex a5823c64eaa6..4165cbd654fc 100644\n--- a/src/libcamera/log.cpp\n+++ b/src/libcamera/log.cpp\n@@ -48,6 +48,22 @@ namespace libcamera {\n * terminates immediately after printing the message.\n */\n \n+/**\n+ * \\def ASSERT(condition)\n+ * \\brief Abort program execution if assertion is failed\n+ *\n+ * If \\a condition is false, ASSERT() logs an error message with the Fatal log\n+ * level and aborts program execution.\n+ *\n+ * If the macro NDEBUG is defined before including log.h, ASSERT() generates no\n+ * code.\n+ *\n+ * Using conditions that have side effects with ASSERT() is not recommended, as\n+ * these effects would depend on whether NDEBUG is defined or not. Similarly,\n+ * ASSERT() should not be used to check for errors that can occur under normal\n+ * conditions as those checks would then be removed when compiling with NDEBUG.\n+ */\n+\n static const char *log_severity_name(LogSeverity severity)\n {\n \tstatic const char * const names[] = {\n", "prefixes": [ "libcamera-devel", "02/11" ] }