From patchwork Thu May 25 20:32:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 767112 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wYgtQ0s9Vz9s8N for ; Fri, 26 May 2017 06:32:30 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 6E6ECC6F; Thu, 25 May 2017 20:32:27 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 3A330B62 for ; Thu, 25 May 2017 20:32:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 18B601D7 for ; Thu, 25 May 2017 20:32:25 +0000 (UTC) Received: from mfilter16-d.gandi.net (mfilter16-d.gandi.net [217.70.178.144]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id D565141C091 for ; Thu, 25 May 2017 22:32:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter16-d.gandi.net Received: from relay5-d.mail.gandi.net ([IPv6:::ffff:217.70.183.197]) by mfilter16-d.gandi.net (mfilter16-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id pJt6o7bi7jYQ for ; Thu, 25 May 2017 22:32:22 +0200 (CEST) X-Originating-IP: 209.85.216.170 Received: from mail-qt0-f170.google.com (mail-qt0-f170.google.com [209.85.216.170]) (Authenticated sender: joe@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 56F8941C089 for ; Thu, 25 May 2017 22:32:22 +0200 (CEST) Received: by mail-qt0-f170.google.com with SMTP id c13so190259080qtc.1 for ; Thu, 25 May 2017 13:32:22 -0700 (PDT) X-Gm-Message-State: AODbwcDnfOYd6xagsseg4+14Yv7ALNqdkRTTBHmWOUMzebxuU/dWhX1v rs3VBIFU8y3QSJAt0xHklzuIX+sGCA== X-Received: by 10.200.55.193 with SMTP id e1mr45488210qtc.198.1495744341091; Thu, 25 May 2017 13:32:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.174.123 with HTTP; Thu, 25 May 2017 13:32:00 -0700 (PDT) In-Reply-To: <20170525201042.GI2820@ovn.org> References: <20170524005716.25105-1-joe@ovn.org> <20170525201042.GI2820@ovn.org> From: Joe Stringer Date: Thu, 25 May 2017 13:32:00 -0700 X-Gmail-Original-Message-ID: Message-ID: To: Ben Pfaff , Aaron Conole X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: ovs dev Subject: Re: [ovs-dev] [PATCHv2] checkpatch: Check for stdlib usage. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org On 25 May 2017 at 13:10, Ben Pfaff wrote: > On Tue, May 23, 2017 at 05:57:16PM -0700, Joe Stringer wrote: >> Many standard library functions are wrapped in OVS, so check for usage >> of the original versions and suggest that authors replace them with the >> OVS versions. >> >> Signed-off-by: Joe Stringer > > Acked-by: Ben Pfaff Thanks for the reviews. Turns out that the wrong error message was returned unless I had the error description factory separately defined, so I'll roll this incremental in and push to master shortly: diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py index d1941c441248..443b8c0481c2 100755 --- a/utilities/checkpatch.py +++ b/utilities/checkpatch.py @@ -215,6 +215,10 @@ def regex_function_factory(func_name): return lambda x: regex.search(x) is not None +def regex_error_factory(description): + return lambda: print_error(description) + + std_functions = [ ('malloc', 'Use xmalloc() in place of malloc()'), ('calloc', 'Use xcalloc() in place of calloc()'), @@ -234,8 +238,8 @@ checks += [ {'regex': '(.c|.h)(.in)?$', 'match_name': None, 'check': regex_function_factory(function_name), - 'print': lambda: print_error(description)} -for function_name, description in std_functions] + 'print': regex_error_factory(description)} + for (function_name, description) in std_functions] def get_file_type_checks(filename):