[07/25] drivers/gpu: replace snprintf with strlcpy

Message ID 20230601150106.18375-8-stephen@networkplumber.org (mailing list archive)
State Rejected
Delegated to: Thomas Monjalon
Headers
Series replace snprintf with strlcpy |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger June 1, 2023, 3 p.m. UTC
  Suggested by devtools/cocci/strlcpy-with-header.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/gpu/cuda/cuda.c    | 2 +-
 drivers/gpu/cuda/gdrcopy.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/drivers/gpu/cuda/cuda.c b/drivers/gpu/cuda/cuda.c
index a552aabeb82d..01875816d592 100644
--- a/drivers/gpu/cuda/cuda.c
+++ b/drivers/gpu/cuda/cuda.c
@@ -291,7 +291,7 @@  cuda_loader(void)
 	char cuda_path[1024];
 
 	if (getenv("CUDA_PATH_L") == NULL)
-		snprintf(cuda_path, 1024, "%s", "libcuda.so");
+		strlcpy(cuda_path, "libcuda.so", 1024);
 	else
 		snprintf(cuda_path, 1024, "%s/%s", getenv("CUDA_PATH_L"), "libcuda.so");
 
diff --git a/drivers/gpu/cuda/gdrcopy.c b/drivers/gpu/cuda/gdrcopy.c
index 322a5dbeb207..ad7809a99b00 100644
--- a/drivers/gpu/cuda/gdrcopy.c
+++ b/drivers/gpu/cuda/gdrcopy.c
@@ -20,7 +20,7 @@  gdrcopy_loader(void)
 	char gdrcopy_path[1024];
 
 	if (getenv("GDRCOPY_PATH_L") == NULL)
-		snprintf(gdrcopy_path, 1024, "%s", "libgdrapi.so");
+		strlcpy(gdrcopy_path, "libgdrapi.so", 1024);
 	else
 		snprintf(gdrcopy_path, 1024, "%s/%s", getenv("GDRCOPY_PATH_L"), "libgdrapi.so");