Patch Detail
Show a patch.
GET /api/patches/165/?format=api
{ "id": 165, "url": "https://patchwork.libcamera.org/api/patches/165/?format=api", "web_url": "https://patchwork.libcamera.org/patch/165/", "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": "<20190107231151.23291-3-laurent.pinchart@ideasonboard.com>", "date": "2019-01-07T23:11:42", "name": "[libcamera-devel,v2,02/11] libcamera: log: Add an ASSERT macro", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "f68404c39ad6f652ed13e9f07118416a7b3de154", "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/165/mbox/", "series": [ { "id": 56, "url": "https://patchwork.libcamera.org/api/series/56/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=56", "date": "2019-01-07T23:11:40", "name": "libcamera: Add event notification and timers", "version": 2, "mbox": "https://patchwork.libcamera.org/series/56/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/165/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/165/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "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 1C51A60B2F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 8 Jan 2019 00:10:48 +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 A91BCE51\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 8 Jan 2019 00:10:47 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1546902647;\n\tbh=1iJndoZVAjgGU+M99GCZ2vKTWSQf5zRnJfjSlaFkzvE=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=ceChrHHLXVXW7nm0G4+VbJS/pkSox5zFm4mfxuXhx7YolfJ+I/hFlZ0nsQI7Fetbi\n\t+hCZ8bLQON9n4e+6m4/mSfrGaL9/tI6+raAU+2GmfPF26cM9csufai38sEETPLDupc\n\t1INHcZJf9GfIZjFdxdFv8WFbtdcw5DMmbaagTTI0=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 8 Jan 2019 01:11:42 +0200", "Message-Id": "<20190107231151.23291-3-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.19.2", "In-Reply-To": "<20190107231151.23291-1-laurent.pinchart@ideasonboard.com>", "References": "<20190107231151.23291-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 02/11] libcamera: log: Add an ASSERT\n\tmacro", "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": "Mon, 07 Jan 2019 23:10:48 -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>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\nChanges since v1:\n\n- Fix syntax error in ASSERT() macro\n- Fix NDEBUG conditional compilation\n- Fix typo in documentation\n- Fix ASSERT() condition check\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..c1af3741ffee 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+#ifndef 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..6785d371449e 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 fails\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", "v2", "02/11" ] }