]> mj.ucw.cz Git - pciutils.git/blobdiff - ls-vpd.c
update-pciids: Report itself as an user agent, version included
[pciutils.git] / ls-vpd.c
index 37217f0e06cae49cb957642d1b3ba732b643d259..fcb80ae030eabdc2d61378103349908cc58f4f0e 100644 (file)
--- a/ls-vpd.c
+++ b/ls-vpd.c
@@ -6,10 +6,13 @@
  *     Written by Ben Hutchings <bhutchings@solarflare.com>
  *     Improved by Martin Mares <mj@ucw.cz>
  *
  *     Written by Ben Hutchings <bhutchings@solarflare.com>
  *     Improved by 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 <stdio.h>
  */
 
 #include <stdio.h>
+#include <string.h>
 
 #include "lspci.h"
 
 
 #include "lspci.h"
 
@@ -156,13 +159,14 @@ cap_vpd(struct device *d)
            {
              word read_len;
              const struct vpd_item *item;
            {
              word read_len;
              const struct vpd_item *item;
-             byte id1, id2;
+             byte id[2], id1, id2;
 
              if (!read_vpd(d, res_addr + part_pos, buf, 3, &csum))
                break;
              part_pos += 3;
 
              if (!read_vpd(d, res_addr + part_pos, buf, 3, &csum))
                break;
              part_pos += 3;
-             id1 = buf[0];
-             id2 = buf[1];
+             memcpy(id, buf, 2);
+             id1 = id[0];
+             id2 = id[1];
              part_len = buf[2];
              if (part_len > res_len - part_pos)
                break;
              part_len = buf[2];
              if (part_len > res_len - part_pos)
                break;
@@ -178,7 +182,9 @@ cap_vpd(struct device *d)
              if (!read_vpd(d, res_addr + part_pos, buf, read_len, &csum))
                break;
 
              if (!read_vpd(d, res_addr + part_pos, buf, read_len, &csum))
                break;
 
-             printf("\t\t\t[%c%c] %s: ", id1, id2, item->name);
+             printf("\t\t\t[");
+             print_vpd_string(id, 2);
+             printf("] %s: ", item->name);
 
              switch (item->format)
                {
 
              switch (item->format)
                {