PeterBee97 commented on code in PR #18745:
URL: https://github.com/apache/nuttx/pull/18745#discussion_r3108021465


##########
arch/sim/src/sim/posix/sim_host_v4l2.c:
##########
@@ -120,37 +120,24 @@ static bool host_video_is_capture_device(const char 
*host_video_dev_path)
   return available;
 }
 
-static int host_video_get_device_path_by_index(const char *dirpath,
-                                               int index,
+static int host_video_get_device_path_by_index(int index,
                                                char *devpath,
                                                size_t devpathlen)
 {
-  DIR *dir;
-  struct dirent *entry;
   int count = 0;
+  int i;
 
-  dir = opendir(dirpath);
-  if (dir == NULL)
-    {
-      return -errno;
-    }
-
-  while ((entry = readdir(dir)) != NULL)
+  for (i = 0; i < HOST_MAX_VIDEO_DEVICES; i++)
     {
-      char path[PATH_MAX];
-
-      if (strncmp(entry->d_name, "video", 5) != 0)
-        {
-          continue;
-        }
+      char path[32];
 
-      if (snprintf(path, sizeof(path), "/dev/%s", entry->d_name) >=
+      if (snprintf(path, sizeof(path), "/dev/video%d", i) >=

Review Comment:
   changed to dynamic discovery of paths



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to