]> mj.ucw.cz Git - pciutils.git/blobdiff - lib/filter.c
MacOS: An attempt to appease compiler picky about attribute placement
[pciutils.git] / lib / filter.c
index d025a96c8809ed4d894fc37b554d9a05ae7af7ac..0301f49f93ff76e6a29f6d781817c2dfd4f83886 100644 (file)
@@ -3,7 +3,9 @@
  *
  *     Copyright (c) 1998--2022 Martin Mares <mj@ucw.cz>
  *
- *     Can be freely distributed and used under the terms of the GNU GPL.
+ *     Can be freely distributed and used under the terms of the GNU GPL v2+.
+ *
+ *     SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 #include <stdlib.h>
@@ -76,6 +78,11 @@ parse_hex_field(char *str, int *outp, unsigned int *maskp, unsigned int max)
   if (!field_defined(str))
     return 1;  // and keep the defaults
 
+  // Historically, filters allowed writing hexadecimal numbers with leading "0x".
+  // This was never intentional nor documented, but some people relied on it.
+  if (!maskp && str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
+    str += 2;
+
   while (*str)
     {
       int c = *str++;
@@ -204,13 +211,13 @@ pci_filter_match_v38(struct pci_filter *f, struct pci_dev *d)
     }
   if (f->device_class >= 0)
     {
-      pci_fill_info(d, PCI_FILL_CLASS);
+      pci_fill_info_v38(d, PCI_FILL_CLASS);
       if ((f->device_class ^ d->device_class) & f->device_class_mask)
        return 0;
     }
   if (f->prog_if >= 0)
     {
-      pci_fill_info(d, PCI_FILL_CLASS_EXT);
+      pci_fill_info_v38(d, PCI_FILL_CLASS_EXT);
       if (f->prog_if != d->prog_if)
        return 0;
     }