From f10588a2de70ad2c65e416bb6541d8cebd4d2529 Mon Sep 17 00:00:00 2001
From: Tom Sepez <tsepez@chromium.org>
Date: Fri, 28 Mar 2025 18:01:43 -0700
Subject: [PATCH] Suppress gpu/v4l2 files using unsafe C library calls.

Fallout from earlier tree-wide attempt to enable these warnings.

Bug: 390223051
Cq-Include-Trybots: luci.chromium.try:linux-v4l2-codec-rel
Change-Id: I0a3f9d04c39367f03f5fd090e678f71cd12abcc8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6410313
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1439815}
---
 media/gpu/v4l2/mt21/mt21_decompressor.cc          | 5 +++++
 media/gpu/v4l2/mt21/mt21_decompressor_unittest.cc | 5 +++++
 media/gpu/v4l2/mt21/mt21_util.h                   | 5 +++++
 media/gpu/v4l2/mt21/mt21_util_unittest.cc         | 5 +++++
 media/gpu/v4l2/v4l2_framerate_control.cc          | 5 +++++
 media/gpu/v4l2/v4l2_jpeg_encode_accelerator.cc    | 5 +++++
 media/gpu/v4l2/v4l2_unittest.cc                   | 5 +++++
 media/gpu/v4l2/v4l2_video_decoder.cc              | 5 +++++
 media/gpu/v4l2/v4l2_video_encode_accelerator.cc   | 5 +++++
 9 files changed, 45 insertions(+)

diff --git a/media/gpu/v4l2/mt21/mt21_decompressor.cc b/media/gpu/v4l2/mt21/mt21_decompressor.cc
index a7f83857102aa..eb87e26d37c52 100644
--- a/media/gpu/v4l2/mt21/mt21_decompressor.cc
+++ b/media/gpu/v4l2/mt21/mt21_decompressor.cc
@@ -2,6 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#ifdef UNSAFE_BUFFERS_BUILD
+// TODO(crbug.com/390223051): Remove C-library calls to fix the errors.
+#pragma allow_unsafe_libc_calls
+#endif
+
 #include "media/gpu/v4l2/mt21/mt21_decompressor.h"
 
 #include <sched.h>
diff --git a/media/gpu/v4l2/mt21/mt21_decompressor_unittest.cc b/media/gpu/v4l2/mt21/mt21_decompressor_unittest.cc
index 5ba6b9802ec59..62ce42403acc2 100644
--- a/media/gpu/v4l2/mt21/mt21_decompressor_unittest.cc
+++ b/media/gpu/v4l2/mt21/mt21_decompressor_unittest.cc
@@ -2,6 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#ifdef UNSAFE_BUFFERS_BUILD
+// TODO(crbug.com/390223051): Remove C-library calls to fix the errors.
+#pragma allow_unsafe_libc_calls
+#endif
+
 #include "build/build_config.h"
 
 #if BUILDFLAG(IS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) && \
diff --git a/media/gpu/v4l2/mt21/mt21_util.h b/media/gpu/v4l2/mt21/mt21_util.h
index 47d8480ca57df..53073752e4468 100644
--- a/media/gpu/v4l2/mt21/mt21_util.h
+++ b/media/gpu/v4l2/mt21/mt21_util.h
@@ -2,6 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#ifdef UNSAFE_BUFFERS_BUILD
+// TODO(crbug.com/390223051): Remove C-library calls to fix the errors.
+#pragma allow_unsafe_libc_calls
+#endif
+
 #ifndef MEDIA_GPU_V4L2_MT21_MT21_UTIL_H_
 #define MEDIA_GPU_V4L2_MT21_MT21_UTIL_H_
 
diff --git a/media/gpu/v4l2/mt21/mt21_util_unittest.cc b/media/gpu/v4l2/mt21/mt21_util_unittest.cc
index 800fd8039c4ab..bbd43d6f066d6 100644
--- a/media/gpu/v4l2/mt21/mt21_util_unittest.cc
+++ b/media/gpu/v4l2/mt21/mt21_util_unittest.cc
@@ -2,6 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#ifdef UNSAFE_BUFFERS_BUILD
+// TODO(crbug.com/390223051): Remove C-library calls to fix the errors.
+#pragma allow_unsafe_libc_calls
+#endif
+
 #include "build/build_config.h"
 
 #if BUILDFLAG(IS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) && \
diff --git a/media/gpu/v4l2/v4l2_framerate_control.cc b/media/gpu/v4l2/v4l2_framerate_control.cc
index 583b27a056548..cddddb6662939 100644
--- a/media/gpu/v4l2/v4l2_framerate_control.cc
+++ b/media/gpu/v4l2/v4l2_framerate_control.cc
@@ -2,6 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#ifdef UNSAFE_BUFFERS_BUILD
+// TODO(crbug.com/390223051): Remove C-library calls to fix the errors.
+#pragma allow_unsafe_libc_calls
+#endif
+
 #include "media/gpu/v4l2/v4l2_framerate_control.h"
 
 #include <linux/videodev2.h>
diff --git a/media/gpu/v4l2/v4l2_jpeg_encode_accelerator.cc b/media/gpu/v4l2/v4l2_jpeg_encode_accelerator.cc
index 8ade5ab42816f..93c5b7a66c37d 100644
--- a/media/gpu/v4l2/v4l2_jpeg_encode_accelerator.cc
+++ b/media/gpu/v4l2/v4l2_jpeg_encode_accelerator.cc
@@ -2,6 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#ifdef UNSAFE_BUFFERS_BUILD
+// TODO(crbug.com/390223051): Remove C-library calls to fix the errors.
+#pragma allow_unsafe_libc_calls
+#endif
+
 #include "media/gpu/v4l2/v4l2_jpeg_encode_accelerator.h"
 
 #include <errno.h>
diff --git a/media/gpu/v4l2/v4l2_unittest.cc b/media/gpu/v4l2/v4l2_unittest.cc
index cc668cca455eb..fd1db41f459b9 100644
--- a/media/gpu/v4l2/v4l2_unittest.cc
+++ b/media/gpu/v4l2/v4l2_unittest.cc
@@ -2,6 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#ifdef UNSAFE_BUFFERS_BUILD
+// TODO(crbug.com/390223051): Remove C-library calls to fix the errors.
+#pragma allow_unsafe_libc_calls
+#endif
+
 #include <drm.h>
 #include <fcntl.h>
 #include <gbm.h>
diff --git a/media/gpu/v4l2/v4l2_video_decoder.cc b/media/gpu/v4l2/v4l2_video_decoder.cc
index 73ba13c3d64e0..8fa928e8ff6cb 100644
--- a/media/gpu/v4l2/v4l2_video_decoder.cc
+++ b/media/gpu/v4l2/v4l2_video_decoder.cc
@@ -2,6 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#ifdef UNSAFE_BUFFERS_BUILD
+// TODO(crbug.com/390223051): Remove C-library calls to fix the errors.
+#pragma allow_unsafe_libc_calls
+#endif
+
 #include "media/gpu/v4l2/v4l2_video_decoder.h"
 
 #include <drm_fourcc.h>
diff --git a/media/gpu/v4l2/v4l2_video_encode_accelerator.cc b/media/gpu/v4l2/v4l2_video_encode_accelerator.cc
index ea5c463e521e0..b1c62dffa0a4b 100644
--- a/media/gpu/v4l2/v4l2_video_encode_accelerator.cc
+++ b/media/gpu/v4l2/v4l2_video_encode_accelerator.cc
@@ -2,6 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#ifdef UNSAFE_BUFFERS_BUILD
+// TODO(crbug.com/390223051): Remove C-library calls to fix the errors.
+#pragma allow_unsafe_libc_calls
+#endif
+
 #include "media/gpu/v4l2/v4l2_video_encode_accelerator.h"
 
 #include <fcntl.h>