When source_enum_display_settings() fails to find a display mode because the index is out of range, the index number in the log is always 0 because the same variable is decreased in the for loop to find the display mode, giving the impression that it fails to find the first display mode.