Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

signal/sh: Use force_sig_fault where appropriate

Filling in struct siginfo before calling force_sig_info a tedious and
error prone process, where once in a great while the wrong fields
are filled out, and siginfo has been inconsistently cleared.

Simplify this process by using the helper force_sig_fault. Which
takes as a parameters all of the information it needs, ensures
all of the fiddly bits of filling in struct siginfo are done properly
and then calls force_sig_info.

In short about a 5 line reduction in code for every time force_sig_info
is called, which makes the calling function clearer.

Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
Acked-by: Rich Felker <dalias@libc.org>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

+8 -30
+5 -14
arch/sh/kernel/traps_32.c
··· 477 477 { 478 478 unsigned long error_code = 0; 479 479 mm_segment_t oldfs; 480 - siginfo_t info; 481 480 insn_size_t instruction; 482 481 int tmp; 483 482 ··· 536 537 "access (PC %lx PR %lx)\n", current->comm, regs->pc, 537 538 regs->pr); 538 539 539 - clear_siginfo(&info); 540 - info.si_signo = SIGBUS; 541 - info.si_errno = 0; 542 - info.si_code = si_code; 543 - info.si_addr = (void __user *)address; 544 - force_sig_info(SIGBUS, &info, current); 540 + force_sig_fault(SIGBUS, si_code, (void __user *)address, current); 545 541 } else { 546 542 inc_unaligned_kernel_access(); 547 543 ··· 593 599 #ifdef CONFIG_CPU_SH2A 594 600 asmlinkage void do_divide_error(unsigned long r4) 595 601 { 596 - siginfo_t info; 602 + int code; 597 603 598 - clear_siginfo(&info); 599 604 switch (r4) { 600 605 case TRAP_DIVZERO_ERROR: 601 - info.si_code = FPE_INTDIV; 606 + code = FPE_INTDIV; 602 607 break; 603 608 case TRAP_DIVOVF_ERROR: 604 - info.si_code = FPE_INTOVF; 609 + code = FPE_INTOVF; 605 610 break; 606 611 } 607 - 608 - info.si_signo = SIGFPE; 609 - force_sig_info(info.si_signo, &info, current); 612 + force_sig_fault(SIGFPE, code, NULL, current); 610 613 } 611 614 #endif 612 615
+2 -7
arch/sh/math-emu/math.c
··· 507 507 unsigned short insn = *(unsigned short *)regs->pc; 508 508 unsigned short finsn; 509 509 unsigned long nextpc; 510 - siginfo_t info; 511 510 int nib[4] = { 512 511 (insn >> 12) & 0xf, 513 512 (insn >> 8) & 0xf, ··· 559 560 ~(FPSCR_CAUSE_MASK | FPSCR_FLAG_MASK); 560 561 task_thread_info(tsk)->status |= TS_USEDFPU; 561 562 } else { 562 - clear_siginfo(&info); 563 - info.si_signo = SIGFPE; 564 - info.si_errno = 0; 565 - info.si_code = FPE_FLTINV; 566 - info.si_addr = (void __user *)regs->pc; 567 - force_sig_info(SIGFPE, &info, tsk); 563 + force_sig_fault(SIGFPE, FPE_FLTINV, 564 + (void __user *)regs->pc, tsk); 568 565 } 569 566 570 567 regs->pc = nextpc;
+1 -9
arch/sh/mm/fault.c
··· 42 42 force_sig_info_fault(int si_signo, int si_code, unsigned long address, 43 43 struct task_struct *tsk) 44 44 { 45 - siginfo_t info; 46 - 47 - clear_siginfo(&info); 48 - info.si_signo = si_signo; 49 - info.si_errno = 0; 50 - info.si_code = si_code; 51 - info.si_addr = (void __user *)address; 52 - 53 - force_sig_info(si_signo, &info, tsk); 45 + force_sig_fault(si_signo, si_code, (void __user *)address, tsk); 54 46 } 55 47 56 48 /*