[{"id":29700,"web_url":"https://patchwork.libcamera.org/comment/29700/","msgid":"<ZlnN9RJ1twvCLTe-@pyrite.rasen.tech>","date":"2024-05-31T13:17:41","subject":"Re: [PATCH 1/4] utils: checkstyle.py: Refactor IncludeChecker","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Fri, May 31, 2024 at 03:18:35PM +0300, Laurent Pinchart wrote:\n> The IncludeCheck warns when code uses C++ standard library headers where\n> corresponding C compatibility headers are preferred. We have an\n> exception to that rule for math.h, where cmath is prefered. In order to\n> prepare for extending checkstyle.py to enforce that rule, refactor the\n> way the IncludeChecker identifies headers. No functional change is\n> intended.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  utils/checkstyle.py | 13 +++++++------\n>  1 file changed, 7 insertions(+), 6 deletions(-)\n> \n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index 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","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 1AAEBBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 May 2024 13:17:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CC1DD634B8;\n\tFri, 31 May 2024 15:17:49 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BD09161A46\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 May 2024 15:17:48 +0200 (CEST)","from pyrite.rasen.tech (h175-177-049-156.catv02.itscom.jp\n\t[175.177.49.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F1333A06;\n\tFri, 31 May 2024 15:17:42 +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=\"mOaGi0aC\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717161463;\n\tbh=Nu3m4zgtq6ABZv2Po08BEZ5Km871kLbvKUTkWCEFkMQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=mOaGi0aCUKgglpzg0CAVIgyh9+r1zQymouzA7nsCRU5ejP3TL9zuxvZh84xez0sVG\n\tcVQRiXSAWmIshu4aAAq2ESJpT+I5nXmBjGC3qACA9r0i5JgKp1RdV6zCE0u11apP0L\n\tX9QDGuUD+ZwOUeEpMiUsPZqJokCqHddsfJlqcA6Y=","Date":"Fri, 31 May 2024 22:17:41 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 1/4] utils: checkstyle.py: Refactor IncludeChecker","Message-ID":"<ZlnN9RJ1twvCLTe-@pyrite.rasen.tech>","References":"<20240531121838.27643-1-laurent.pinchart@ideasonboard.com>\n\t<20240531121838.27643-2-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20240531121838.27643-2-laurent.pinchart@ideasonboard.com>","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>"}},{"id":29705,"web_url":"https://patchwork.libcamera.org/comment/29705/","msgid":"<171716241931.2228432.1408479540597836801@ping.linuxembedded.co.uk>","date":"2024-05-31T13:33:39","subject":"Re: [PATCH 1/4] utils: checkstyle.py: Refactor IncludeChecker","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2024-05-31 13:18:35)\n> The IncludeCheck warns when code uses C++ standard library headers where\n> corresponding C compatibility headers are preferred. We have an\n> exception to that rule for math.h, where cmath is prefered. In order to\n> prepare for extending checkstyle.py to enforce that rule, refactor the\n> way the IncludeChecker identifies headers. No functional change is\n> intended.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  utils/checkstyle.py | 13 +++++++------\n>  1 file changed, 7 insertions(+), 6 deletions(-)\n> \n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index 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> -- \n> Regards,\n> \n> Laurent Pinchart\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 80F5ABD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 May 2024 13:33:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3D431634BF;\n\tFri, 31 May 2024 15:33:44 +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 2C719634BA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 May 2024 15:33:43 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 93CF0A06;\n\tFri, 31 May 2024 15:33:37 +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=\"e+5Ac7VN\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717162417;\n\tbh=WF9y8D6WHmqoyyIdf3VxxPFxwEHoGJCLJKMDdjkjdo4=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=e+5Ac7VN2C3y0udrnL+qI0fCSiAXtAUiDlJYDjw9Vuzav3RV5ef7EWQzTzD7kyV9l\n\tk3rTmEimM2KIiL6M/rB4JP3DMPATSUOxkHMZ7u8BvoxpJO00WKQq/5xQQDkPfVikJ/\n\t06JExK8LnOaEjrCox0i3Rs5NhbZBNqVqQyf4Zpi8=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240531121838.27643-2-laurent.pinchart@ideasonboard.com>","References":"<20240531121838.27643-1-laurent.pinchart@ideasonboard.com>\n\t<20240531121838.27643-2-laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH 1/4] utils: checkstyle.py: Refactor IncludeChecker","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 31 May 2024 14:33:39 +0100","Message-ID":"<171716241931.2228432.1408479540597836801@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}}]