diff mbox

[ovs-dev,PATCHv2] checkpatch: Check for stdlib usage.

Message ID CAPWQB7Gdd1ze_GQcubYRANXHQMpP3BKZBDFkE6LwAMrnNqNtXA@mail.gmail.com
State Not Applicable
Headers show

Commit Message

Joe Stringer May 25, 2017, 8:32 p.m. UTC
On 25 May 2017 at 13:10, Ben Pfaff <blp@ovn.org> 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 <joe@ovn.org>
>
> Acked-by: Ben Pfaff <blp@ovn.org>

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 mbox

Patch

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):