From 4e41a0b19949d20c0b1d4e99ebbc188640bca8bc Mon Sep 17 00:00:00 2001 From: Nicolas Benech Date: Thu, 18 Oct 2018 10:51:12 -0400 Subject: [PATCH] gpu: nvgpu: Fix LibC MISRA 17.7 in os/posix MISRA Rule-17.7 requires the return value of all functions to be used. Fix is either to use the return value or change the function to return void. This patch contains fix for all 17.7 violations instandard C functions in OS/Posix interface. JIRA NVGPU-1036 Change-Id: I2da417edc992f16de24cdff536c0538f1fde8b61 Signed-off-by: Nicolas Benech Reviewed-on: https://git-master.nvidia.com/r/1929901 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity Reviewed-by: svc-misra-checker GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/posix/log.c | 4 ++-- drivers/gpu/nvgpu/os/posix/posix-dma.c | 2 +- drivers/gpu/nvgpu/os/posix/posix-nvgpu_mem.c | 2 +- drivers/gpu/nvgpu/os/posix/rwsem.c | 2 +- drivers/gpu/nvgpu/os/posix/thread.c | 5 +++-- drivers/gpu/nvgpu/os/posix/timers.c | 6 +++--- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/nvgpu/os/posix/log.c b/drivers/gpu/nvgpu/os/posix/log.c index 35d262660..fb1e7858f 100644 --- a/drivers/gpu/nvgpu/os/posix/log.c +++ b/drivers/gpu/nvgpu/os/posix/log.c @@ -68,7 +68,7 @@ void __nvgpu_log_msg(struct gk20a *g, const char *func_name, int line, va_list args; va_start(args, fmt); - vsnprintf(log, LOG_BUFFER_LENGTH, fmt, args); + (void) vsnprintf(log, LOG_BUFFER_LENGTH, fmt, args); va_end(args); __nvgpu_really_print_log(nvgpu_log_name(g), @@ -87,7 +87,7 @@ void __nvgpu_log_dbg(struct gk20a *g, u64 log_mask, return; va_start(args, fmt); - vsnprintf(log, LOG_BUFFER_LENGTH, fmt, args); + (void) vsnprintf(log, LOG_BUFFER_LENGTH, fmt, args); va_end(args); __nvgpu_really_print_log(nvgpu_log_name(g), diff --git a/drivers/gpu/nvgpu/os/posix/posix-dma.c b/drivers/gpu/nvgpu/os/posix/posix-dma.c index 025e0fb8b..b03e3376f 100644 --- a/drivers/gpu/nvgpu/os/posix/posix-dma.c +++ b/drivers/gpu/nvgpu/os/posix/posix-dma.c @@ -97,7 +97,7 @@ void nvgpu_dma_free_sys(struct gk20a *g, struct nvgpu_mem *mem) if (!(mem->mem_flags & NVGPU_MEM_FLAG_SHADOW_COPY)) free(mem->cpu_va); - memset(mem, 0, sizeof(*mem)); + (void) memset(mem, 0, sizeof(*mem)); } void nvgpu_dma_free_vid(struct gk20a *g, struct nvgpu_mem *mem) diff --git a/drivers/gpu/nvgpu/os/posix/posix-nvgpu_mem.c b/drivers/gpu/nvgpu/os/posix/posix-nvgpu_mem.c index 9cfd85efa..bc229aedb 100644 --- a/drivers/gpu/nvgpu/os/posix/posix-nvgpu_mem.c +++ b/drivers/gpu/nvgpu/os/posix/posix-nvgpu_mem.c @@ -151,7 +151,7 @@ int nvgpu_mem_create_from_mem(struct gk20a *g, if ((start + size) > src->size) return -EINVAL; - memset(dest, 0, sizeof(*dest)); + (void) memset(dest, 0, sizeof(*dest)); dest->cpu_va = ((char *)src->cpu_va) + start; dest->mem_flags = src->mem_flags | NVGPU_MEM_FLAG_SHADOW_COPY; diff --git a/drivers/gpu/nvgpu/os/posix/rwsem.c b/drivers/gpu/nvgpu/os/posix/rwsem.c index 7a696b757..1c9f43517 100644 --- a/drivers/gpu/nvgpu/os/posix/rwsem.c +++ b/drivers/gpu/nvgpu/os/posix/rwsem.c @@ -28,7 +28,7 @@ void nvgpu_rwsem_init(struct nvgpu_rwsem *rwsem) { - memset(rwsem, 0, sizeof(*rwsem)); + (void) memset(rwsem, 0, sizeof(*rwsem)); nvgpu_spinlock_init(&rwsem->lock); } diff --git a/drivers/gpu/nvgpu/os/posix/thread.c b/drivers/gpu/nvgpu/os/posix/thread.c index d94765233..e72f95800 100644 --- a/drivers/gpu/nvgpu/os/posix/thread.c +++ b/drivers/gpu/nvgpu/os/posix/thread.c @@ -54,13 +54,14 @@ int nvgpu_thread_create(struct nvgpu_thread *thread, BUG_ON(thread->running); - memset(thread, 0, sizeof(*thread)); + (void) memset(thread, 0, sizeof(*thread)); /* * By subtracting 1 the above memset ensures that we have a zero * terminated string. */ - strncpy(thread->tname, name, NVGPU_THREAD_POSIX_MAX_NAMELEN - 1); + (void) strncpy(thread->tname, name, + NVGPU_THREAD_POSIX_MAX_NAMELEN - 1); thread->nvgpu.data = data; thread->nvgpu.fn = threadfn; diff --git a/drivers/gpu/nvgpu/os/posix/timers.c b/drivers/gpu/nvgpu/os/posix/timers.c index c84b0de56..3e4974607 100644 --- a/drivers/gpu/nvgpu/os/posix/timers.c +++ b/drivers/gpu/nvgpu/os/posix/timers.c @@ -45,7 +45,7 @@ int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout, if (flags & ~NVGPU_TIMER_FLAG_MASK) return -EINVAL; - memset(timeout, 0, sizeof(*timeout)); + (void) memset(timeout, 0, sizeof(*timeout)); timeout->g = g; timeout->flags = flags; @@ -68,7 +68,7 @@ static int __nvgpu_timeout_expired_msg_cpu(struct nvgpu_timeout *timeout, if (!(timeout->flags & NVGPU_TIMER_SILENT_TIMEOUT)) { char buf[128]; - vsnprintf(buf, sizeof(buf), fmt, args); + (void) vsnprintf(buf, sizeof(buf), fmt, args); nvgpu_err(g, "Timeout detected @ %p %s", caller, buf); } @@ -89,7 +89,7 @@ static int __nvgpu_timeout_expired_msg_retry(struct nvgpu_timeout *timeout, if (!(timeout->flags & NVGPU_TIMER_SILENT_TIMEOUT)) { char buf[128]; - vsnprintf(buf, sizeof(buf), fmt, args); + (void) vsnprintf(buf, sizeof(buf), fmt, args); nvgpu_err(g, "No more retries @ %p %s", caller, buf); }