1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-20 18:04:03 +03:00

id128-util: use FOREACH_STRING where appropriate

This commit is contained in:
Mike Yuan 2024-01-24 17:02:28 +08:00
parent ed4498a193
commit f789041c4a
No known key found for this signature in database
GPG Key ID: 417471C0A40F58B3

View File

@ -12,6 +12,7 @@
#include "sha256.h"
#include "stdio-util.h"
#include "string-util.h"
#include "strv.h"
#include "sync-util.h"
#include "virt.h"
@ -231,11 +232,15 @@ int id128_get_product(sd_id128_t *ret) {
* of the host */
return -ENOENT;
r = id128_read("/sys/class/dmi/id/product_uuid", ID128_FORMAT_UUID, &uuid);
if (r == -ENOENT)
r = id128_read("/proc/device-tree/vm,uuid", ID128_FORMAT_UUID, &uuid);
if (r == -ENOENT)
r = id128_read("/sys/hypervisor/uuid", ID128_FORMAT_UUID, &uuid);
FOREACH_STRING(i,
"/sys/class/dmi/id/product_uuid", /* KVM */
"/proc/device-tree/vm,uuid", /* Device tree */
"/sys/hypervisor/uuid") { /* Xen */
r = id128_read(i, ID128_FORMAT_UUID, &uuid);
if (r != -ENOENT)
break;
}
if (r < 0)
return r;