From patchwork Sat May 14 08:40:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng He X-Patchwork-Id: 1631055 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=gEqfrgNO; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L0f9R29c1z9s5V for ; Sat, 14 May 2022 18:40:43 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 875E360F19; Sat, 14 May 2022 08:40:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cpp2zQDgmW4V; Sat, 14 May 2022 08:40:40 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id BC03D60F0D; Sat, 14 May 2022 08:40:39 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8EF45C007B; Sat, 14 May 2022 08:40:39 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3D68AC002D for ; Sat, 14 May 2022 08:40:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 0982860F0A for ; Sat, 14 May 2022 08:40:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lgduqx3AkSCE for ; Sat, 14 May 2022 08:40:33 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by smtp3.osuosl.org (Postfix) with ESMTPS id 57D5F60F08 for ; Sat, 14 May 2022 08:40:33 +0000 (UTC) Received: by mail-pg1-x52f.google.com with SMTP id g184so9588612pgc.1 for ; Sat, 14 May 2022 01:40:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EKa5SWZrxvZn8rQiU9GnVezg7/4xJp4N9VOspfFyKkE=; b=gEqfrgNOzAEEBZtpGiIHWMVYECeueAx04KaylAyzL3tPxPD56AwSF882WiujxwboQF odUin53oOTW6e477zkeY/OpJt6gO+l4eq0biVPzTtl1Bkve9vo6T0Z3YETskQFhEfBh2 gKwKpW80Cycxrd2Jp3wrsux3gHKUfV9nfrK56zzw3RQHLWlvXDMZqA6Ke/4aogzpqaNt 5B/Y47d5nfUW9rCS99Rwl32qmXANYmbXrTGojE/W8Y4zh5WKj+BFSli/mf1p4S6VDnj2 kN7g3aUpMrrOOihFsWiMZB9d3IHEEqZLkRU4O041wwgFKwEFiN1NsmibqGMG6fzxxYnO 3hbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EKa5SWZrxvZn8rQiU9GnVezg7/4xJp4N9VOspfFyKkE=; b=b/DrgaSvdDXnfoNRj30aebBJXO0sgw3f3xQMwEAHUrP+myzpIuF8pLRyYSmp68Xq6T 5yeCC/w/LLewuaKh2T7lh9pFg+s6XNP+OvTowWjQqrUs4c9OnXcd/R5Y+dYRyYYQb50W izSKOhvAiNBrmt11YESi4p4NH8csafi+TN0l7qJE0zO6GNBydpe37h39EfAUN2W1qJHf p7D6SB14rPKd1Jx2h8pC+PgBBCFx2TYqyO3Z+waPy5MI+7nrnPJqVcr2pbiS9M+FdqGN A6t5o4Os11/fcEEVhix/vpVoh3I1X1vfQZ+O9QsXRwZ1usJjIImPQAAJe7QLf0VXt3Q7 bmqA== X-Gm-Message-State: AOAM531aTx6bvljSR+d85YpxpkgyHpG5CuqTVnbKwY9dC/vf9CRQAcCT 06jdt1XrN9Eg1dVo4wiW57g3s57rnZPo1Q== X-Google-Smtp-Source: ABdhPJxm7hvMvT3l+9oNvAEMm2fSyDKz94jswitkqrZ3RKGfOPHPnggi4aPnN5uGbGpMN096NmqAug== X-Received: by 2002:a65:4c0c:0:b0:3c1:5bb1:6701 with SMTP id u12-20020a654c0c000000b003c15bb16701mr7144354pgq.136.1652517632475; Sat, 14 May 2022 01:40:32 -0700 (PDT) Received: from localhost ([221.194.170.169]) by smtp.gmail.com with ESMTPSA id x2-20020a170902a38200b001615ca9ab2asm6511pla.20.2022.05.14.01.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 May 2022 01:40:32 -0700 (PDT) From: Peng He X-Google-Original-From: Peng He To: dev@openvswitch.org Date: Sat, 14 May 2022 08:40:10 +0000 Message-Id: <20220514084010.119558-3-hepeng.0320@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220514084010.119558-1-hepeng.0320@bytedance.com> References: <20220514084010.119558-1-hepeng.0320@bytedance.com> MIME-Version: 1.0 Cc: david.marchand@redhat.com, i.maximets@ovn.org Subject: [ovs-dev] [ovs-dev v3 3/3] checkpatch.py: add checks for experimental API. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Signed-off-by: Peng He --- utilities/checkpatch.py | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py index 8c7faa419..67c517b69 100755 --- a/utilities/checkpatch.py +++ b/utilities/checkpatch.py @@ -619,6 +619,8 @@ def regex_function_factory(func_name): def regex_error_factory(description): return lambda: print_error(description) +def regex_warn_factory(description): + return lambda: print_warning(description) std_functions = [ ('malloc', 'Use xmalloc() in place of malloc()'), @@ -636,6 +638,7 @@ std_functions = [ ('assert', 'Use ovs_assert() in place of assert()'), ('error', 'Use ovs_error() in place of error()'), ] + checks += [ {'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None, @@ -644,6 +647,21 @@ checks += [ 'print': regex_error_factory(description)} for (function_name, description) in std_functions] +experimental_api = [ + ('ovsrcu_barrier', + 'lib/ovs-rcu.c', + 'Are you sure you need to use ovsrcu_barrier(),' + 'in most cases ovsrcu_synchronize() will be fine?'), + ] + +checks += [ + {'regex': r'(\.c)(\.in)?$', + 'match_name': lambda x: x != location, + 'prereq': lambda x: not is_comment_line(x), + 'check': regex_function_factory(function_name), + 'print': regex_warn_factory(description)} + for (function_name, location, description) in experimental_api] + def regex_operator_factory(operator): regex = re.compile(r'^[^#][^"\']*[^ "]%s[^ "\'][^"]*' % operator) @@ -676,12 +694,20 @@ def get_file_type_checks(filename): global checks checkList = [] for check in checks: + regex_check = True + match_check = True + if check['regex'] is None and check['match_name'] is None: checkList.append(check) + continue + if check['regex'] is not None and \ - re.compile(check['regex']).search(filename) is not None: - checkList.append(check) - elif check['match_name'] is not None and check['match_name'](filename): + re.compile(check['regex']).search(filename) is None: + regex_check = False + elif check['match_name'] is not None and not check['match_name'](filename): + match_check = False + + if regex_check and match_check: checkList.append(check) return checkList