From b9e7ea65e1d73b8e5ba04eb2f66214f21f68e3c2 Mon Sep 17 00:00:00 2001 From: Nicolas Benech Date: Thu, 18 Oct 2018 10:50:51 -0400 Subject: [PATCH] gpu: nvgpu: Fix LibC MISRA 17.7 in os/linux 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/Linux interface. JIRA NVGPU-1036 Change-Id: I39b20f1d0e1a1da56d452f2c3d5ee049666cefe8 Signed-off-by: Nicolas Benech Reviewed-on: https://git-master.nvidia.com/r/1929900 Reviewed-by: Automatic_Commit_Validation_User 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/linux/cde.c | 10 +++++----- drivers/gpu/nvgpu/os/linux/comptags.c | 2 +- drivers/gpu/nvgpu/os/linux/ctxsw_trace.c | 10 ++++++---- drivers/gpu/nvgpu/os/linux/debug_kmem.c | 6 +++--- drivers/gpu/nvgpu/os/linux/debug_pmu.c | 6 +++--- drivers/gpu/nvgpu/os/linux/debug_xve.c | 4 ++-- drivers/gpu/nvgpu/os/linux/firmware.c | 4 ++-- drivers/gpu/nvgpu/os/linux/ioctl_as.c | 6 +++--- drivers/gpu/nvgpu/os/linux/ioctl_channel.c | 4 ++-- drivers/gpu/nvgpu/os/linux/ioctl_clk_arb.c | 6 +++--- drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c | 13 +++++++------ drivers/gpu/nvgpu/os/linux/ioctl_dbg.c | 2 +- drivers/gpu/nvgpu/os/linux/ioctl_tsg.c | 4 ++-- drivers/gpu/nvgpu/os/linux/kmem.c | 4 ++-- drivers/gpu/nvgpu/os/linux/linux-channel.c | 2 +- drivers/gpu/nvgpu/os/linux/log.c | 4 ++-- drivers/gpu/nvgpu/os/linux/nvgpu_mem.c | 2 +- drivers/gpu/nvgpu/os/linux/pci.c | 5 +++-- drivers/gpu/nvgpu/os/linux/pci_power.c | 2 +- drivers/gpu/nvgpu/os/linux/platform_gk20a_tegra.c | 4 ++-- drivers/gpu/nvgpu/os/linux/sched.c | 8 ++++---- drivers/gpu/nvgpu/os/linux/sync_sema_android.c | 8 ++++---- drivers/gpu/nvgpu/os/linux/sysfs.c | 2 +- drivers/gpu/nvgpu/os/linux/timers.c | 6 +++--- drivers/gpu/nvgpu/os/linux/vgpu/fecs_trace_vgpu.c | 2 +- include/uapi/linux/nvgpu.h | 6 ++++-- 26 files changed, 69 insertions(+), 63 deletions(-) diff --git a/drivers/gpu/nvgpu/os/linux/cde.c b/drivers/gpu/nvgpu/os/linux/cde.c index 7cb82d7d0..e416e2805 100644 --- a/drivers/gpu/nvgpu/os/linux/cde.c +++ b/drivers/gpu/nvgpu/os/linux/cde.c @@ -290,7 +290,7 @@ static int gk20a_init_cde_buf(struct gk20a_cde_ctx *cde_ctx, /* copy the content */ if (buf->data_byte_offset != 0) - memcpy(mem->cpu_va, img->data + buf->data_byte_offset, + (void) memcpy(mem->cpu_va, img->data + buf->data_byte_offset, buf->num_bytes); cde_ctx->num_bufs++; @@ -644,8 +644,8 @@ static int gk20a_cde_pack_cmdbufs(struct gk20a_cde_ctx *cde_ctx) } /* move the original init here and append convert */ - memcpy(combined_cmd, cde_ctx->init_convert_cmd, init_bytes); - memcpy(combined_cmd + cde_ctx->init_cmd_num_entries, + (void) memcpy(combined_cmd, cde_ctx->init_convert_cmd, init_bytes); + (void) memcpy(combined_cmd + cde_ctx->init_cmd_num_entries, cde_ctx->convert_cmd, conv_bytes); nvgpu_kfree(g, cde_ctx->init_convert_cmd); @@ -714,7 +714,7 @@ static int gk20a_init_cde_img(struct gk20a_cde_ctx *cde_ctx, break; } case TYPE_ARRAY: - memcpy(&cde_app->arrays[elem->array.id][0], + (void) memcpy(&cde_app->arrays[elem->array.id][0], elem->array.data, MAX_CDE_ARRAY_ENTRIES*sizeof(u32)); break; @@ -1173,7 +1173,7 @@ __releases(&l->cde_app->mutex) cde_ctx->scatterbuffer_size = scatterbuffer_size; /* remove existing argument data */ - memset(cde_ctx->user_param_values, 0, + (void) memset(cde_ctx->user_param_values, 0, sizeof(cde_ctx->user_param_values)); /* read user space arguments for the conversion */ diff --git a/drivers/gpu/nvgpu/os/linux/comptags.c b/drivers/gpu/nvgpu/os/linux/comptags.c index ab371972d..1e127c7b4 100644 --- a/drivers/gpu/nvgpu/os/linux/comptags.c +++ b/drivers/gpu/nvgpu/os/linux/comptags.c @@ -33,7 +33,7 @@ void gk20a_get_comptags(struct nvgpu_os_buffer *buf, return; if (!priv) { - memset(comptags, 0, sizeof(*comptags)); + (void) memset(comptags, 0, sizeof(*comptags)); return; } diff --git a/drivers/gpu/nvgpu/os/linux/ctxsw_trace.c b/drivers/gpu/nvgpu/os/linux/ctxsw_trace.c index e88c21506..450b14b0d 100644 --- a/drivers/gpu/nvgpu/os/linux/ctxsw_trace.c +++ b/drivers/gpu/nvgpu/os/linux/ctxsw_trace.c @@ -252,13 +252,15 @@ static int gk20a_ctxsw_dev_ioctl_ring_setup(struct gk20a_ctxsw_dev *dev, static void nvgpu_set_ctxsw_trace_filter_args(struct nvgpu_gpu_ctxsw_trace_filter *filter_dst, struct nvgpu_ctxsw_trace_filter *filter_src) { - memcpy(filter_dst->tag_bits, filter_src->tag_bits, (NVGPU_CTXSW_FILTER_SIZE + 63) / 64); + (void) memcpy(filter_dst->tag_bits, filter_src->tag_bits, + (NVGPU_CTXSW_FILTER_SIZE + 63) / 64); } static void nvgpu_get_ctxsw_trace_filter_args(struct nvgpu_ctxsw_trace_filter *filter_dst, struct nvgpu_gpu_ctxsw_trace_filter *filter_src) { - memcpy(filter_dst->tag_bits, filter_src->tag_bits, (NVGPU_CTXSW_FILTER_SIZE + 63) / 64); + (void) memcpy(filter_dst->tag_bits, filter_src->tag_bits, + (NVGPU_CTXSW_FILTER_SIZE + 63) / 64); } static int gk20a_ctxsw_dev_ioctl_set_filter(struct gk20a_ctxsw_dev *dev, @@ -418,7 +420,7 @@ long gk20a_ctxsw_dev_ioctl(struct file *filp, unsigned int cmd, (_IOC_SIZE(cmd) > NVGPU_CTXSW_IOCTL_MAX_ARG_SIZE)) return -EINVAL; - memset(buf, 0, sizeof(buf)); + (void) memset(buf, 0, sizeof(buf)); if (_IOC_DIR(cmd) & _IOC_WRITE) { if (copy_from_user(buf, (void __user *) arg, _IOC_SIZE(cmd))) return -EFAULT; @@ -580,7 +582,7 @@ int gk20a_ctxsw_trace_init(struct gk20a *g) return 0; fail: - memset(&g->ops.fecs_trace, 0, sizeof(g->ops.fecs_trace)); + (void) memset(&g->ops.fecs_trace, 0, sizeof(g->ops.fecs_trace)); nvgpu_kfree(g, trace); g->ctxsw_trace = NULL; return err; diff --git a/drivers/gpu/nvgpu/os/linux/debug_kmem.c b/drivers/gpu/nvgpu/os/linux/debug_kmem.c index a0c7d47d0..1e7a93b83 100644 --- a/drivers/gpu/nvgpu/os/linux/debug_kmem.c +++ b/drivers/gpu/nvgpu/os/linux/debug_kmem.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 NVIDIA Corporation. All rights reserved. + * Copyright (C) 2018 NVIDIA Corporation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -164,7 +164,7 @@ static void print_histogram(struct nvgpu_mem_alloc_tracker *tracker, u64 hr_bytes; const char *hr_suffix; - memset(this_line, 0, sizeof(this_line)); + (void) memset(this_line, 0, sizeof(this_line)); /* * Compute the normalized line length. Cant use floating point @@ -175,7 +175,7 @@ static void print_histogram(struct nvgpu_mem_alloc_tracker *tracker, line_length *= sizeof(histogram_line); line_length /= 1000; - memset(this_line, '+', line_length); + (void) memset(this_line, '+', line_length); __to_human_readable_bytes(1 << (__ffs(pot_min) + i), &hr_bytes, &hr_suffix); diff --git a/drivers/gpu/nvgpu/os/linux/debug_pmu.c b/drivers/gpu/nvgpu/os/linux/debug_pmu.c index f4ed992df..cc47b86ed 100644 --- a/drivers/gpu/nvgpu/os/linux/debug_pmu.c +++ b/drivers/gpu/nvgpu/os/linux/debug_pmu.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 NVIDIA Corporation. All rights reserved. + * Copyright (C) 2018 NVIDIA Corporation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -284,7 +284,7 @@ static int falc_trace_show(struct seq_file *s, void *data) while (nvgpu_find_hex_in_string((trace+i+20+m), g, &k)) { if (k >= 40) break; - strncpy(part_str, (trace+i+20+m), k); + (void) strncpy(part_str, (trace+i+20+m), k); part_str[k] = 0; seq_printf(s, "%s0x%x", part_str, trace1[(i / 4) + 1 + l]); @@ -334,7 +334,7 @@ static ssize_t perfmon_events_enable_write(struct file *file, int buf_size; int err; - memset(buf, 0, sizeof(buf)); + (void) memset(buf, 0, sizeof(buf)); buf_size = min(count, (sizeof(buf)-1)); if (copy_from_user(buf, userbuf, buf_size)) diff --git a/drivers/gpu/nvgpu/os/linux/debug_xve.c b/drivers/gpu/nvgpu/os/linux/debug_xve.c index 128d31606..5bca87ab9 100644 --- a/drivers/gpu/nvgpu/os/linux/debug_xve.c +++ b/drivers/gpu/nvgpu/os/linux/debug_xve.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 NVIDIA Corporation. All rights reserved. + * Copyright (C) 2018 NVIDIA Corporation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -34,7 +34,7 @@ static ssize_t xve_link_speed_write(struct file *filp, buff_size = min_t(size_t, 16, len); - memset(kbuff, 0, 16); + (void) memset(kbuff, 0, 16); if (copy_from_user(kbuff, buff, buff_size)) return -EFAULT; diff --git a/drivers/gpu/nvgpu/os/linux/firmware.c b/drivers/gpu/nvgpu/os/linux/firmware.c index 8f0344be7..9d55eb575 100644 --- a/drivers/gpu/nvgpu/os/linux/firmware.c +++ b/drivers/gpu/nvgpu/os/linux/firmware.c @@ -40,7 +40,7 @@ static const struct firmware *do_request_firmware(struct device *dev, if (!fw_path) return NULL; - sprintf(fw_path, "%s/%s", prefix, fw_name); + (void) sprintf(fw_path, "%s/%s", prefix, fw_name); fw_name = fw_path; } @@ -93,7 +93,7 @@ struct nvgpu_firmware *nvgpu_request_firmware(struct gk20a *g, if (!fw->data) goto err_release; - memcpy(fw->data, linux_fw->data, linux_fw->size); + (void) memcpy(fw->data, linux_fw->data, linux_fw->size); fw->size = linux_fw->size; release_firmware(linux_fw); diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_as.c b/drivers/gpu/nvgpu/os/linux/ioctl_as.c index 3fa8aa2c5..4da83b867 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_as.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_as.c @@ -183,7 +183,7 @@ static int gk20a_as_ioctl_map_buffer_batch( s16 incompressible_kind; struct nvgpu_as_map_buffer_ex_args map_args; - memset(&map_args, 0, sizeof(map_args)); + (void) memset(&map_args, 0, sizeof(map_args)); if (copy_from_user(&map_args, &user_map_args[i], sizeof(map_args))) { @@ -249,7 +249,7 @@ static int gk20a_as_ioctl_get_va_regions( struct nvgpu_as_va_region region; struct nvgpu_allocator *vma = vm->vma[i]; - memset(®ion, 0, sizeof(struct nvgpu_as_va_region)); + (void) memset(®ion, 0, sizeof(struct nvgpu_as_va_region)); region.page_size = vm->gmmu_page_sizes[i]; region.offset = nvgpu_alloc_base(vma); @@ -345,7 +345,7 @@ long gk20a_as_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) (_IOC_SIZE(cmd) > NVGPU_AS_IOCTL_MAX_ARG_SIZE)) return -EINVAL; - memset(buf, 0, sizeof(buf)); + (void) memset(buf, 0, sizeof(buf)); if (_IOC_DIR(cmd) & _IOC_WRITE) { if (copy_from_user(buf, (void __user *)arg, _IOC_SIZE(cmd))) return -EFAULT; diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c index fa4fe2b1d..9fd7aa677 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c @@ -396,7 +396,7 @@ static int gk20a_init_error_notifier(struct channel_gk20a *ch, priv->error_notifier.notification = va + args->offset; priv->error_notifier.vaddr = va; - memset(priv->error_notifier.notification, 0, + (void) memset(priv->error_notifier.notification, 0, sizeof(struct nvgpu_notification)); /* set channel notifiers pointer */ @@ -553,7 +553,7 @@ int gk20a_channel_open_ioctl(struct gk20a *g, return err; fd = err; - snprintf(name, sizeof(name), "nvhost-%s-fd%d", + (void) snprintf(name, sizeof(name), "nvhost-%s-fd%d", dev_name(dev_from_gk20a(g)), fd); file = anon_inode_getfile(name, l->channel.cdev.ops, NULL, O_RDWR); diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_clk_arb.c b/drivers/gpu/nvgpu/os/linux/ioctl_clk_arb.c index 477222dc5..c061eb9e9 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_clk_arb.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_clk_arb.c @@ -198,7 +198,7 @@ static ssize_t nvgpu_clk_arb_read_event_dev(struct file *filp, char __user *buf, if ((size - *off) < sizeof(info)) return 0; - memset(&info, 0, sizeof(info)); + (void) memset(&info, 0, sizeof(info)); /* Get the oldest event from the queue */ while (!__pending_event(dev, &info)) { if (filp->f_flags & O_NONBLOCK) @@ -257,7 +257,7 @@ static long nvgpu_clk_arb_ioctl_event_dev(struct file *filp, unsigned int cmd, BUG_ON(_IOC_SIZE(cmd) > NVGPU_EVENT_IOCTL_MAX_ARG_SIZE); - memset(buf, 0, sizeof(buf)); + (void) memset(buf, 0, sizeof(buf)); if (_IOC_DIR(cmd) & _IOC_WRITE) { if (copy_from_user(buf, (void __user *) arg, _IOC_SIZE(cmd))) return -EFAULT; @@ -327,7 +327,7 @@ static int nvgpu_clk_arb_install_fd(struct gk20a *g, goto fail; } - snprintf(name, sizeof(name), "%s-clk-fd%d", g->name, fd); + (void) snprintf(name, sizeof(name), "%s-clk-fd%d", g->name, fd); file = anon_inode_getfile(name, fops, dev, O_RDWR); if (IS_ERR(file)) { err = PTR_ERR(file); diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c index 9b4f50a53..f2ecd8f5d 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c @@ -273,7 +273,7 @@ gk20a_ctrl_ioctl_gpu_characteristics( return -EINVAL; } - memset(&gpu, 0, sizeof(gpu)); + (void) memset(&gpu, 0, sizeof(gpu)); gpu.L2_cache_size = g->ops.ltc.determine_L2_size_bytes(g); gpu.on_board_video_memory_size = 0; /* integrated GPU */ @@ -477,7 +477,7 @@ static int gk20a_ctrl_alloc_as( return err; fd = err; - snprintf(name, sizeof(name), "nvhost-%s-fd%d", g->name, fd); + (void) snprintf(name, sizeof(name), "nvhost-%s-fd%d", g->name, fd); file = anon_inode_getfile(name, l->as_dev.cdev.ops, NULL, O_RDWR); if (IS_ERR(file)) { @@ -519,7 +519,7 @@ static int gk20a_ctrl_open_tsg(struct gk20a *g, return err; fd = err; - snprintf(name, sizeof(name), "nvgpu-%s-tsg%d", g->name, fd); + (void) snprintf(name, sizeof(name), "nvgpu-%s-tsg%d", g->name, fd); file = anon_inode_getfile(name, l->tsg.cdev.ops, NULL, O_RDWR); if (IS_ERR(file)) { @@ -886,7 +886,7 @@ static int nvgpu_gpu_get_engine_info( &g->fifo.engine_info[active_engine_id]; struct nvgpu_gpu_get_engine_info_item dst_info; - memset(&dst_info, 0, sizeof(dst_info)); + (void) memset(&dst_info, 0, sizeof(dst_info)); engine_enum = src_info->engine_enum; @@ -1619,7 +1619,7 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg (_IOC_SIZE(cmd) > NVGPU_GPU_IOCTL_MAX_ARG_SIZE)) return -EINVAL; - memset(buf, 0, sizeof(buf)); + (void) memset(buf, 0, sizeof(buf)); if (_IOC_DIR(cmd) & _IOC_WRITE) { if (copy_from_user(buf, (void __user *)arg, _IOC_SIZE(cmd))) return -EFAULT; @@ -1643,7 +1643,8 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg case NVGPU_GPU_IOCTL_ZCULL_GET_INFO: get_info_args = (struct nvgpu_gpu_zcull_get_info_args *)buf; - memset(get_info_args, 0, sizeof(struct nvgpu_gpu_zcull_get_info_args)); + (void) memset(get_info_args, 0, + sizeof(struct nvgpu_gpu_zcull_get_info_args)); zcull_info = nvgpu_kzalloc(g, sizeof(struct gr_zcull_info)); if (zcull_info == NULL) diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c b/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c index 96ee35b7c..fc15d4971 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c @@ -1872,7 +1872,7 @@ long gk20a_dbg_gpu_dev_ioctl(struct file *filp, unsigned int cmd, (_IOC_SIZE(cmd) > NVGPU_DBG_GPU_IOCTL_MAX_ARG_SIZE)) return -EINVAL; - memset(buf, 0, sizeof(buf)); + (void) memset(buf, 0, sizeof(buf)); if (_IOC_DIR(cmd) & _IOC_WRITE) { if (copy_from_user(buf, (void __user *)arg, _IOC_SIZE(cmd))) return -EFAULT; diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c b/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c index 7ebf42910..b8c61d003 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c @@ -305,7 +305,7 @@ static int gk20a_tsg_event_id_enable(struct tsg_gk20a *tsg, goto free_ref; local_fd = err; - snprintf(name, sizeof(name), "nvgpu-event%d-fd%d", + (void) snprintf(name, sizeof(name), "nvgpu-event%d-fd%d", event_id, local_fd); file = anon_inode_getfile(name, &gk20a_event_id_ops, @@ -612,7 +612,7 @@ long nvgpu_ioctl_tsg_dev_ioctl(struct file *filp, unsigned int cmd, (_IOC_SIZE(cmd) > NVGPU_TSG_IOCTL_MAX_ARG_SIZE)) return -EINVAL; - memset(buf, 0, sizeof(buf)); + (void) memset(buf, 0, sizeof(buf)); if (_IOC_DIR(cmd) & _IOC_WRITE) { if (copy_from_user(buf, (void __user *)arg, _IOC_SIZE(cmd))) return -EFAULT; diff --git a/drivers/gpu/nvgpu/os/linux/kmem.c b/drivers/gpu/nvgpu/os/linux/kmem.c index 395cc458f..7c3549f0f 100644 --- a/drivers/gpu/nvgpu/os/linux/kmem.c +++ b/drivers/gpu/nvgpu/os/linux/kmem.c @@ -300,7 +300,7 @@ static int __nvgpu_free_kmem_alloc(struct nvgpu_mem_alloc_tracker *tracker, return -EINVAL; } - memset((void *)alloc->addr, 0, alloc->size); + (void) memset((void *)alloc->addr, 0, alloc->size); tracker->nr_frees++; tracker->bytes_freed += alloc->size; @@ -621,7 +621,7 @@ struct nvgpu_kmem_cache *nvgpu_kmem_cache_create(struct gk20a *g, size_t size) cache->g = g; - snprintf(cache->name, sizeof(cache->name), + (void) snprintf(cache->name, sizeof(cache->name), "nvgpu-cache-0x%p-%d-%d", g, (int)size, atomic_inc_return(&kmem_cache_id)); cache->cache = kmem_cache_create(cache->name, diff --git a/drivers/gpu/nvgpu/os/linux/linux-channel.c b/drivers/gpu/nvgpu/os/linux/linux-channel.c index d035baf71..9ead003f3 100644 --- a/drivers/gpu/nvgpu/os/linux/linux-channel.c +++ b/drivers/gpu/nvgpu/os/linux/linux-channel.c @@ -332,7 +332,7 @@ static int nvgpu_channel_init_os_fence_framework(struct channel_gk20a *ch, fence_framework = &priv->fence_framework; va_start(args, fmt); - vsnprintf(name, sizeof(name), fmt, args); + (void) vsnprintf(name, sizeof(name), fmt, args); va_end(args); fence_framework->timeline = gk20a_sync_timeline_create(name); diff --git a/drivers/gpu/nvgpu/os/linux/log.c b/drivers/gpu/nvgpu/os/linux/log.c index bd9f67dad..d6122c300 100644 --- a/drivers/gpu/nvgpu/os/linux/log.c +++ b/drivers/gpu/nvgpu/os/linux/log.c @@ -105,7 +105,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(0, g ? nvgpu_log_name(g) : "", @@ -124,7 +124,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(g->log_trace, nvgpu_log_name(g), diff --git a/drivers/gpu/nvgpu/os/linux/nvgpu_mem.c b/drivers/gpu/nvgpu/os/linux/nvgpu_mem.c index 1a6e64250..ce6fbe4ea 100644 --- a/drivers/gpu/nvgpu/os/linux/nvgpu_mem.c +++ b/drivers/gpu/nvgpu/os/linux/nvgpu_mem.c @@ -202,7 +202,7 @@ int __nvgpu_mem_create_from_pages(struct gk20a *g, struct nvgpu_mem *dest, if (!our_pages) return -ENOMEM; - memcpy(our_pages, pages, sizeof(struct page *) * nr_pages); + (void) memcpy(our_pages, pages, sizeof(struct page *) * nr_pages); if (nvgpu_get_sgtable_from_pages(g, &sgt, pages, 0, nr_pages * PAGE_SIZE)) { diff --git a/drivers/gpu/nvgpu/os/linux/pci.c b/drivers/gpu/nvgpu/os/linux/pci.c index dff55c801..ada62d05d 100644 --- a/drivers/gpu/nvgpu/os/linux/pci.c +++ b/drivers/gpu/nvgpu/os/linux/pci.c @@ -701,7 +701,8 @@ static int nvgpu_pci_probe(struct pci_dev *pdev, } /* copy detected device data to allocated platform space*/ - memcpy((void *)platform, (void *)&nvgpu_pci_device[pent->driver_data], + (void) memcpy((void *)platform, + (void *)&nvgpu_pci_device[pent->driver_data], sizeof(struct gk20a_platform)); pci_set_drvdata(pdev, platform); @@ -778,7 +779,7 @@ static int nvgpu_pci_probe(struct pci_dev *pdev, goto err_free_irq; } - snprintf(nodefmt, sizeof(nodefmt), + (void) snprintf(nodefmt, sizeof(nodefmt), PCI_INTERFACE_NAME, dev_name(&pdev->dev)); err = nvgpu_probe(g, "gpu_pci", nodefmt, &nvgpu_pci_class); diff --git a/drivers/gpu/nvgpu/os/linux/pci_power.c b/drivers/gpu/nvgpu/os/linux/pci_power.c index 52d6e63a9..8dee39ee0 100644 --- a/drivers/gpu/nvgpu/os/linux/pci_power.c +++ b/drivers/gpu/nvgpu/os/linux/pci_power.c @@ -143,7 +143,7 @@ static int nvgpu_pci_parse_dev_name(const char *buf, size_t count, char *name) if (ret < 4) return -EINVAL; - snprintf(name, PCI_DEV_NAME_MAX, "%04x:%02x:%02x.%1x", + (void) snprintf(name, PCI_DEV_NAME_MAX, "%04x:%02x:%02x.%1x", domain, bus, device, func); return 0; diff --git a/drivers/gpu/nvgpu/os/linux/platform_gk20a_tegra.c b/drivers/gpu/nvgpu/os/linux/platform_gk20a_tegra.c index 408e546fc..83df13acc 100644 --- a/drivers/gpu/nvgpu/os/linux/platform_gk20a_tegra.c +++ b/drivers/gpu/nvgpu/os/linux/platform_gk20a_tegra.c @@ -482,7 +482,7 @@ static int gk20a_tegra_get_clocks(struct device *dev) BUG_ON(GK20A_CLKS_MAX < ARRAY_SIZE(tegra_gk20a_clocks)); - snprintf(devname, sizeof(devname), "tegra_%s", dev_name(dev)); + (void) snprintf(devname, sizeof(devname), "tegra_%s", dev_name(dev)); platform->num_clks = 0; for (i = 0; i < ARRAY_SIZE(tegra_gk20a_clocks); i++) { @@ -655,7 +655,7 @@ static struct clk *gk20a_clk_get(struct gk20a *g) char clk_dev_id[32]; struct device *dev = dev_from_gk20a(g); - snprintf(clk_dev_id, 32, "tegra_%s", dev_name(dev)); + (void) snprintf(clk_dev_id, 32, "tegra_%s", dev_name(dev)); clk = clk_get_sys(clk_dev_id, "gpu"); if (IS_ERR(clk)) { diff --git a/drivers/gpu/nvgpu/os/linux/sched.c b/drivers/gpu/nvgpu/os/linux/sched.c index 4f9aa782f..f602d0480 100644 --- a/drivers/gpu/nvgpu/os/linux/sched.c +++ b/drivers/gpu/nvgpu/os/linux/sched.c @@ -136,7 +136,7 @@ static int gk20a_sched_dev_ioctl_get_recent_tsgs(struct gk20a_sched_ctrl *sched, return -EFAULT; } - memset(sched->recent_tsg_bitmap, 0, sched->bitmap_size); + (void) memset(sched->recent_tsg_bitmap, 0, sched->bitmap_size); nvgpu_mutex_release(&sched->status_lock); return 0; @@ -418,9 +418,9 @@ int gk20a_sched_dev_open(struct inode *inode, struct file *filp) goto free_ref; } - memcpy(sched->recent_tsg_bitmap, sched->active_tsg_bitmap, + (void) memcpy(sched->recent_tsg_bitmap, sched->active_tsg_bitmap, sched->bitmap_size); - memset(sched->ref_tsg_bitmap, 0, sched->bitmap_size); + (void) memset(sched->ref_tsg_bitmap, 0, sched->bitmap_size); filp->private_data = sched; nvgpu_log(g, gpu_dbg_sched, "filp=%p sched=%p", filp, sched); @@ -447,7 +447,7 @@ long gk20a_sched_dev_ioctl(struct file *filp, unsigned int cmd, (_IOC_SIZE(cmd) > NVGPU_SCHED_IOCTL_MAX_ARG_SIZE)) return -EINVAL; - memset(buf, 0, sizeof(buf)); + (void) memset(buf, 0, sizeof(buf)); if (_IOC_DIR(cmd) & _IOC_WRITE) { if (copy_from_user(buf, (void __user *)arg, _IOC_SIZE(cmd))) return -EFAULT; diff --git a/drivers/gpu/nvgpu/os/linux/sync_sema_android.c b/drivers/gpu/nvgpu/os/linux/sync_sema_android.c index 59e3b7a64..1e98e644a 100644 --- a/drivers/gpu/nvgpu/os/linux/sync_sema_android.c +++ b/drivers/gpu/nvgpu/os/linux/sync_sema_android.c @@ -276,7 +276,7 @@ static void gk20a_sync_timeline_value_str(struct sync_timeline *timeline, { struct gk20a_sync_timeline *obj = (struct gk20a_sync_timeline *)timeline; - snprintf(str, size, "%d", gk20a_sync_timeline_current(obj)); + (void) snprintf(str, size, "%d", gk20a_sync_timeline_current(obj)); } static void gk20a_sync_pt_value_str_for_sema(struct gk20a_sync_pt *pt, @@ -284,7 +284,7 @@ static void gk20a_sync_pt_value_str_for_sema(struct gk20a_sync_pt *pt, { struct nvgpu_semaphore *s = pt->sema; - snprintf(str, size, "S: pool=%llu [v=%u,r_v=%u]", + (void) snprintf(str, size, "S: pool=%llu [v=%u,r_v=%u]", s->location.pool->page_idx, nvgpu_semaphore_get_value(s), nvgpu_semaphore_read(s)); @@ -300,7 +300,7 @@ static void gk20a_sync_pt_value_str(struct sync_pt *sync_pt, char *str, return; } - snprintf(str, size, "%d", pt->thresh); + (void) snprintf(str, size, "%d", pt->thresh); } static const struct sync_timeline_ops gk20a_sync_timeline_ops = { @@ -406,7 +406,7 @@ struct sync_fence *gk20a_sync_fence_create( return NULL; va_start(args, fmt); - vsnprintf(name, sizeof(name), fmt, args); + (void) vsnprintf(name, sizeof(name), fmt, args); va_end(args); fence = sync_fence_create(name, pt); diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c index 1ffb6539d..6defd3615 100644 --- a/drivers/gpu/nvgpu/os/linux/sysfs.c +++ b/drivers/gpu/nvgpu/os/linux/sysfs.c @@ -655,7 +655,7 @@ static ssize_t aelpg_param_store(struct device *dev, /* If parameter value is 0 then reset to SW default values*/ if ((paramlist[0] | paramlist[1] | paramlist[2] | paramlist[3] | paramlist[4]) == 0x00) { - memcpy(paramlist, defaultparam, sizeof(defaultparam)); + (void) memcpy(paramlist, defaultparam, sizeof(defaultparam)); } /* If aelpg is enabled & pmu is ready then post values to diff --git a/drivers/gpu/nvgpu/os/linux/timers.c b/drivers/gpu/nvgpu/os/linux/timers.c index 018fd2d8f..8d8d28ec6 100644 --- a/drivers/gpu/nvgpu/os/linux/timers.c +++ b/drivers/gpu/nvgpu/os/linux/timers.c @@ -61,7 +61,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; @@ -89,7 +89,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 @ %pF %s", caller, buf); } @@ -113,7 +113,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 @ %pF %s", caller, buf); } diff --git a/drivers/gpu/nvgpu/os/linux/vgpu/fecs_trace_vgpu.c b/drivers/gpu/nvgpu/os/linux/vgpu/fecs_trace_vgpu.c index 02a381e18..05ec208bb 100644 --- a/drivers/gpu/nvgpu/os/linux/vgpu/fecs_trace_vgpu.c +++ b/drivers/gpu/nvgpu/os/linux/vgpu/fecs_trace_vgpu.c @@ -211,7 +211,7 @@ int vgpu_fecs_trace_set_filter(struct gk20a *g, struct tegra_vgpu_fecs_trace_filter *p = &msg.params.fecs_trace_filter; int err; - memcpy(&p->tag_bits, &filter->tag_bits, sizeof(p->tag_bits)); + (void) memcpy(&p->tag_bits, &filter->tag_bits, sizeof(p->tag_bits)); err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); err = err ? err : msg.ret; WARN_ON(err); diff --git a/include/uapi/linux/nvgpu.h b/include/uapi/linux/nvgpu.h index 8c60f374b..3ec4d66e0 100644 --- a/include/uapi/linux/nvgpu.h +++ b/include/uapi/linux/nvgpu.h @@ -2245,8 +2245,10 @@ struct nvgpu_ctxsw_ring_setup_args { ((p)->tag_bits[(n) / 64] &= ~(1 << ((n) & 63))) #define NVGPU_CTXSW_FILTER_ISSET(n, p) \ ((p)->tag_bits[(n) / 64] & (1 << ((n) & 63))) -#define NVGPU_CTXSW_FILTER_CLR_ALL(p) memset((void *)(p), 0, sizeof(*(p))) -#define NVGPU_CTXSW_FILTER_SET_ALL(p) memset((void *)(p), ~0, sizeof(*(p))) +#define NVGPU_CTXSW_FILTER_CLR_ALL(p) \ + ((void) memset((void *)(p), 0, sizeof(*(p)))) +#define NVGPU_CTXSW_FILTER_SET_ALL(p) \ + ((void) memset((void *)(p), ~0, sizeof(*(p)))) struct nvgpu_ctxsw_trace_filter { __u64 tag_bits[(NVGPU_CTXSW_FILTER_SIZE + 63) / 64];