Checkpatch contains a large list of spelling words, currently 326.  The
in-built list is quite cumbersome, and includes duplicate entries
('netdev' and 'revalidation').  Managing this list will continue to grow
difficult over time, and really shouldn't be so difficult.  To make the
maintenance of OVS specific spelling words easier, create a new file
that will contain the spelling words and move the list into that file
(sorted).  This patch adds 'FreeBSD' and 'gcloud' to the list as it
was tested against
80d723736b64 ("cirrus: Update to FreeBSD 14.3 and 13.5.").  It also
adds "apis", "enablement", "ifdef", and "tnl" after the patch proposed
by Eelco at the referenced link.

Ref: 
https://patchwork.ozlabs.org/project/openvswitch/patch/d6fecfc9491893b852ff9de3ef8b7ef068535d6d.1750328980.git.echau...@redhat.com/
Signed-off-by: Aaron Conole <acon...@redhat.com>
---
v3->v4: * Rename variables in checkpatch.py to closer align what's going on
        * Reference the words added from Eelco's patch
        * Add the ability to cut error lines from the checkpatch_c_file and
          use that to catch the warning for 'naintenance'.  An alternative
          approach could be to disable spelling suggestions, but that may
          be a useful independent feature, so I'd prefer to introduce that
          as a separate patch.

 tests/checkpatch.at           |  43 ++++-
 utilities/automake.mk         |   1 +
 utilities/checkpatch.py       |  73 +-------
 utilities/checkpatch_dict.txt | 330 ++++++++++++++++++++++++++++++++++
 4 files changed, 377 insertions(+), 70 deletions(-)
 create mode 100644 utilities/checkpatch_dict.txt

diff --git a/tests/checkpatch.at b/tests/checkpatch.at
index 3182ca8808..da0e07f054 100755
--- a/tests/checkpatch.at
+++ b/tests/checkpatch.at
@@ -39,10 +39,12 @@ Subject: Patch this is.
     fi
 }
 
-# try_checkpatch_c_file SOURCE [ERRORS] [CHECKPATCH-ARGS]
+# try_checkpatch_c_file SOURCE [ERRORS] [CHECKPATCH-ARGS] [ALLOWFILTER]
 #
 # Runs checkpatch against test SOURCE expecting the set of specified
-# ERRORS (and warnings).  Optionally, sets [CHECKPATCH-ARGS]
+# ERRORS (and warnings).  Optionally, sets [CHECKPATCH-ARGS].  The
+# optional ALLOWFILTER can be used to adjust the expected output before
+# processing.
 try_checkpatch_c_file() {
    echo "$1" | sed 's/^    //' > test.c
 
@@ -57,7 +59,8 @@ try_checkpatch_c_file() {
        AT_CHECK([OVS_SRC_DIR=$top_srcdir $PYTHON3 \
                    $top_srcdir/utilities/checkpatch.py $3 -q -f test.c],
                 [1], [stdout])
-       AT_CHECK([sed '/^Lines checked:/,$d' stdout], [0], [expout])
+       AT_CHECK([sed "$4
+/^Lines checked:/,$$d" stdout], [0], [expout])
    else
        AT_CHECK([OVS_SRC_DIR=$top_srcdir $PYTHON3 \
                    $top_srcdir/utilities/checkpatch.py $3 -q -f test.c])
@@ -726,3 +729,37 @@ try_checkpatch_c_file \
     "
 done
 AT_CLEANUP
+
+AT_SETUP([checkpatch - spelling checks])
+AT_SKIP_IF([! $PYTHON3 -c 'import enchant' >/dev/null 2>&1])
+
+dnl First check with some default words
+
+try_checkpatch_c_file \
+   "#include <foo.h>
+    #include <bar.h>
+
+    /* naintenance mode */
+    void foo() {
+       $ctr ( first_run ) {
+          something(check_node);
+       }
+    }" \
+    "WARNING: Possible misspelled word: \"naintenance\"" \
+    "-S" \
+    "/^Did you mean:/,$$d"
+
+try_checkpatch_c_file \
+   "#include <foo.h>
+    #include <bar.h>
+
+    /* hugepage mode */
+    void foo() {
+       $ctr ( first_run ) {
+          something(check_node);
+       }
+    }" \
+    "" \
+    "-S"
+
+AT_CLEANUP
diff --git a/utilities/automake.mk b/utilities/automake.mk
index fcd353109d..a76e077e1f 100644
--- a/utilities/automake.mk
+++ b/utilities/automake.mk
@@ -66,6 +66,7 @@ EXTRA_DIST += \
        utilities/ovs-vlan-test.in \
        utilities/ovs-vsctl-bashcomp.bash \
        utilities/checkpatch.py \
+       utilities/checkpatch_dict.txt \
        utilities/docker/Makefile \
        utilities/docker/ovs-override.conf \
        utilities/docker/start-ovs \
diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index 566a2bd60b..28d0977eb4 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -56,71 +56,6 @@ def open_spell_check_dict():
         pass
 
     try:
-        extra_keywords = ['ovs', 'vswitch', 'vswitchd', 'ovs-vswitchd',
-                          'netdev', 'selinux', 'ovs-ctl', 'dpctl', 'ofctl',
-                          'openvswitch', 'dpdk', 'hugepage', 'hugepages',
-                          'pmd', 'upcall', 'vhost', 'rx', 'tx', 'vhostuser',
-                          'openflow', 'qsort', 'rxq', 'txq', 'perf', 'stats',
-                          'struct', 'int', 'char', 'bool', 'upcalls', 'nicira',
-                          'bitmask', 'ipv4', 'ipv6', 'tcp', 'tcp4', 'tcpv4',
-                          'udp', 'udp4', 'udpv4', 'icmp', 'icmp4', 'icmpv6',
-                          'vlan', 'vxlan', 'cksum', 'csum', 'checksum',
-                          'ofproto', 'numa', 'mempool', 'mempools', 'mbuf',
-                          'mbufs', 'hmap', 'cmap', 'smap', 'dhcpv4', 'dhcp',
-                          'dhcpv6', 'opts', 'metadata', 'geneve', 'mutex',
-                          'netdev', 'netdevs', 'subtable', 'virtio', 'qos',
-                          'policer', 'datapath', 'tunctl', 'attr', 'ethernet',
-                          'ether', 'defrag', 'defragment', 'loopback', 'sflow',
-                          'acl', 'initializer', 'recirc', 'xlated', 'unclosed',
-                          'netlink', 'msec', 'usec', 'nsec', 'ms', 'us', 'ns',
-                          'kilobits', 'kbps', 'kilobytes', 'megabytes', 'mbps',
-                          'gigabytes', 'gbps', 'megabits', 'gigabits', 'pkts',
-                          'tuple', 'miniflow', 'megaflow', 'conntrack',
-                          'vlans', 'vxlans', 'arg', 'tpid', 'xbundle',
-                          'xbundles', 'mbundle', 'mbundles', 'netflow',
-                          'localnet', 'odp', 'pre', 'dst', 'dest', 'src',
-                          'ethertype', 'cvlan', 'ips', 'msg', 'msgs',
-                          'liveness', 'userspace', 'eventmask', 'datapaths',
-                          'slowpath', 'fastpath', 'multicast', 'unicast',
-                          'revalidation', 'namespace', 'qdisc', 'uuid',
-                          'ofport', 'subnet', 'revalidation', 'revalidator',
-                          'revalidate', 'l2', 'l3', 'l4', 'openssl', 'mtu',
-                          'ifindex', 'enum', 'enums', 'http', 'https', 'num',
-                          'vconn', 'vconns', 'conn', 'nat', 'memset', 'memcmp',
-                          'strcmp', 'strcasecmp', 'tc', 'ufid', 'api',
-                          'ofpbuf', 'ofpbufs', 'hashmaps', 'hashmap', 'deref',
-                          'dereference', 'hw', 'prio', 'sendmmsg', 'sendmsg',
-                          'malloc', 'free', 'alloc', 'pid', 'ppid', 'pgid',
-                          'uid', 'gid', 'sid', 'utime', 'stime', 'cutime',
-                          'cstime', 'vsize', 'rss', 'rsslim', 'whcan', 'gtime',
-                          'eip', 'rip', 'cgtime', 'dbg', 'gw', 'sbrec', 'bfd',
-                          'sizeof', 'pmds', 'nic', 'nics', 'hwol', 'encap',
-                          'decap', 'tlv', 'tlvs', 'decapsulation', 'fd',
-                          'cacheline', 'xlate', 'skiplist', 'idl',
-                          'comparator', 'natting', 'alg', 'pasv', 'epasv',
-                          'wildcard', 'nated', 'amd64', 'x86_64',
-                          'recirculation', 'linux', 'afxdp', 'promisc', 'goto',
-                          'misconfigured', 'misconfiguration', 'checkpatch',
-                          'debian', 'travis', 'cirrus', 'appveyor', 'faq',
-                          'erspan', 'const', 'hotplug', 'addresssanitizer',
-                          'ovsdb', 'dpif', 'veth', 'rhel', 'jsonrpc', 'json',
-                          'syscall', 'lacp', 'ipf', 'skb', 'valgrind',
-                          'appctl', 'arp', 'asan', 'backport', 'backtrace',
-                          'chmod', 'ci', 'cpu', 'cpus', 'dnat', 'dns', 'dpcls',
-                          'eol', 'ethtool', 'fdb', 'freebsd', 'gcc', 'github',
-                          'glibc', 'gre', 'inlined', 'ip', 'ipfix', 'ipsec',
-                          'ixgbe', 'libbpf', 'libcrypto', 'libgcc',
-                          'libopenvswitch', 'libreswan', 'libssl', 'libxdp',
-                          'lldp', 'llvm', 'lockless', 'mcast', 'megaflows',
-                          'mfex', 'ncat', 'networkmanager', 'pcap', 'pedit',
-                          'pidfile', 'pps', 'rculist', 'rebalance', 'rebased'
-                          'recirculations', 'revalidators', 'rst', 'sed',
-                          'shrinked', 'snat', 'stderr', 'stdout', 'testpmd',
-                          'tftp', 'timeval', 'trie', 'tso', 'ubsan', 'ukey',
-                          'umask', 'unassociated', 'unixctl', 'uuid'
-                          'virtqueue', 'vms', 'vnet', 'vport', 'vports',
-                          'vtep', 'wc', 'wget', 'xenserver', 'util']
-
         global spell_check_dict
 
         spell_check_dict = enchant.Dict("en_US")
@@ -132,8 +67,12 @@ def open_spell_check_dict():
                     for word in words:
                         spell_check_dict.add_to_session(word.strip())
 
-        for kw in extra_keywords:
-            spell_check_dict.add_to_session(kw)
+        check_dict_file = os.path.join(get_top_directory(), "utilities",
+                                       "checkpatch_dict.txt")
+        if os.path.exists(check_dict_file):
+            with open(check_dict_file, "r") as project_words:
+                for check_word in project_words:
+                    spell_check_dict.add_to_session(check_word.strip())
 
         return True
     except:
diff --git a/utilities/checkpatch_dict.txt b/utilities/checkpatch_dict.txt
new file mode 100644
index 0000000000..13f107246b
--- /dev/null
+++ b/utilities/checkpatch_dict.txt
@@ -0,0 +1,330 @@
+acl
+addresssanitizer
+afxdp
+alg
+alloc
+amd64
+api
+apis
+appctl
+appveyor
+arg
+arp
+asan
+attr
+backport
+backtrace
+bfd
+bitmask
+bool
+cacheline
+cgtime
+char
+checkpatch
+checksum
+chmod
+ci
+cirrus
+cksum
+cmap
+comparator
+conn
+conntrack
+const
+cpu
+cpus
+cstime
+csum
+cutime
+cvlan
+datapath
+datapaths
+dbg
+debian
+decap
+decapsulation
+defrag
+defragment
+deref
+dereference
+dest
+dhcp
+dhcpv4
+dhcpv6
+dnat
+dns
+dpcls
+dpctl
+dpdk
+dpif
+dst
+eip
+enablement
+encap
+enum
+enums
+eol
+epasv
+erspan
+ether
+ethernet
+ethertype
+ethtool
+eventmask
+faq
+fastpath
+fd
+fdb
+free
+freebsd
+FreeBSD
+gbps
+gcc
+gcloud
+geneve
+gid
+gigabits
+gigabytes
+github
+glibc
+goto
+gre
+gtime
+gw
+hashmap
+hashmaps
+hmap
+hotplug
+http
+https
+hugepage
+hugepages
+hw
+hwol
+icmp
+icmp4
+icmpv6
+idl
+ifdef
+ifindex
+initializer
+inlined
+int
+ip
+ipf
+ipfix
+ips
+ipsec
+ipv4
+ipv6
+ixgbe
+json
+jsonrpc
+kbps
+kilobits
+kilobytes
+l2
+l3
+l4
+lacp
+libbpf
+libcrypto
+libgcc
+libopenvswitch
+libreswan
+libssl
+libxdp
+linux
+liveness
+lldp
+llvm
+localnet
+lockless
+loopback
+malloc
+mbps
+mbuf
+mbufs
+mbundle
+mbundles
+mcast
+megabits
+megabytes
+megaflow
+megaflows
+memcmp
+mempool
+mempools
+memset
+metadata
+mfex
+miniflow
+misconfiguration
+misconfigured
+ms
+msec
+msg
+msgs
+mtu
+multicast
+mutex
+namespace
+nat
+nated
+natting
+ncat
+netdev
+netdevs
+netflow
+netlink
+networkmanager
+nic
+nicira
+nics
+ns
+nsec
+num
+numa
+odp
+ofctl
+ofpbuf
+ofpbufs
+ofport
+ofproto
+openflow
+openssl
+openvswitch
+opts
+ovs
+ovs-ctl
+ovsdb
+ovs-vswitchd
+pasv
+pcap
+pedit
+perf
+pgid
+pid
+pidfile
+pkts
+pmd
+pmds
+policer
+ppid
+pps
+pre
+prio
+promisc
+qdisc
+qos
+qsort
+rculist
+rebalance
+rebased
+recirc
+recirculation
+recirculations
+revalidate
+revalidation
+revalidator
+revalidators
+rhel
+rip
+rss
+rsslim
+rst
+rx
+rxq
+sbrec
+sed
+selinux
+sendmmsg
+sendmsg
+sflow
+shrinked
+sid
+sizeof
+skb
+skiplist
+slowpath
+smap
+snat
+src
+stats
+stderr
+stdout
+stime
+strcasecmp
+strcmp
+struct
+subnet
+subtable
+syscall
+tc
+tcp
+tcp4
+tcpv4
+testpmd
+tftp
+timeval
+tlv
+tlvs
+tnl
+tpid
+travis
+trie
+tso
+tunctl
+tuple
+tx
+txq
+ubsan
+udp
+udp4
+udpv4
+ufid
+uid
+ukey
+umask
+unassociated
+unclosed
+unicast
+unixctl
+upcall
+upcalls
+us
+usec
+userspace
+util
+utime
+uuid
+valgrind
+vconn
+vconns
+veth
+vhost
+vhostuser
+virtio
+virtqueue
+vlan
+vlans
+vms
+vnet
+vport
+vports
+vsize
+vswitch
+vswitchd
+vtep
+vxlan
+vxlans
+wc
+wget
+whcan
+wildcard
+x86_64
+xbundle
+xbundles
+xenserver
+xlate
+xlated
-- 
2.49.0

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to