From 03f918bf15e53c60b2e8a264bb0b0f7865477660 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 11 Jul 2022 11:54:35 +0200 Subject: [PATCH] udev: prefix vendor.id and product.id with 0x They are hex strings so prefix them with 0x to make sure they get handled like that in properties. Fixes #2527 --- spa/plugins/alsa/alsa-udev.c | 10 ++++------ spa/plugins/v4l2/v4l2-udev.c | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/spa/plugins/alsa/alsa-udev.c b/spa/plugins/alsa/alsa-udev.c index 8501ff642..aa7b03994 100644 --- a/spa/plugins/alsa/alsa-udev.c +++ b/spa/plugins/alsa/alsa-udev.c @@ -478,11 +478,10 @@ static int emit_object_info(struct impl *this, struct device *device) items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_SUBSYSTEM, str); } if ((str = udev_device_get_property_value(dev, "ID_VENDOR_ID")) && *str) { - char *dec = alloca(6); /* 65535 is max */ int32_t val; - if (spa_atoi32(str, &val, 16)) { - snprintf(dec, 6, "%d", val); + char *dec = alloca(12); /* 0xffffffff is max */ + snprintf(dec, 12, "0x%04x", val); items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_ID, dec); } } @@ -501,11 +500,10 @@ static int emit_object_info(struct impl *this, struct device *device) items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_NAME, str); } if ((str = udev_device_get_property_value(dev, "ID_MODEL_ID")) && *str) { - char *dec = alloca(6); /* 65535 is max */ int32_t val; - if (spa_atoi32(str, &val, 16)) { - snprintf(dec, 6, "%d", val); + char *dec = alloca(12); /* 0xffffffff is max */ + snprintf(dec, 12, "0x%04x", val); items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PRODUCT_ID, dec); } } diff --git a/spa/plugins/v4l2/v4l2-udev.c b/spa/plugins/v4l2/v4l2-udev.c index ff5433e08..df1b1f890 100644 --- a/spa/plugins/v4l2/v4l2-udev.c +++ b/spa/plugins/v4l2/v4l2-udev.c @@ -279,11 +279,10 @@ static int emit_object_info(struct impl *this, struct device *device) items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_SUBSYSTEM, str); } if ((str = udev_device_get_property_value(dev, "ID_VENDOR_ID")) && *str) { - char *dec = alloca(6); /* 65535 is max */ int32_t val; - if (spa_atoi32(str, &val, 16)) { - snprintf(dec, 6, "%d", val); + char *dec = alloca(12); /* 0xffff is max */ + snprintf(dec, 12, "0x%04x", val); items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_ID, dec); } } @@ -302,11 +301,10 @@ static int emit_object_info(struct impl *this, struct device *device) items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_NAME, str); } if ((str = udev_device_get_property_value(dev, "ID_MODEL_ID")) && *str) { - char *dec = alloca(6); /* 65535 is max */ int32_t val; - if (spa_atoi32(str, &val, 16)) { - snprintf(dec, 6, "%d", val); + char *dec = alloca(12); /* 0xffff is max */ + snprintf(dec, 12, "0x%04x", val); items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PRODUCT_ID, dec); } }