Răsfoiți Sursa

linux-v4l2: Fix format-truncation warning

tytan652 3 ani în urmă
părinte
comite
096ec55c83
1 a modificat fișierele cu 8 adăugiri și 3 ștergeri
  1. 8 3
      plugins/linux-v4l2/v4l2-output.c

+ 8 - 3
plugins/linux-v4l2/v4l2-output.c

@@ -197,9 +197,14 @@ static bool virtualcam_start(void *data)
 		return false;
 		return false;
 
 
 	for (int i = 0; i < n; i++) {
 	for (int i = 0; i < n; i++) {
-		char device[32];
-
-		snprintf(device, 32, "/dev/%s", list[i]->d_name);
+		char device[32] = {0};
+
+		// 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)) {
 		if (try_connect(vcam, device)) {
 			success = true;
 			success = true;