From 779cb11b5d2f476875292a3d73fe45d451dfc3d0 Mon Sep 17 00:00:00 2001 From: ajesh Date: Mon, 20 May 2019 12:54:59 +0530 Subject: [PATCH] gpu: nvgpu: fix MISRA violations in os_sched unit MISRA rule 21.1 forbids the use of #define and #undef on a reserved identifier or reserved macro name. Fix violations of rule 21.1 in os_sched unit. MISRA rule 21.2 forbids the usage of identifier names which start with an underscore. Fix violation of MISRA rule 21.2 in os_sched unit. Jira NVGPU-3299 Change-Id: Ib772f60adf5e81935f9cd2044ff8f6a402e15d82 Signed-off-by: ajesh Reviewed-on: https://git-master.nvidia.com/r/2121955 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/posix/os_sched.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/nvgpu/os/posix/os_sched.c b/drivers/gpu/nvgpu/os/posix/os_sched.c index 8d478191a..1f1b7df4d 100644 --- a/drivers/gpu/nvgpu/os/posix/os_sched.c +++ b/drivers/gpu/nvgpu/os/posix/os_sched.c @@ -10,12 +10,6 @@ #include -#if defined(__NVGPU_POSIX__) -#define __USE_GNU -#else -#define __EXT_QNX -#endif - #include #include @@ -48,6 +42,8 @@ int nvgpu_current_tid(struct gk20a *g) void nvgpu_print_current_impl(struct gk20a *g, const char *func_name, int line, void *ctx, enum nvgpu_log_type type) { +#if defined(__NVGPU_POSIX__) +#ifdef _GNU_SOURCE char current_tname[CURRENT_NAME_LEN]; /* pthread_getname_np() will return null terminated string on success */ @@ -58,4 +54,19 @@ void nvgpu_print_current_impl(struct gk20a *g, const char *func_name, int line, nvgpu_log_msg_impl(g, func_name, line, type, "(unknown process)"); } +#else + nvgpu_log_msg_impl(g, func_name, line, type, "(unknown process)"); +#endif +#else + char current_tname[CURRENT_NAME_LEN]; + + /* pthread_getname_np() will return null terminated string on success */ + if (pthread_getname_np(0, current_tname, CURRENT_NAME_LEN) == 0) { + nvgpu_log_msg_impl(g, func_name, line, type, "%s", + current_tname); + } else { + nvgpu_log_msg_impl(g, func_name, line, type, + "(unknown process)"); + } +#endif }