Commit 99cc16a2 authored by Zheng Yejian's avatar Zheng Yejian Committed by Zheng Zengkai
Browse files

livepatch: Fix several code style issues

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I60MKD


CVE: NA

--------------------------------

Fix several code style issues:
- Do not use magic numbers.The number is 10
- Do not use parentheses when printing numbers.
- Braces {} are not necessary for single statement blocks
- Do not add blank lines on the start of a code block defined by braces.

Signed-off-by: default avatarZheng Yejian <zhengyejian1@huawei.com>
Reviewed-by: default avatarKuohai Xu <xukuohai@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 2c3c0b3a
Loading
Loading
Loading
Loading
+1 −10
Original line number Diff line number Diff line
@@ -277,16 +277,7 @@ static int do_check_calltrace(struct walk_stackframe_args *args,
			frame.sp = current_stack_pointer;
			frame.lr = (unsigned long)__builtin_return_address(0);
			frame.pc = (unsigned long)do_check_calltrace;
		} else if (strncmp(t->comm, "migration/", 10) == 0) {
			/*
			 * current on other CPU
			 * we call this in stop_machine, so the current
			 * of each CPUs is mirgation, just compare the
			 * task_comm here, because we can't get the
			 * cpu_curr(task_cpu(t))). This assumes that no
			 * other thread will pretend to be a stopper via
			 * task_comm.
			 */
		} else if (klp_is_migration_thread(t->comm)) {
			continue;
		} else {
			frame.fp = thread_saved_fp(t);
+3 −12
Original line number Diff line number Diff line
@@ -274,16 +274,7 @@ static int do_check_calltrace(struct walk_stackframe_args *args,
			/* current on this CPU */
			frame.fp = (unsigned long)__builtin_frame_address(0);
			frame.pc = (unsigned long)do_check_calltrace;
		} else if (strncmp(t->comm, "migration/", 10) == 0) {
			/*
			 * current on other CPU
			 * we call this in stop_machine, so the current
			 * of each CPUs is mirgation, just compare the
			 * task_comm here, because we can't get the
			 * cpu_curr(task_cpu(t))). This assumes that no
			 * other thread will pretend to be a stopper via
			 * task_comm.
			 */
		} else if (klp_is_migration_thread(t->comm)) {
			continue;
		} else {
			frame.fp = thread_saved_fp(t);
@@ -425,7 +416,7 @@ static int do_patch(unsigned long pc, unsigned long new_addr)
		for (i = 0; i < LJMP_INSN_SIZE; i++) {
			ret = aarch64_insn_patch_text_nosync(((u32 *)pc) + i, insns[i]);
			if (ret) {
				pr_err("patch instruction(%d) large range failed, ret=%d\n",
				pr_err("patch instruction %d large range failed, ret=%d\n",
				       i, ret);
				return -EPERM;
			}
@@ -471,7 +462,7 @@ void arch_klp_unpatch_func(struct klp_func *func)
			ret = aarch64_insn_patch_text_nosync(((u32 *)pc) + i,
							     func_node->arch_data.old_insns[i]);
			if (ret) {
				pr_err("restore instruction(%d) failed, ret=%d\n", i, ret);
				pr_err("restore instruction %d failed, ret=%d\n", i, ret);
				return;
			}
		}
+3 −12
Original line number Diff line number Diff line
@@ -293,16 +293,7 @@ static int do_check_calltrace(struct walk_stackframe_args *args,
			 * backtrace is so similar
			 */
			stack = (unsigned long *)current_stack_pointer;
		} else if (strncmp(t->comm, "migration/", 10) == 0) {
			/*
			 * current on other CPU
			 * we call this in stop_machine, so the current
			 * of each CPUs is mirgation, just compare the
			 * task_comm here, because we can't get the
			 * cpu_curr(task_cpu(t))). This assumes that no
			 * other thread will pretend to be a stopper via
			 * task_comm.
			 */
		} else if (klp_is_migration_thread(t->comm)) {
			continue;
		} else {
			/*
@@ -440,7 +431,7 @@ static int do_patch(unsigned long pc, unsigned long new_addr)
			ret = patch_instruction((struct ppc_inst *)(((u32 *)pc) + i),
						ppc_inst(insns[i]));
			if (ret) {
				pr_err("patch instruction(%d) large range failed, ret=%d\n",
				pr_err("patch instruction %d large range failed, ret=%d\n",
				       i, ret);
				return -EPERM;
			}
@@ -478,7 +469,7 @@ void arch_klp_unpatch_func(struct klp_func *func)
			ret = patch_instruction((struct ppc_inst *)(((u32 *)pc) + i),
						ppc_inst(func_node->arch_data.old_insns[i]));
			if (ret) {
				pr_err("restore instruction(%d) failed, ret=%d\n", i, ret);
				pr_err("restore instruction %d failed, ret=%d\n", i, ret);
				return;
			}
		}
+2 −11
Original line number Diff line number Diff line
@@ -314,16 +314,7 @@ static int do_check_calltrace(struct walk_stackframe_args *args,
			 * so similar
			 */
			stack = (unsigned long *)current_stack_pointer;
		} else if (strncmp(t->comm, "migration/", 10) == 0) {
			/*
			 * current on other CPU
			 * we call this in stop_machine, so the current
			 * of each CPUs is mirgation, just compare the
			 * task_comm here, because we can't get the
			 * cpu_curr(task_cpu(t))). This assumes that no
			 * other thread will pretend to be a stopper via
			 * task_comm.
			 */
		} else if (klp_is_migration_thread(t->comm)) {
			continue;
		} else {
			/*
@@ -476,7 +467,7 @@ void arch_klp_unpatch_func(struct klp_func *func)
			ret = patch_instruction((struct ppc_inst *)((u32 *)pc + i),
						ppc_inst(func_node->arch_data.old_insns[i]));
			if (ret) {
				pr_err("restore instruction(%d) failed, ret=%d\n", i, ret);
				pr_err("restore instruction %d failed, ret=%d\n", i, ret);
				break;
			}
		}
+1 −1
Original line number Diff line number Diff line
@@ -315,7 +315,7 @@ static int do_check_calltrace(bool (*fn)(void *, int *, unsigned long), void *da
#endif

	for_each_process_thread(g, t) {
		if (!strncmp(t->comm, "migration/", 10))
		if (klp_is_migration_thread(t->comm))
			continue;

#ifdef CONFIG_ARCH_STACKWALK
Loading