device: start id space at 1

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

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

Loading…
Cancel
Save