gpu: nvgpu: resolve GCC 9.3 toolchain errors

Using updated GCC 9.3 toolchain results into build failure with string
functions. The updated toolchain requires strncat API to be independent
of source string length.
Update strncat used in nvgpu_worker_init_name to use destination length
only.

Bug 3270814

Change-Id: Ie50a2bed2dc09a5e34d14012e1ba878ef4ff176f
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2500503
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Aidan Ha <aha@nvidia.com>
Reviewed-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Vedashree Vidwans
2021-03-17 15:46:50 -07:00
committed by mobile promotions
parent ff8fbf1004
commit 8ebe7ca314

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -256,18 +256,15 @@ void nvgpu_worker_init_name(struct nvgpu_worker *worker,
/* Terminate thread name with NULL character */
worker->thread_name[0] = '\0';
(void) strncat(worker->thread_name, worker_name,
min(num_free_chars, strlen(worker_name)));
(void) strncat(worker->thread_name, worker_name, num_free_chars);
num_free_chars = worker_name_size - strlen(worker->thread_name);
(void) strncat(worker->thread_name, "_",
min(num_free_chars, sizeof("_")));
(void) strncat(worker->thread_name, "_", num_free_chars);
num_free_chars = worker_name_size - strlen(worker->thread_name);
(void) strncat(worker->thread_name, gpu_name,
min(num_free_chars, strlen(gpu_name)));
(void) strncat(worker->thread_name, gpu_name, num_free_chars);
}
int nvgpu_worker_init(struct gk20a *g, struct nvgpu_worker *worker,