On 22 May 2017 at 17:53, Ben Pfaff <b...@ovn.org> wrote:
> On Mon, May 22, 2017 at 03:51:39PM -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 <j...@ovn.org>
>
> Thanks for working to improve the patch checks!
>
>> +def regex_function_factory(func_name):
>> +    regex = re.compile('[^x]%s\([^)]*\)' % func_name)
>> +    return lambda x: regex.search(x) is not None
>> +
>> +
>> +std_functions = [
>> +        ('malloc', 'Use xmalloc() in place of malloc()'),
>> +        ('calloc', 'Use xcmalloc() in place of calloc()'),
>
> xcalloc, not xcmalloc
>
>> +        ('zalloc', 'Use xzmalloc() in place of zalloc()'),
>
> I don't think there's a zalloc function.
>
>> +        ('realloc', 'Use xrealloc() in place of realloc()'),
>> +        ('memdup', 'Use xmemdup() in place of memdup()'),
>> +        ('memdup0', 'Use xmemdup0() in place of memdup0()'),
>
> I don't think there's a memdup0 function.
>
>> +        ('strdup', 'Use xstrdup() in place of strdup()'),
>> +        ('asprintf', 'Use xasprintf() in place of asprintf()'),
>> +        ('vasprintf', 'Use xvasprintf() in place of vasprintf()'),
>> +        ('2nrealloc', 'Use x2nrealloc() in place of 2nrealloc()'),
>
> I don't think there's a 2nrealloc function.
>
>> +        ('strlcpy', 'Use ovs_strlcpy() in place of strlcpy()'),
>> +        ('strzcpy', 'Use ovs_strzcpy() in place of strzcpy()'),
>
> I don't think there's a strzcpy function, but ovs_strzcpy() might be a
> substitute for strncpy.
>
> It can often be a good idea to use ovs_strlcpy() in place of plain
> strcpy().
>
>> +        ('strerror', 'Use ovs_strerror() in place of strerror()'),
>> +        ('sleep', 'Use xsleep() in place of sleep()'),
>> +        ('abort', 'Use xabort() in place of abort()'),
>
> I don't think we have an xabort function.
>
>> +        ('error', 'Use xerror() in place of error()'),
>
> I don't know of either error *or* xerror functions.

:-) Thanks for looking through. I started from lib/util.h and assumed
that anything prefaced with 'x' replaces a common library function.

For xabort/xerror I think I was looking at ovs_abort() and
ovs_error(). The former is probably a useful substitute but perhaps
not the latter.

I'll send a v2.
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to