]> mj.ucw.cz Git - pciutils.git/commitdiff
lspci, setpci: Warn when -s or -d is used multiple times
authorMartin Mareš <mj@ucw.cz>
Sun, 5 Apr 2026 17:18:47 +0000 (19:18 +0200)
committerMartin Mareš <mj@ucw.cz>
Sun, 5 Apr 2026 17:18:47 +0000 (19:18 +0200)
lspci.c
setpci.c

diff --git a/lspci.c b/lspci.c
index 2bfc2368b36acd1405a93134eed82b5b3c30ff17..68c9155ce70ea0a752aabb247744cedee0e56994 100644 (file)
--- a/lspci.c
+++ b/lspci.c
@@ -1135,11 +1135,15 @@ main(int argc, char **argv)
        pacc->buscentric = 1;
        break;
       case 's':
+       if (pci_filter_has_slot(&filter))
+         fprintf(stderr, "Multiple -s options are given, only the last one has effect.\n");
        if (msg = pci_filter_parse_slot(&filter, optarg))
          die("-s: %s", msg);
        opt_filter = 1;
        break;
       case 'd':
+       if (pci_filter_has_id(&filter))
+         fprintf(stderr, "Multiple -d options are given, only the last one has effect.\n");
        if (msg = pci_filter_parse_id(&filter, optarg))
          die("-d: %s", msg);
        opt_filter = 1;
index b833250808d3dfb19c258de2964d7acc24e31ab7..e7f18ee755e4aafe9c8665480fddec273a6343dc 100644 (file)
--- a/setpci.c
+++ b/setpci.c
@@ -558,10 +558,14 @@ static int parse_filter(int argc, char **argv, int i, struct group *group)
   switch (c[1])
     {
     case 's':
+      if (pci_filter_has_slot(&group->filter))
+         fprintf(stderr, "Multiple -s options are given, only the last one has effect.\n");
       if (d = pci_filter_parse_slot(&group->filter, d))
        parse_err("Unable to parse filter -s %s", d);
       break;
     case 'd':
+      if (pci_filter_has_id(&group->filter))
+       fprintf(stderr, "Multiple -d options are given, only the last one has effect.\n");
       if (d = pci_filter_parse_id(&group->filter, d))
        parse_err("Unable to parse filter -d %s", d);
       break;