device: start id space at 1

So a value of 0 means no device.
pull/15398/head
Victor Julien 7 months ago
parent a7ee12c921
commit 4a7ded0eea

@ -138,7 +138,8 @@ int LiveRegisterDevice(const char *dev)
return -1; return -1;
} }
int id = LiveGetDeviceCount(); /* +1 as the id space starts at 1 */
int id = LiveGetDeviceCount() + 1;
if (id > UINT16_MAX) { if (id > UINT16_MAX) {
SCFree(pd); SCFree(pd);
return -1; return -1;
@ -475,8 +476,9 @@ LiveDevice *LiveDeviceForEach(LiveDevice **ldev, LiveDevice **ndev)
static void LiveDeviceFinalizeBuildArray(void) static void LiveDeviceFinalizeBuildArray(void)
{ {
BUG_ON(g_livedev_array); BUG_ON(g_livedev_array);
int max_id = LiveGetDeviceCount(); /* +1 as the id space starts at 1 */
if (max_id <= 0) int max_id = LiveGetDeviceCount() + 1;
if (max_id <= 1)
return; return;
g_livedev_array = SCCalloc(max_id + 1, sizeof(LiveDevice *)); g_livedev_array = SCCalloc(max_id + 1, sizeof(LiveDevice *));

Loading…
Cancel
Save