{"id":20166,"url":"https://patchwork.libcamera.org/api/1.1/patches/20166/?format=json","web_url":"https://patchwork.libcamera.org/patch/20166/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20240531121838.27643-2-laurent.pinchart@ideasonboard.com>","date":"2024-05-31T12:18:35","name":"[1/4] utils: checkstyle.py: Refactor IncludeChecker","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"1ee7a491220ed7d2a92725eae66c89a13c722bbd","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20166/mbox/","series":[{"id":4346,"url":"https://patchwork.libcamera.org/api/1.1/series/4346/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4346","date":"2024-05-31T12:18:34","name":"utils: checkstyle.py: Miscellaneous improvements","version":1,"mbox":"https://patchwork.libcamera.org/series/4346/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20166/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20166/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 6B955BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 May 2024 12:18:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0C509634BC;\n\tFri, 31 May 2024 14:18:57 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BE99861A46\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 May 2024 14:18:53 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BF5A111A3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 May 2024 14:18:48 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"LxKVPtFY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717157929;\n\tbh=NLtLXJjZSN7auouiRWIkJcgqCnCtwD6FHbaPlDwokgs=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=LxKVPtFYsJ0ID2t6qF9619NxckqrvmYljuYL5LDmspVlMhR8ZJrSaM8mb+NyGSc+D\n\tYAdfIYkvT4uNkDdbcz05nb8T2ebJ34UeFiRMGubwJMxmS0WqYG8v5poZMED7egK6sH\n\tMYvsY4bdogLMFafvw/9sGkJ6y8Tjwl37/T4CnqL0=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH 1/4] utils: checkstyle.py: Refactor IncludeChecker","Date":"Fri, 31 May 2024 15:18:35 +0300","Message-ID":"<20240531121838.27643-2-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.44.1","In-Reply-To":"<20240531121838.27643-1-laurent.pinchart@ideasonboard.com>","References":"<20240531121838.27643-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The IncludeCheck warns when code uses C++ standard library headers where\ncorresponding C compatibility headers are preferred. We have an\nexception to that rule for math.h, where cmath is prefered. In order to\nprepare for extending checkstyle.py to enforce that rule, refactor the\nway the IncludeChecker identifies headers. No functional change is\nintended.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n utils/checkstyle.py | 13 +++++++------\n 1 file changed, 7 insertions(+), 6 deletions(-)","diff":"diff --git a/utils/checkstyle.py b/utils/checkstyle.py\nindex 4e287b2e0053..518be0897db5 100755\n--- a/utils/checkstyle.py\n+++ b/utils/checkstyle.py\n@@ -565,11 +565,11 @@ class StyleIssue(object):\n class IncludeChecker(StyleChecker):\n     patterns = ('*.cpp', '*.h')\n \n-    headers = ('assert', 'ctype', 'errno', 'fenv', 'float', 'inttypes',\n-               'limits', 'locale', 'setjmp', 'signal', 'stdarg', 'stddef',\n-               'stdint', 'stdio', 'stdlib', 'string', 'time', 'uchar', 'wchar',\n-               'wctype')\n-    include_regex = re.compile(r'^#include <c([a-z]*)>')\n+    headers = ('cassert', 'cctype', 'cerrno', 'cfenv', 'cfloat', 'cinttypes',\n+               'climits', 'clocale', 'csetjmp', 'csignal', 'cstdarg', 'cstddef',\n+               'cstdint', 'cstdio', 'cstdlib', 'cstring', 'ctime', 'cuchar',\n+               'cwchar', 'cwctype')\n+    include_regex = re.compile(r'^#include <([a-z.]*)>')\n \n     def __init__(self, content):\n         super().__init__()\n@@ -588,8 +588,9 @@ class IncludeChecker(StyleChecker):\n             if header not in IncludeChecker.headers:\n                 continue\n \n+            header = header[1:] + '.h'\n             issues.append(StyleIssue(line_number, line,\n-                                     'C compatibility header <%s.h> is preferred' % header))\n+                                     'C compatibility header <%s> is preferred' % header))\n \n         return issues\n \n","prefixes":["1/4"]}