Do we need to call sd_device_unref on ref returned from sd_device_enumerator_get_device_first?
I have noticed memory related issues after calling sd_device_unref(dev) on device refs returned from sd_device_enumerator_get_device_first.
I don't see sd_device_unref called in the Systemd test cases, ex: https://github.com/systemd/systemd/blob/91010bd6ccd363be9e09f22c60d45f5e27c1d2a8/src/libsystemd/sd-device/test-sd-device.c#L362
I don't think so. Because when I do I'll get an assertion error when calling sd_device_enumerator_unref on the enumerator. So I think freeing the enumerator will free the devices it enumerated.
Unfortunately sd-device is not documented well at all.