From a74ffd690023186dd8173cebed689ee78116a305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Wed, 21 Jan 2026 10:00:20 +0100 Subject: [PATCH] Pass the destination buffer size minus one to strncpy Copying the last byte was pointless, since the next line overwrites it, and resulted in a compiler warning: ../src/intel/common/intel_measure.c: In function 'intel_measure_init': ../src/intel/common/intel_measure.c:68:7: warning: 'strncpy' specified bound 1024 equals destination size [-Wstringop-truncation] 68 | strncpy(env_copy, env, 1024); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ This allows dropping -Wno-error=stringop-truncation from the debian-x86_64-asan & debian-{arm64,x86_64}-ubsan CI jobs. Part-of: --- .gitlab-ci/build/gitlab-ci.yml | 3 --- src/gallium/auxiliary/hud/hud_driver_query.c | 2 +- src/intel/common/intel_measure.c | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci/build/gitlab-ci.yml b/.gitlab-ci/build/gitlab-ci.yml index 8827a5e151b..513ca8df9b4 100644 --- a/.gitlab-ci/build/gitlab-ci.yml +++ b/.gitlab-ci/build/gitlab-ci.yml @@ -60,7 +60,6 @@ debian-x86_64-asan: VULKAN_DRIVERS: "swrast,amd,intel" GALLIUM_DRIVERS: "llvmpipe,softpipe,zink,r300" C_ARGS: > - -Wno-error=stringop-truncation -Wno-error=deprecated-declarations EXTRA_OPTION: > -D intel-elk=false @@ -149,7 +148,6 @@ debian-x86_64-ubsan: variables: C_ARGS: > -Wno-error=stringop-overflow - -Wno-error=stringop-truncation -Wno-error=deprecated-declarations CPP_ARGS: > -Wno-error=array-bounds @@ -533,7 +531,6 @@ debian-arm64-ubsan: C_ARGS: > -Wno-error=array-bounds -Wno-error=stringop-overflow - -Wno-error=stringop-truncation -Wno-error=deprecated-declarations CPP_ARGS: > -Wno-error=array-bounds diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c b/src/gallium/auxiliary/hud/hud_driver_query.c index e403a5b4bc4..b8fc599f953 100644 --- a/src/gallium/auxiliary/hud/hud_driver_query.c +++ b/src/gallium/auxiliary/hud/hud_driver_query.c @@ -383,7 +383,7 @@ hud_pipe_query_install(struct hud_batch_query_context **pbq, if (!gr) return; - strncpy(gr->name, name, sizeof(gr->name)); + strncpy(gr->name, name, sizeof(gr->name) - 1); gr->name[sizeof(gr->name) - 1] = '\0'; gr->query_data = CALLOC_STRUCT(query_info); if (!gr->query_data) diff --git a/src/intel/common/intel_measure.c b/src/intel/common/intel_measure.c index 7315f7e8d25..3013b6a0a08 100644 --- a/src/intel/common/intel_measure.c +++ b/src/intel/common/intel_measure.c @@ -65,7 +65,7 @@ intel_measure_init(struct intel_measure_device *device) return; char env_copy[1024]; - strncpy(env_copy, env, 1024); + strncpy(env_copy, env, 1023); env_copy[1023] = '\0'; config.file = stderr;