linux-v4l2: Fix format-truncation warning

This commit is contained in:
tytan652 2021-12-12 16:45:59 +01:00 committed by Jim
parent 55b23a26d2
commit 096ec55c83

View File

@ -197,9 +197,14 @@ static bool virtualcam_start(void *data)
return false;
for (int i = 0; i < n; i++) {
char device[32];
char device[32] = {0};
snprintf(device, 32, "/dev/%s", list[i]->d_name);
// Use the return value of snprintf to prevent truncation warning.
int written = snprintf(device, 32, "/dev/%s", list[i]->d_name);
if (written >= 32)
blog(LOG_DEBUG,
"v4l2-output: A format truncation may have occurred."
" This can be ignored since it is quite improbable.");
if (try_connect(vcam, device)) {
success = true;