From patchwork Mon Oct 30 20:10:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1857226 X-Patchwork-Delegate: i.maximets@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SK4BH71lJz1yQ4 for ; Tue, 31 Oct 2023 07:09:59 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 8EE0D80E35; Mon, 30 Oct 2023 20:09:54 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 8EE0D80E35 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nXNWD4K1JMZo; Mon, 30 Oct 2023 20:09:53 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 3178C80EB6; Mon, 30 Oct 2023 20:09:52 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 3178C80EB6 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 06195C007F; Mon, 30 Oct 2023 20:09:52 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6259EC008C for ; Mon, 30 Oct 2023 20:09:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 2E95F80C27 for ; Mon, 30 Oct 2023 20:09:49 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 2E95F80C27 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SzcNQWaM4owx for ; Mon, 30 Oct 2023 20:09:48 +0000 (UTC) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.osuosl.org (Postfix) with ESMTPS id DCA9580A5F for ; Mon, 30 Oct 2023 20:09:47 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org DCA9580A5F Received: by mail.gandi.net (Postfix) with ESMTPSA id 300D61C0005; Mon, 30 Oct 2023 20:09:46 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Mon, 30 Oct 2023 21:10:44 +0100 Message-ID: <20231030201054.136934-2-i.maximets@ovn.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231030201054.136934-1-i.maximets@ovn.org> References: <20231030201054.136934-1-i.maximets@ovn.org> MIME-Version: 1.0 X-GND-Sasl: i.maximets@ovn.org Cc: Ilya Maximets Subject: [ovs-dev] [PATCH 1/6] automake: Move build-aux EXTRA_DIST updates to their own file. 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" Otherwise it's hard to keep track of all the scripts we have. Signed-off-by: Ilya Maximets Acked-by: Eelco Chaudron --- build-aux/automake.mk | 10 +++++++++- datapath-windows/include/automake.mk | 2 -- include/automake.mk | 1 - include/openflow/automake.mk | 3 --- lib/automake.mk | 4 ---- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/build-aux/automake.mk b/build-aux/automake.mk index b9a77a51c..8d7e8ae19 100644 --- a/build-aux/automake.mk +++ b/build-aux/automake.mk @@ -1,11 +1,19 @@ EXTRA_DIST += \ build-aux/calculate-schema-cksum \ build-aux/cccl \ + build-aux/check-structs \ build-aux/cksum-schema-check \ build-aux/dist-docs \ build-aux/dpdkstrip.py \ - build-aux/generate-dhparams-c \ + build-aux/extract-odp-netlink-h \ + build-aux/extract-odp-netlink-macros-h \ + build-aux/extract-odp-netlink-windows-dp-h \ + build-aux/extract-ofp-actions \ + build-aux/extract-ofp-errors \ + build-aux/extract-ofp-fields \ + build-aux/extract-ofp-msgs \ build-aux/gen_ofp_field_decoders \ + build-aux/generate-dhparams-c \ build-aux/initial-tab-allowed-files \ build-aux/sodepends.py \ build-aux/soexpand.py \ diff --git a/datapath-windows/include/automake.mk b/datapath-windows/include/automake.mk index a354f007f..185a06b03 100644 --- a/datapath-windows/include/automake.mk +++ b/datapath-windows/include/automake.mk @@ -7,6 +7,4 @@ $(srcdir)/datapath-windows/include/OvsDpInterface.h: \ build-aux/extract-odp-netlink-windows-dp-h $(AM_V_GEN)sed -f $(srcdir)/build-aux/extract-odp-netlink-windows-dp-h < $< > $@ -EXTRA_DIST += $(srcdir)/build-aux/extract-odp-netlink-windows-dp-h - CLEANFILES += $(srcdir)/datapath-windows/include/OvsDpInterface.h diff --git a/include/automake.mk b/include/automake.mk index 1e3390ae0..a276c680b 100644 --- a/include/automake.mk +++ b/include/automake.mk @@ -8,7 +8,6 @@ include/odp-netlink-macros.h: include/odp-netlink.h \ build-aux/extract-odp-netlink-macros-h $(AM_V_GEN)sh -f $(srcdir)/build-aux/extract-odp-netlink-macros-h $< > $@ -EXTRA_DIST += build-aux/extract-odp-netlink-h build-aux/extract-odp-netlink-macros-h CLEANFILES += include/odp-netlink.h include/odp-netlink-macros.h include include/openflow/automake.mk diff --git a/include/openflow/automake.mk b/include/openflow/automake.mk index a1d75756c..820c09f84 100644 --- a/include/openflow/automake.mk +++ b/include/openflow/automake.mk @@ -22,6 +22,3 @@ HSTAMP_FILES = $(openflowinclude_HEADERS:.h=.hstamp) CLEANFILES += $(HSTAMP_FILES) ALL_LOCAL += $(HSTAMP_FILES) $(HSTAMP_FILES): build-aux/check-structs $(openflowinclude_HEADERS) - -EXTRA_DIST += build-aux/check-structs - diff --git a/lib/automake.mk b/lib/automake.mk index 24b0ffefe..1be13a420 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -642,7 +642,6 @@ lib/nx-match.inc: $(srcdir)/build-aux/extract-ofp-fields include/openvswitch/met $(AM_V_at)mv $@.tmp $@ lib/nx-match.lo: lib/nx-match.inc CLEANFILES += lib/meta-flow.inc lib/nx-match.inc -EXTRA_DIST += build-aux/extract-ofp-fields lib/ofp-actions.inc1: $(srcdir)/build-aux/extract-ofp-actions lib/ofp-actions.c $(AM_V_GEN)$(run_python) $< prototypes $(srcdir)/lib/ofp-actions.c > $@.tmp && mv $@.tmp $@ @@ -650,7 +649,6 @@ lib/ofp-actions.inc2: $(srcdir)/build-aux/extract-ofp-actions lib/ofp-actions.c $(AM_V_GEN)$(run_python) $< definitions $(srcdir)/lib/ofp-actions.c > $@.tmp && mv $@.tmp $@ lib/ofp-actions.lo: lib/ofp-actions.inc1 lib/ofp-actions.inc2 CLEANFILES += lib/ofp-actions.inc1 lib/ofp-actions.inc2 -EXTRA_DIST += build-aux/extract-ofp-actions lib/ofp-errors.inc: include/openvswitch/ofp-errors.h include/openflow/openflow-common.h \ $(srcdir)/build-aux/extract-ofp-errors @@ -660,14 +658,12 @@ lib/ofp-errors.inc: include/openvswitch/ofp-errors.h include/openflow/openflow-c mv $@.tmp $@ lib/ofp-errors.lo: lib/ofp-errors.inc CLEANFILES += lib/ofp-errors.inc -EXTRA_DIST += build-aux/extract-ofp-errors lib/ofp-msgs.inc: include/openvswitch/ofp-msgs.h $(srcdir)/build-aux/extract-ofp-msgs $(AM_V_GEN)$(run_python) $(srcdir)/build-aux/extract-ofp-msgs \ $(srcdir)/include/openvswitch/ofp-msgs.h $@ > $@.tmp && mv $@.tmp $@ lib/ofp-msgs.lo: lib/ofp-msgs.inc CLEANFILES += lib/ofp-msgs.inc -EXTRA_DIST += build-aux/extract-ofp-msgs # _server IDL OVSIDL_BUILT += lib/ovsdb-server-idl.c lib/ovsdb-server-idl.h lib/ovsdb-server-idl.ovsidl From patchwork Mon Oct 30 20:10:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1857227 X-Patchwork-Delegate: i.maximets@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SK4BJ3mBJz1yQh for ; Tue, 31 Oct 2023 07:10:00 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 48274404F1; Mon, 30 Oct 2023 20:09:58 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 48274404F1 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pFIIWsGsZTmj; Mon, 30 Oct 2023 20:09:57 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id E38FC404C2; Mon, 30 Oct 2023 20:09:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org E38FC404C2 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A7A8DC0071; Mon, 30 Oct 2023 20:09:55 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id C541FC0032 for ; Mon, 30 Oct 2023 20:09:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 823C4404AE for ; Mon, 30 Oct 2023 20:09:53 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 823C4404AE X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kpnzMuDNnDt0 for ; Mon, 30 Oct 2023 20:09:51 +0000 (UTC) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by smtp2.osuosl.org (Postfix) with ESMTPS id 5646B402A8 for ; Mon, 30 Oct 2023 20:09:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 5646B402A8 Received: by mail.gandi.net (Postfix) with ESMTPSA id 4BE711C0004; Mon, 30 Oct 2023 20:09:49 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Mon, 30 Oct 2023 21:10:45 +0100 Message-ID: <20231030201054.136934-3-i.maximets@ovn.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231030201054.136934-1-i.maximets@ovn.org> References: <20231030201054.136934-1-i.maximets@ovn.org> MIME-Version: 1.0 X-GND-Sasl: i.maximets@ovn.org Cc: Ilya Maximets Subject: [ovs-dev] [PATCH 2/6] build-aux/extract-ofp-actions: Fix flake8 and syntax errors. 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" A few general style issues like extra spacing and lines being too long. Also, unused variables 'error_types' and 'comments'. And a few invalid escape sequences, which are not actual escape sequences, but cause actual syntax warnings starting python 3.12 and will eventually become syntax errors [1]: extract-ofp-actions:122: SyntaxWarning: invalid escape sequence '\[' comment = re.sub('\[[^]]*\]', '', comment) extract-ofp-actions:125: SyntaxWarning: invalid escape sequence '\s' m = re.match('([^:]+):\s+(.*)$', comment) These are fixed by converting to raw strings. [1] https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences Signed-off-by: Ilya Maximets Acked-by: Eelco Chaudron --- build-aux/extract-ofp-actions | 108 ++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 44 deletions(-) diff --git a/build-aux/extract-ofp-actions b/build-aux/extract-ofp-actions index 0aa6c65f3..cc5c1dbb0 100755 --- a/build-aux/extract-ofp-actions +++ b/build-aux/extract-ofp-actions @@ -17,27 +17,30 @@ version_map = {"1.0": 0x01, version_reverse_map = dict((v, k) for (k, v) in version_map.items()) # Map from vendor name to the length of the action header. -vendor_map = {"OF": (0x00000000, 4), +vendor_map = {"OF": (0x00000000, 4), "ONF": (0x4f4e4600, 10), "NX": (0x00002320, 10)} # Basic types used in action arguments. -types = {} -types['uint8_t'] = {"size": 1, "align": 1, "ntoh": None, "hton": None} -types['ovs_be16'] = {"size": 2, "align": 2, "ntoh": "ntohs", "hton": "htons"} -types['ovs_be32'] = {"size": 4, "align": 4, "ntoh": "ntohl", "hton": "htonl"} -types['ovs_be64'] = {"size": 8, "align": 8, "ntoh": "ntohll", "hton": "htonll"} -types['uint16_t'] = {"size": 2, "align": 2, "ntoh": None, "hton": None} -types['uint32_t'] = {"size": 4, "align": 4, "ntoh": None, "hton": None} -types['uint64_t'] = {"size": 8, "align": 8, "ntoh": None, "hton": None} +types = { + "uint8_t" : {"size": 1, "align": 1, "ntoh": None, "hton": None}, + "ovs_be16": {"size": 2, "align": 2, "ntoh": "ntohs", "hton": "htons"}, + "ovs_be32": {"size": 4, "align": 4, "ntoh": "ntohl", "hton": "htonl"}, + "ovs_be64": {"size": 8, "align": 8, "ntoh": "ntohll", "hton": "htonll"}, + "uint16_t": {"size": 2, "align": 2, "ntoh": None, "hton": None}, + "uint32_t": {"size": 4, "align": 4, "ntoh": None, "hton": None}, + "uint64_t": {"size": 8, "align": 8, "ntoh": None, "hton": None}, +} line = "" - +n_errors = 0 arg_structs = set() + def round_up(x, y): return int((x + (y - 1)) / y) * y + def open_file(fn): global file_name global input_file @@ -46,6 +49,7 @@ def open_file(fn): input_file = open(file_name) line_number = 0 + def get_line(): global input_file global line @@ -56,16 +60,18 @@ def get_line(): fatal("unexpected end of input") return line -n_errors = 0 + def error(msg): global n_errors sys.stderr.write("%s:%d: %s\n" % (file_name, line_number, msg)) n_errors += 1 + def fatal(msg): error(msg) sys.exit(1) + def usage(): argv0 = os.path.basename(sys.argv[0]) print('''\ @@ -84,10 +90,8 @@ Commands: ''' % {"argv0": argv0}) sys.exit(0) -def extract_ofp_actions(fn, definitions): - error_types = {} - comments = [] +def extract_ofp_actions(fn, definitions): names = [] domain = {} for code, size in vendor_map.values(): @@ -100,14 +104,14 @@ def extract_ofp_actions(fn, definitions): while True: get_line() - if re.match('enum ofp_raw_action_type {', line): + if re.match(r'enum ofp_raw_action_type {', line): break while True: get_line() if line.startswith('/*') or not line or line.isspace(): continue - elif re.match('}', line): + elif re.match(r'}', line): break if not line.lstrip().startswith('/*'): @@ -119,10 +123,10 @@ def extract_ofp_actions(fn, definitions): if line.startswith('/*') or not line or line.isspace(): fatal("unexpected syntax within action") comment += ' %s' % line.lstrip('* \t').rstrip(' \t\r\n') - comment = re.sub('\[[^]]*\]', '', comment) + comment = re.sub(r'\[[^]]*\]', '', comment) comment = comment[:-2].rstrip() - m = re.match('([^:]+):\s+(.*)$', comment) + m = re.match(r'([^:]+):\s+(.*)$', comment) if not m: fatal("unexpected syntax between actions") @@ -147,7 +151,9 @@ def extract_ofp_actions(fn, definitions): names.append(enum) for dst in dsts.split(', '): - m = re.match(r'([A-Z]+)([0-9.]+)(\+|-[0-9.]+)?(?:\((\d+)\))(?: is deprecated \(([^)]+)\))?$', dst) + m = re.match( + r'([A-Z]+)([0-9.]+)(\+|-[0-9.]+)?(?:\((\d+)\))(?:' + r' is deprecated \(([^)]+)\))?$', dst) if not m: fatal("%r: syntax error in destination" % dst) vendor_name = m.group(1) @@ -220,18 +226,18 @@ def extract_ofp_actions(fn, definitions): else: max_length = min_length - info = {"enum": enum, # 0 - "deprecation": deprecation, # 1 - "file_name": file_name, # 2 - "line_number": line_number, # 3 - "min_length": min_length, # 4 - "max_length": max_length, # 5 - "arg_ofs": arg_ofs, # 6 - "arg_len": arg_len, # 7 - "base_argtype": base_argtype, # 8 - "arg_vl_mff_map": arg_vl_mff_map, # 9 - "version": version, # 10 - "type": type_} # 11 + info = {"enum": enum, # 0 + "deprecation": deprecation, # 1 + "file_name": file_name, # 2 + "line_number": line_number, # 3 + "min_length": min_length, # 4 + "max_length": max_length, # 5 + "arg_ofs": arg_ofs, # 6 + "arg_len": arg_len, # 7 + "base_argtype": base_argtype, # 8 + "arg_vl_mff_map": arg_vl_mff_map, # 9 + "version": version, # 10 + "type": type_} # 11 domain[vendor][type_][version] = info enums.setdefault(enum, []) @@ -247,9 +253,13 @@ def extract_ofp_actions(fn, definitions): """) if definitions: - print("/* Verify that structs used as actions are reasonable sizes. */") + print( + "/* Verify that structs used as actions are reasonable sizes. */" + ) for s in sorted(arg_structs): - print("BUILD_ASSERT_DECL(sizeof(%s) %% OFP_ACTION_ALIGN == 0);" % s) + print( + "BUILD_ASSERT_DECL(sizeof(%s) %% OFP_ACTION_ALIGN == 0);" % s + ) print("\nstatic struct ofpact_raw_instance all_raw_instances[] = {") for vendor in domain: @@ -265,9 +275,11 @@ def extract_ofp_actions(fn, definitions): print(" %s," % d["max_length"]) print(" %s," % d["arg_ofs"]) print(" %s," % d["arg_len"]) - print(" \"%s\"," % re.sub('_RAW[0-9]*', '', d["enum"], 1)) + print(" \"%s\"," + % re.sub(r'_RAW[0-9]*', '', d["enum"], 1)) if d["deprecation"]: - print(" \"%s\"," % re.sub(r'(["\\])', r'\\\1', d["deprecation"])) + print(" \"%s\"," + % re.sub(r'(["\\])', r'\\\1', d["deprecation"])) else: print(" NULL,") print(" },") @@ -286,10 +298,11 @@ def extract_ofp_actions(fn, definitions): decl = "static inline " if base_argtype.startswith('struct'): - decl += "%s *" %base_argtype + decl += "%s *" % base_argtype else: decl += "void" - decl += "\nput_%s(struct ofpbuf *openflow" % versions[0]["enum"].replace('_RAW', '', 1) + decl += "\nput_%s(struct ofpbuf *openflow" \ + % versions[0]["enum"].replace('_RAW', '', 1) if need_ofp_version: decl += ", enum ofp_version version" if base_argtype != 'void' and not base_argtype.startswith('struct'): @@ -348,9 +361,13 @@ ofpact_decode(const struct ofp_action_header *a, enum ofp_raw_action_type raw, else: arg = "arg" if arg_vl_mff_map: - print(" return decode_%s(%s, version, vl_mff_map, tlv_bitmap, out);" % (enum, arg)) + print( + " return decode_%s(%s," % (enum, arg), + "version, vl_mff_map, tlv_bitmap, out);" + ) else: - print(" return decode_%s(%s, version, out);" % (enum, arg)) + print(" return decode_%s(%s, version, out);" + % (enum, arg)) print("") print("""\ default: @@ -366,7 +383,8 @@ ofpact_decode(const struct ofp_action_header *a, enum ofp_raw_action_type raw, arg_vl_mff_map = versions[0]["arg_vl_mff_map"] if base_argtype != 'void': if base_argtype.startswith('struct'): - prototype += "const %s *, enum ofp_version, " % base_argtype + prototype += "const %s *, " % base_argtype + prototype += "enum ofp_version, " else: prototype += "%s, enum ofp_version, " % base_argtype if arg_vl_mff_map: @@ -378,13 +396,15 @@ ofpact_decode(const struct ofp_action_header *a, enum ofp_raw_action_type raw, static enum ofperr ofpact_decode(const struct ofp_action_header *, enum ofp_raw_action_type raw, enum ofp_version version, - uint64_t arg, const struct vl_mff_map *vl_mff_map, + uint64_t arg, + const struct vl_mff_map *vl_mff_map, uint64_t *tlv_bitmap, struct ofpbuf *out); """) + -## ------------ ## -## Main Program ## -## ------------ ## +# ------------ # +# Main Program # +# ------------ # if __name__ == '__main__': argv0 = sys.argv[0] From patchwork Mon Oct 30 20:10:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1857228 X-Patchwork-Delegate: i.maximets@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SK4BM5YcMz1yQ4 for ; Tue, 31 Oct 2023 07:10:03 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id CC36381E86; Mon, 30 Oct 2023 20:10:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org CC36381E86 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NGKVN00zp4px; Mon, 30 Oct 2023 20:10:00 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id CDD8F80EFA; Mon, 30 Oct 2023 20:09:58 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org CDD8F80EFA Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B6C78C0DDA; Mon, 30 Oct 2023 20:09:57 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 248B5C0DD2 for ; Mon, 30 Oct 2023 20:09:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 54AC94018A for ; Mon, 30 Oct 2023 20:09:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 54AC94018A X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dG8aau6GQ6QK for ; Mon, 30 Oct 2023 20:09:54 +0000 (UTC) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp4.osuosl.org (Postfix) with ESMTPS id A45E8401D4 for ; Mon, 30 Oct 2023 20:09:53 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org A45E8401D4 Received: by mail.gandi.net (Postfix) with ESMTPSA id 0353D1C0002; Mon, 30 Oct 2023 20:09:51 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Mon, 30 Oct 2023 21:10:46 +0100 Message-ID: <20231030201054.136934-4-i.maximets@ovn.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231030201054.136934-1-i.maximets@ovn.org> References: <20231030201054.136934-1-i.maximets@ovn.org> MIME-Version: 1.0 X-GND-Sasl: i.maximets@ovn.org Cc: Ilya Maximets Subject: [ovs-dev] [PATCH 3/6] build-aux/extract-ofp-errors: Fix flake8 and syntax errors. 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" A few general style issues like extra spacing and lines being too long, unused variable 'error_types', passing more arguments than a format string has. And a few invalid escape sequences, which are not actual escape sequences, but cause actual syntax warnings starting python 3.12 and will eventually become syntax errors [1]: extract-ofp-errors:244: SyntaxWarning: invalid escape sequence '\.' m = re.match('Expected: (.*)\.$', comment) extract-ofp-errors:249: SyntaxWarning: invalid escape sequence '\.' m = re.match('((?:.(?!\. ))+.)\.\s+(.*)$', comment) extract-ofp-errors:256: SyntaxWarning: invalid escape sequence '\s' m = re.match('\s+(?:OFPERR_([A-Z0-9_]+))(\s*=\s*OFPERR_OFS)?,', extract-ofp-errors:265: SyntaxWarning: invalid escape sequence '\[' comments.append(re.sub('\[[^]]*\]', '', comment)) These are fixed by converting to raw strings. [1] https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences Signed-off-by: Ilya Maximets Acked-by: Eelco Chaudron --- build-aux/extract-ofp-errors | 101 +++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 39 deletions(-) diff --git a/build-aux/extract-ofp-errors b/build-aux/extract-ofp-errors index 2c3fbfc88..eeefccbee 100755 --- a/build-aux/extract-ofp-errors +++ b/build-aux/extract-ofp-errors @@ -22,6 +22,9 @@ tokenRe = "#?" + idRe + "|[0-9]+|." inComment = False inDirective = False +n_errors = 0 + + def open_file(fn): global fileName global inputFile @@ -30,6 +33,7 @@ def open_file(fn): inputFile = open(fileName) lineNumber = 0 + def tryGetLine(): global inputFile global line @@ -38,10 +42,12 @@ def tryGetLine(): lineNumber += 1 return line != "" + def getLine(): if not tryGetLine(): fatal("unexpected end of input") + def getToken(): global token global line @@ -82,37 +88,43 @@ def getToken(): line = line[:-2] + inputFile.readline() lineNumber += 1 if line == "": - if token == None: + if token is None: fatal("unexpected end of input") token = None return False -n_errors = 0 + def error(msg): global n_errors sys.stderr.write("%s:%d: %s\n" % (fileName, lineNumber, msg)) n_errors += 1 + def fatal(msg): error(msg) sys.exit(1) + def skipDirective(): getToken() while token != '$': getToken() + def isId(s): - return re.match(idRe + "$", s) != None + return re.match(idRe + "$", s) is not None + def forceId(): if not isId(token): fatal("identifier expected") + def forceInteger(): - if not re.match('[0-9]+$', token): + if not re.match(r'[0-9]+$', token): fatal("integer expected") + def match(t): if token == t: getToken() @@ -120,10 +132,12 @@ def match(t): else: return False + def forceMatch(t): if not match(t): fatal("%s expected" % t) + def parseTaggedName(): assert token in ('struct', 'union') name = token @@ -133,26 +147,26 @@ def parseTaggedName(): getToken() return name + def print_enum(tag, constants, storage_class): - print (""" + print(""" %(storage_class)sconst char * %(tag)s_to_string(uint16_t value) { switch (value) {\ """ % {"tag": tag, - "bufferlen": len(tag) + 32, "storage_class": storage_class}) for constant in constants: - print (" case %s: return \"%s\";" % (constant, constant)) - print ("""\ + print(" case %s: return \"%s\";" % (constant, constant)) + print("""\ } return NULL; -}\ -""" % {"tag": tag}) +}""") + def usage(): argv0 = os.path.basename(sys.argv[0]) - print ('''\ + print('''\ %(argv0)s, for extracting OpenFlow error codes from header files usage: %(argv0)s ERROR_HEADER VENDOR_HEADER @@ -167,6 +181,7 @@ The output is suitable for use as lib/ofp-errors.inc.\ ''' % {"argv0": argv0}) sys.exit(0) + def extract_vendor_ids(fn): global vendor_map vendor_map = {} @@ -174,7 +189,10 @@ def extract_vendor_ids(fn): open_file(fn) while tryGetLine(): - m = re.match(r'#define\s+([A-Z0-9_]+)_VENDOR_ID\s+(0x[0-9a-fA-F]+|[0-9]+)', line) + m = re.match( + r'#define\s+([A-Z0-9_]+)_VENDOR_ID\s+(0x[0-9a-fA-F]+|[0-9]+)', + line + ) if not m: continue @@ -202,9 +220,8 @@ def extract_vendor_ids(fn): % (id_, vendor_reverse_map[id_], name)) vendor_reverse_map[id_] = name -def extract_ofp_errors(fn): - error_types = {} +def extract_ofp_errors(fn): comments = [] names = [] domain = {} @@ -220,14 +237,14 @@ def extract_ofp_errors(fn): while True: getLine() - if re.match('enum ofperr', line): + if re.match(r'enum ofperr', line): break while True: getLine() if line.startswith('/*') or not line or line.isspace(): continue - elif re.match('}', line): + elif re.match(r'}', line): break if not line.lstrip().startswith('/*'): @@ -241,19 +258,19 @@ def extract_ofp_errors(fn): comment += ' %s' % line.lstrip('* \t').rstrip(' \t\r\n') comment = comment[:-2].rstrip() - m = re.match('Expected: (.*)\.$', comment) + m = re.match(r'Expected: (.*)\.$', comment) if m: expected_errors[m.group(1)] = (fileName, lineNumber) continue - m = re.match('((?:.(?!\. ))+.)\.\s+(.*)$', comment) + m = re.match(r'((?:.(?!\. ))+.)\.\s+(.*)$', comment) if not m: fatal("unexpected syntax between errors") dsts, comment = m.groups() getLine() - m = re.match('\s+(?:OFPERR_([A-Z0-9_]+))(\s*=\s*OFPERR_OFS)?,', + m = re.match(r'\s+(?:OFPERR_([A-Z0-9_]+))(\s*=\s*OFPERR_OFS)?,', line) if not m: fatal("syntax error expecting OFPERR_ enum value") @@ -262,11 +279,14 @@ def extract_ofp_errors(fn): if enum in names: fatal("%s specified twice" % enum) - comments.append(re.sub('\[[^]]*\]', '', comment)) + comments.append(re.sub(r'\[[^]]*\]', '', comment)) names.append(enum) for dst in dsts.split(', '): - m = re.match(r'([A-Z]+)([0-9.]+)(\+|-[0-9.]+)?\((\d+)(?:,(\d+))?\)$', dst) + m = re.match( + r'([A-Z]+)([0-9.]+)(\+|-[0-9.]+)?\((\d+)(?:,(\d+))?\)$', + dst + ) if not m: fatal("%r: syntax error in destination" % dst) vendor_name = m.group(1) @@ -313,8 +333,7 @@ def extract_ofp_errors(fn): # mechanism that includes a type but not a code. if v1 < version_map['1.2'] or v2 < version_map['1.2']: if code is None: - fatal("%s: NX1.0 and NX1.1 domains require code" - % (dst, vendor_name)) + fatal("%s: NX1.0 and NX1.1 domains require code" % dst) if v1 >= version_map['1.2'] or v2 >= version_map['1.2']: if code is not None: fatal("%s: NX1.2+ domains do not have codes" % dst) @@ -340,11 +359,13 @@ def extract_ofp_errors(fn): del expected_errors[msg] else: error("%s: %s." % (dst, msg)) - sys.stderr.write("%s:%d: %s: Here is the location " - "of the previous definition.\n" - % (domain[version][vendor][type_][code][1], - domain[version][vendor][type_][code][2], - dst)) + sys.stderr.write( + "%s:%d: %s: Here is the location " + "of the previous definition.\n" + % (domain[version][vendor][type_][code][1], + domain[version][vendor][type_][code][2], + dst) + ) else: domain[version][vendor][type_][code] = (enum, fileName, lineNumber) @@ -361,7 +382,7 @@ def extract_ofp_errors(fn): if n_errors: sys.exit(1) - print ("""\ + print("""\ /* Generated automatically; do not modify! -*- buffer-read-only: t -*- */ #define OFPERR_N_ERRORS %d @@ -386,7 +407,7 @@ static const char *error_comments[OFPERR_N_ERRORS] = { for comment in comments))) def output_domain(map, name, description, version): - print (""" + print(""" static enum ofperr %s_decode(uint32_t vendor, uint16_t type, uint16_t code) { @@ -405,16 +426,16 @@ static enum ofperr vendor_s = "(%#xULL << 32) | " % vendor else: vendor_s = "" - print (" case %s ((uint32_t) %d << 16) | %d:" % (vendor_s, + print(" case %s ((uint32_t) %d << 16) | %d:" % (vendor_s, type_, code)) - print (" return OFPERR_%s;" % enum) - print ("""\ + print(" return OFPERR_%s;" % enum) + print("""\ } return 0; }""") - print (""" + print(""" static const struct ofperr_domain %s = { "%s", %d, @@ -423,20 +444,22 @@ static const struct ofperr_domain %s = { for enum in names: if enum in map: vendor, type_, code = map[enum] - if code == None: + if code is None: code = -1 - print (" { %#8x, %2d, %3d }, /* %s */" % (vendor, type_, code, enum)) + print(" { %#8x, %2d, %3d }, /* %s */" % (vendor, type_, + code, enum)) else: - print (" { -1, -1, -1 }, /* %s */" % enum) - print ("""\ + print(" { -1, -1, -1 }, /* %s */" % enum) + print("""\ }, };""") for version_name, id_ in version_map.items(): - var = 'ofperr_of' + re.sub('[^A-Za-z0-9_]', '', version_name) + var = 'ofperr_of' + re.sub(r'[^A-Za-z0-9_]', '', version_name) description = "OpenFlow %s" % version_name output_domain(reverse[id_], var, description, id_) + if __name__ == '__main__': if '--help' in sys.argv: usage() From patchwork Mon Oct 30 20:10:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1857229 X-Patchwork-Delegate: i.maximets@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SK4BR0xwjz1yQ4 for ; Tue, 31 Oct 2023 07:10:07 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id E8DF6404C8; Mon, 30 Oct 2023 20:10:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org E8DF6404C8 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zKVitQAywqAS; Mon, 30 Oct 2023 20:10:04 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id F3DE94052F; Mon, 30 Oct 2023 20:10:02 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org F3DE94052F Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D2DCDC0071; Mon, 30 Oct 2023 20:10:02 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2753AC008D for ; Mon, 30 Oct 2023 20:10:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 5E7A540519 for ; Mon, 30 Oct 2023 20:09:58 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 5E7A540519 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id deWY2DFt-NWV for ; Mon, 30 Oct 2023 20:09:57 +0000 (UTC) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp2.osuosl.org (Postfix) with ESMTPS id A5EDB404F9 for ; Mon, 30 Oct 2023 20:09:56 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org A5EDB404F9 Received: by mail.gandi.net (Postfix) with ESMTPSA id A02241C0002; Mon, 30 Oct 2023 20:09:54 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Mon, 30 Oct 2023 21:10:47 +0100 Message-ID: <20231030201054.136934-5-i.maximets@ovn.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231030201054.136934-1-i.maximets@ovn.org> References: <20231030201054.136934-1-i.maximets@ovn.org> MIME-Version: 1.0 X-GND-Sasl: i.maximets@ovn.org Cc: Ilya Maximets Subject: [ovs-dev] [PATCH 4/6] build-aux/extract-ofp-fields: Fix flake8 and syntax errors. 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" A few general style issues like extra spacing and block comment format. And a few invalid escape sequences, which are not actual escape sequences, but cause actual syntax warnings starting python 3.12 and will eventually become syntax errors [1]: extract-ofp-fields:323: SyntaxWarning: invalid escape sequence '\_' "\_;\_;\_;\_;\_;\_\n", extract-ofp-fields:332: SyntaxWarning: invalid escape sequence '\_' s = """tab(;); extract-ofp-fields:374: SyntaxWarning: invalid escape sequence '\-' """\ These are fixed by converting to raw strings. While doing that we also have to remove all the now unnecessary escaping from actual escape sequences like '\\'. [1] https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences Signed-off-by: Ilya Maximets Acked-by: Eelco Chaudron --- build-aux/extract-ofp-fields | 50 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/build-aux/extract-ofp-fields b/build-aux/extract-ofp-fields index 05d3e1df3..89d80c208 100755 --- a/build-aux/extract-ofp-fields +++ b/build-aux/extract-ofp-fields @@ -167,9 +167,9 @@ def make_nx_match(meta_flow_h): print(oline) -## ------------------------ ## -## Documentation Generation ## -## ------------------------ ## +# ------------------------ # +# Documentation Generation # +# ------------------------ # def field_to_xml(field_node, f, body, summary): @@ -189,9 +189,9 @@ def field_to_xml(field_node, f, body, summary): ovs_version = [int(x) for x in ovs_version_s.split(".")] if min_ovs_version is None or ovs_version < min_ovs_version: min_ovs_version = ovs_version - summary += ["\\fB%s\\fR" % f["name"]] + summary += [r"\fB%s\fR" % f["name"]] if f["extra_name"]: - summary += [" aka \\fB%s\\fR" % f["extra_name"]] + summary += [r" aka \fB%s\fR" % f["extra_name"]] summary += [";%d" % f["n_bytes"]] if f["n_bits"] != 8 * f["n_bytes"]: summary += [" (low %d bits)" % f["n_bits"]] @@ -213,8 +213,8 @@ def field_to_xml(field_node, f, body, summary): title = field_node.attributes["title"].nodeValue body += [ - """.PP -\\fB%s Field\\fR + r""".PP +\fB%s Field\fR .TS tab(;),nowarn; l lx. @@ -222,9 +222,9 @@ l lx. % title ] - body += ["Name:;\\fB%s\\fR" % f["name"]] + body += [r"Name:;\fB%s\fR" % f["name"]] if f["extra_name"]: - body += [" (aka \\fB%s\\fR)" % f["extra_name"]] + body += [r" (aka \fB%s\fR)" % f["extra_name"]] body += ["\n"] body += ["Width:;"] @@ -320,7 +320,8 @@ def group_xml_to_nroff(group_node, fields): "tab(;),nowarn;\n", "l l l l l l l.\n", "Name;Bytes;Mask;RW?;Prereqs;NXM/OXM Support\n", - "\_;\_;\_;\_;\_;\_\n", + r"\_;\_;\_;\_;\_;\_", + "\n", ] content += summary content += [".TE\n"] @@ -329,7 +330,7 @@ def group_xml_to_nroff(group_node, fields): def make_oxm_classes_xml(document): - s = """tab(;),nowarn; + s = r"""tab(;),nowarn; l l l. Prefix;Vendor;Class \_;\_;\_ @@ -367,42 +368,41 @@ def make_ovs_fields(meta_flow_h, meta_flow_xml): doc = document.documentElement global version - if version == None: + if version is None: version = "UNKNOWN" print( - """\ -'\\" tp -.\\" -*- mode: troff; coding: utf-8 -*- + r"""'\" tp +.\" -*- mode: troff; coding: utf-8 -*- .TH "ovs\-fields" 7 "%s" "Open vSwitch" "Open vSwitch Manual" -.fp 5 L CR \\" Make fixed-width font available as \\fL. +.fp 5 L CR \" Make fixed-width font available as \fL. .de ST . PP . RS -0.15in -. I "\\\\$1" +. I "\\$1" . RE .. .de SU . PP -. I "\\\\$1" +. I "\\$1" .. .de IQ . br . ns -. IP "\\\\$1" +. IP "\\$1" .. .de TQ . br . ns -. TP "\\\\$1" +. TP "\\$1" .. .de URL -\\\\$2 \\(laURL: \\\\$1 \\(ra\\\\$3 +\\$2 \(laURL: \\$1 \(ra\\$3 .. -.if \\n[.g] .mso www.tmac +.if \n[.g] .mso www.tmac .SH NAME ovs\-fields \- protocol header fields in OpenFlow and Open vSwitch . @@ -460,9 +460,9 @@ ovs\-fields \- protocol header fields in OpenFlow and Open vSwitch print(output[i]) -## ------------ ## -## Main Program ## -## ------------ ## +# ------------ # +# Main Program # +# ------------ # if __name__ == "__main__": argv0 = sys.argv[0] From patchwork Mon Oct 30 20:10:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1857230 X-Patchwork-Delegate: i.maximets@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SK4BV5jQDz1yQ4 for ; Tue, 31 Oct 2023 07:10:10 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id CF3944053F; Mon, 30 Oct 2023 20:10:08 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org CF3944053F X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I0Z6ARoO-4Tv; Mon, 30 Oct 2023 20:10:07 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id D35EF40517; Mon, 30 Oct 2023 20:10:05 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org D35EF40517 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id CA42CC008C; Mon, 30 Oct 2023 20:10:04 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1F545C0DD2 for ; Mon, 30 Oct 2023 20:10:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id C04FC41AEB for ; Mon, 30 Oct 2023 20:10:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C04FC41AEB X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nOGlHhQ72u4p for ; Mon, 30 Oct 2023 20:09:59 +0000 (UTC) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp4.osuosl.org (Postfix) with ESMTPS id E0D5A410BC for ; Mon, 30 Oct 2023 20:09:58 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org E0D5A410BC Received: by mail.gandi.net (Postfix) with ESMTPSA id 2DCE91C0003; Mon, 30 Oct 2023 20:09:57 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Mon, 30 Oct 2023 21:10:48 +0100 Message-ID: <20231030201054.136934-6-i.maximets@ovn.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231030201054.136934-1-i.maximets@ovn.org> References: <20231030201054.136934-1-i.maximets@ovn.org> MIME-Version: 1.0 X-GND-Sasl: i.maximets@ovn.org Cc: Ilya Maximets Subject: [ovs-dev] [PATCH 5/6] build-aux/extract-ofp-msgs: Fix flake8 and syntax errors. 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" A few general style issues like extra spacing and line length, semicolons at the end of the line and unused variable 'raw_types'. And a few invalid escape sequences, which are not actual escape sequences, but cause actual syntax warnings starting python 3.12 and will eventually become syntax errors [1]: extract-ofp-msgs:118: SyntaxWarning: invalid escape sequence '\s' m = re.match('\s+(?:OFPRAW_%s)(\d*)_([A-Z0-9_]+),?$' % type_, These are fixed by converting to raw strings. [1] https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences Signed-off-by: Ilya Maximets Acked-by: Eelco Chaudron --- build-aux/extract-ofp-msgs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/build-aux/extract-ofp-msgs b/build-aux/extract-ofp-msgs index 6b3295cf6..c26ea1d35 100755 --- a/build-aux/extract-ofp-msgs +++ b/build-aux/extract-ofp-msgs @@ -24,6 +24,9 @@ OFPT11_STATS_REQUEST = 18 OFPT11_STATS_REPLY = 19 OFPST_VENDOR = 0xffff +n_errors = 0 + + def decode_version_range(range): if range in VERSION: return (VERSION[range], VERSION[range]) @@ -35,6 +38,7 @@ def decode_version_range(range): a, b = re.match(r'^([^-]+)-([^-]+)$', range).groups() return (VERSION[a], VERSION[b]) + def get_line(): global line global line_number @@ -43,16 +47,18 @@ def get_line(): if line == "": fatal("unexpected end of input") -n_errors = 0 + def error(msg): global n_errors sys.stderr.write("%s:%d: %s\n" % (file_name, line_number, msg)) n_errors += 1 + def fatal(msg): error(msg) sys.exit(1) + def usage(): argv0 = os.path.basename(sys.argv[0]) print('''\ @@ -65,6 +71,7 @@ only controls #line directives in the output.\ ''' % {"argv0": argv0}) sys.exit(0) + def make_sizeof(s): m = re.match(r'(.*) up to (.*)', s) if m: @@ -73,9 +80,8 @@ def make_sizeof(s): else: return "sizeof(%s)" % s -def extract_ofp_msgs(output_file_name): - raw_types = [] +def extract_ofp_msgs(output_file_name): all_hdrs = {} all_raws = {} all_raws_order = [] @@ -108,15 +114,16 @@ def extract_ofp_msgs(output_file_name): comment += ' %s' % line.lstrip('* \t').rstrip(' \t\r\n') comment = comment[:-2].rstrip() - m = re.match(r'([A-Z]+) ([-.+\d]+|) \((\d+)\): ([^.]+)\.$', comment) + m = re.match( + r'([A-Z]+) ([-.+\d]+|) \((\d+)\): ([^.]+)\.$', comment + ) if not m: fatal("unexpected syntax between messages") type_, versions, number, contents = m.groups() number = int(number) get_line() - m = re.match('\s+(?:OFPRAW_%s)(\d*)_([A-Z0-9_]+),?$' % type_, - line) + m = re.match(r'\s+(?:OFPRAW_%s)(\d*)_([A-Z0-9_]+),?$' % type_, line) if not m: fatal("syntax error expecting OFPRAW_ enum") vinfix, name = m.groups() @@ -300,7 +307,7 @@ def extract_ofp_msgs(output_file_name): for hdrs in r['hdrs']: output.append(" { {0, NULL}, {%d, %d, %d, 0x%x, %d}, %s, 0 }," % (hdrs + (raw,))) - + output.append("};") output.append("") @@ -349,8 +356,8 @@ def extract_ofp_msgs(output_file_name): % r["human_name"]) output.append("};") - output.append(""); - output.append("static const char *type_names[] = {"); + output.append("") + output.append("static const char *type_names[] = {") for t in all_types: output.append(" \"%s\"," % t) output.append("};") @@ -378,4 +385,3 @@ if __name__ == '__main__': for line in extract_ofp_msgs(sys.argv[2]): print(line) - From patchwork Mon Oct 30 20:10:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1857231 X-Patchwork-Delegate: i.maximets@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SK4Bb0TcKz1yQ6 for ; Tue, 31 Oct 2023 07:10:14 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 235028203D; Mon, 30 Oct 2023 20:10:13 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 235028203D X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tnf7JtiVqj33; Mon, 30 Oct 2023 20:10:12 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 0A55F8209B; Mon, 30 Oct 2023 20:10:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 0A55F8209B Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E037DC0071; Mon, 30 Oct 2023 20:10:10 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1B32AC007F for ; Mon, 30 Oct 2023 20:10:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id C55BF401B5 for ; Mon, 30 Oct 2023 20:10:02 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C55BF401B5 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iIFbcHkYnizR for ; Mon, 30 Oct 2023 20:10:02 +0000 (UTC) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp4.osuosl.org (Postfix) with ESMTPS id 9890D4052B for ; Mon, 30 Oct 2023 20:10:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 9890D4052B Received: by mail.gandi.net (Postfix) with ESMTPSA id C96FE1C0003; Mon, 30 Oct 2023 20:09:59 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Mon, 30 Oct 2023 21:10:49 +0100 Message-ID: <20231030201054.136934-7-i.maximets@ovn.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231030201054.136934-1-i.maximets@ovn.org> References: <20231030201054.136934-1-i.maximets@ovn.org> MIME-Version: 1.0 X-GND-Sasl: i.maximets@ovn.org Cc: Ilya Maximets Subject: [ovs-dev] [PATCH 6/6] build-aux: Enable flake8 checks for python extraction scripts. 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" These were recently updated to pass the checks, so should be added to the list in order to avoid regressions in the future. While at it, fixing the indentation. Signed-off-by: Ilya Maximets Acked-by: Eelco Chaudron --- build-aux/automake.mk | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/build-aux/automake.mk b/build-aux/automake.mk index 8d7e8ae19..d65b6da6c 100644 --- a/build-aux/automake.mk +++ b/build-aux/automake.mk @@ -21,8 +21,12 @@ EXTRA_DIST += \ build-aux/xml2nroff FLAKE8_PYFILES += \ - build-aux/dpdkstrip.py \ - build-aux/gen_ofp_field_decoders \ - build-aux/sodepends.py \ - build-aux/soexpand.py \ - build-aux/xml2nroff + build-aux/dpdkstrip.py \ + build-aux/extract-ofp-actions \ + build-aux/extract-ofp-errors \ + build-aux/extract-ofp-fields \ + build-aux/extract-ofp-msgs \ + build-aux/gen_ofp_field_decoders \ + build-aux/sodepends.py \ + build-aux/soexpand.py \ + build-aux/xml2nroff