[{"id":29702,"web_url":"https://patchwork.libcamera.org/comment/29702/","msgid":"<ZlnOM0R4VRglQfAF@pyrite.rasen.tech>","date":"2024-05-31T13:18:43","subject":"Re: [PATCH 3/4] utils: checkstyle.py: Add a check for hex values","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:37PM +0300, Laurent Pinchart wrote:\n> libcamera uses lowercase hex values. Add a corresponding checker.\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 | 28 ++++++++++++++++++++++++++++\n>  1 file changed, 28 insertions(+)\n> \n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index f3604299de94..77d6f39011c1 100755\n> --- a/utils/checkstyle.py\n> +++ b/utils/checkstyle.py\n> @@ -562,6 +562,34 @@ class StyleIssue(object):\n>          self.msg = msg\n>  \n>  \n> +class HexValueChecker(StyleChecker):\n> +    patterns = ('*.c', '*.cpp', '*.h')\n> +\n> +    regex = re.compile(r'\\b0[xX][0-9a-fA-F]+\\b')\n> +\n> +    def __init__(self, content):\n> +        super().__init__()\n> +        self.__content = content\n> +\n> +    def check(self, line_numbers):\n> +        issues = []\n> +\n> +        for line_number in line_numbers:\n> +            line = self.__content[line_number - 1]\n> +            match = HexValueChecker.regex.search(line)\n> +            if not match:\n> +                continue\n> +\n> +            value = match.group(0)\n> +            if value == value.lower():\n> +                continue\n> +\n> +            issues.append(StyleIssue(line_number, line,\n> +                                     f'Use lowercase hex constant {value.lower()}'))\n> +\n> +        return issues\n> +\n> +\n>  class IncludeChecker(StyleChecker):\n>      patterns = ('*.cpp', '*.h')","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 0775FBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 May 2024 13:18:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A9997634B2;\n\tFri, 31 May 2024 15:18:51 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8E452634AF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 May 2024 15:18:49 +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 C2F81A06;\n\tFri, 31 May 2024 15:18:43 +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=\"nEyK7/w7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717161524;\n\tbh=wfUEakZanf3IF9Z22yLukOLqMu3QolCIM8ltlDstRS8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=nEyK7/w7ehj43KjyMb1YqFrtQJwDANkThEvPfbb6LrYkxHgMhAbhBGJQearMDNNF7\n\tCm1E5i2RWIOp9xvYJUIn8W4UJNTYx8J2YIKloBWoxpPLntJsLXb9rdU0qXPYaFkHoH\n\twzASLfvRMXTJmbis/tijwMgpeIYcLHTmh5p2bCYo=","Date":"Fri, 31 May 2024 22:18:43 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 3/4] utils: checkstyle.py: Add a check for hex values","Message-ID":"<ZlnOM0R4VRglQfAF@pyrite.rasen.tech>","References":"<20240531121838.27643-1-laurent.pinchart@ideasonboard.com>\n\t<20240531121838.27643-4-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20240531121838.27643-4-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":29706,"web_url":"https://patchwork.libcamera.org/comment/29706/","msgid":"<171716255006.2228432.1971927216977376834@ping.linuxembedded.co.uk>","date":"2024-05-31T13:35:50","subject":"Re: [PATCH 3/4] utils: checkstyle.py: Add a check for hex values","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:37)\n> libcamera uses lowercase hex values. Add a corresponding checker.\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 | 28 ++++++++++++++++++++++++++++\n>  1 file changed, 28 insertions(+)\n> \n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index f3604299de94..77d6f39011c1 100755\n> --- a/utils/checkstyle.py\n> +++ b/utils/checkstyle.py\n> @@ -562,6 +562,34 @@ class StyleIssue(object):\n>          self.msg = msg\n>  \n>  \n> +class HexValueChecker(StyleChecker):\n> +    patterns = ('*.c', '*.cpp', '*.h')\n> +\n> +    regex = re.compile(r'\\b0[xX][0-9a-fA-F]+\\b')\n> +\n> +    def __init__(self, content):\n> +        super().__init__()\n> +        self.__content = content\n> +\n> +    def check(self, line_numbers):\n> +        issues = []\n> +\n> +        for line_number in line_numbers:\n> +            line = self.__content[line_number - 1]\n> +            match = HexValueChecker.regex.search(line)\n> +            if not match:\n> +                continue\n> +\n> +            value = match.group(0)\n> +            if value == value.lower():\n> +                continue\n> +\n> +            issues.append(StyleIssue(line_number, line,\n> +                                     f'Use lowercase hex constant {value.lower()}'))\n> +\n> +        return issues\n> +\n> +\n>  class IncludeChecker(StyleChecker):\n>      patterns = ('*.cpp', '*.h')\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 D6ADABDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 May 2024 13:35:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 029E3634B8;\n\tFri, 31 May 2024 15:35:55 +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 F335461A46\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 May 2024 15:35:52 +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 D4069A06;\n\tFri, 31 May 2024 15:35:47 +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=\"HwCnXhmS\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717162547;\n\tbh=hHJjJhxCNs/GhlCdMuQWIT8oeKaQqLz7tDuGgQnQVfc=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=HwCnXhmSFfDZ2HCFlwYWoyBY9uK3zqwRFKcqo43s1XQEzvCq+795t0qZ+19xsAiaa\n\t41IZoaoexsgPNaFeTQjftt+/JUFgBH5lHrpyNJvo/3eQrdz1fW9U3RcRmQI69WbZAw\n\tB1Cwwkv/61fSyjkLvTvsZNNvtHscwUFd0yDk15Ng=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240531121838.27643-4-laurent.pinchart@ideasonboard.com>","References":"<20240531121838.27643-1-laurent.pinchart@ideasonboard.com>\n\t<20240531121838.27643-4-laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH 3/4] utils: checkstyle.py: Add a check for hex values","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:35:50 +0100","Message-ID":"<171716255006.2228432.1971927216977376834@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>"}}]