pmdinfogen: fix warning with python 3.14
PATCH 1/1 pmdinfogen: fix warning with python 3.14
Fix the following warning seen on Fedora 43 with Python 3.14:
buildtools/pmdinfogen.py:118: DeprecationWarning: Due to '_pack_', the 'rte_pci_id' Structure will use memory layout compatible with MSVC (Windows). If this is intended, set _layout_ to 'ms'. The implicit default is dep recated and slated to become an error in Python 3.19.
Use the struct module which is simpler and assumes everything is packed by default.
There is no change in the output of dpdk-pmdinfo.py before and after this patch.
--- buildtools/pmdinfogen.py | 42 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 31 deletions(-)
buildtools/pmdinfogen.py +11 -31
@@ -4,9 +4,9 @@ # Copyright (c) 2020 Dmitry Kozlyuk <[email protected]> import argparse -import ctypes import json import re +import struct import sys import tempfile
@@ -110,24 +110,6 @@ def find_by_name(self, name): return None -def define_rte_pci_id(is_big_endian): - base_type = ctypes.LittleEndianStructure - if is_big_endian: - base_type = ctypes.BigEndianStructure - - class rte_pci_id(base_type): - _pack_ = True - _fields_ = [ - ("class_id", ctypes.c_uint32), - ("vendor_id", ctypes.c_uint16), - ("device_id", ctypes.c_uint16), - ("subsystem_vendor_id", ctypes.c_uint16), - ("subsystem_device_id", ctypes.c_uint16), - ] - - return rte_pci_id - - class Driver: OPTIONS = [ ("params", "_param_string_export"),
@@ -166,26 +148,24 @@ def _load_pci_ids(image, table_name_symbol): if not table_symbol: raise Exception("PCI table declared but not defined: %d" % table_name) - rte_pci_id = define_rte_pci_id(image.is_big_endian) + if image.is_big_endian: + fmt = ">" + else: + fmt = "<" + fmt += "LHHHH" result = [] while True: - size = ctypes.sizeof(rte_pci_id) + size = struct.calcsize(fmt) offset = size * len(result) data = table_symbol.get_value(offset, size) if not data: break - pci_id = rte_pci_id.from_buffer_copy(data) - if not pci_id.device_id: + _, vendor, device, ss_vendor, ss_device = struct.unpack_from(fmt, data) + if not device: break - result.append( - [ - pci_id.vendor_id, - pci_id.device_id, - pci_id.subsystem_vendor_id, - pci_id.subsystem_device_id, - ] - ) + result.append((vendor, device, ss_vendor, ss_device)) + return result def dump(self, file):
Signature · 1 line
2.51.1
David Marchand
AppliedQuoted 8 lines · Robin Jarry
Fix the following warning seen on Fedora 43 with Python 3.14:
buildtools/pmdinfogen.py:118: DeprecationWarning: Due to '_pack_', the 'rte_pci_id' Structure will use memory layout compatible with MSVC (Windows). If this is intended, set _layout_ to 'ms'. The implicit default is dep recated and slated to become an error in Python 3.19.
Quoted 5 lines
Use the struct module which is simpler and assumes everything is packed by default.
There is no change in the output of
dpdk-pmdinfo.pybefore and after this patch.
Bugzilla ID: 1818
Cc: [email protected]
Quoted 3 lines
Signed-off-by Robin Jarry <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand