1
0
Эх сурвалжийг харах

obs-ffmpeg: Fix compiler warnings

* obs-ffmpeg: Fix format-overflow warning

* obs-ffmpeg: Fix unused-parameter warnings
tytan652 3 жил өмнө
parent
commit
ce62240530

+ 3 - 0
plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c

@@ -202,6 +202,9 @@ static bool nvenc_reconfigure(void *data, obs_data_t *settings)
 		enc->ffve.context->bit_rate = rate;
 		enc->ffve.context->rc_max_rate = rate;
 	}
+#else
+	UNUSED_PARAMETER(data);
+	UNUSED_PARAMETER(settings);
 #endif
 	return true;
 }

+ 10 - 2
plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c

@@ -600,8 +600,16 @@ static obs_properties_t *vaapi_properties(void *unused)
 			    strcmp(file_name, "..") == 0)
 				continue;
 
-			char path[64] = "\0";
-			sprintf(path, "/dev/dri/by-path/%s", file_name);
+			char path[64] = {0};
+
+			// Use the return value of snprintf to prevent truncation warning.
+			int written = snprintf(path, 64, "/dev/dri/by-path/%s",
+					       file_name);
+			if (written >= 64)
+				blog(LOG_DEBUG,
+				     "obs-ffmpeg-vaapi: A format truncation may have occurred."
+				     " This can be ignored since it is quite improbable.");
+
 			type = strrchr(file_name, '-');
 			if (type == NULL)
 				continue;