Re: [PATCH 8/8] signal: simplify rt_sigaction()

From: Christoph Hellwig
Date: Tue May 29 2018 - 02:47:33 EST


> + if (act)
> if (copy_from_user(&new_sa.sa, act, sizeof(new_sa.sa)))
> return -EFAULT;

if (act && copy_from_user(&new_sa.sa, act, sizeof(new_sa.sa)))
return -EFAULT;

> ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa : NULL);
> -
> - if (!ret && oact) {
> + if (!ret && oact)
> if (copy_to_user(oact, &old_sa.sa, sizeof(old_sa.sa)))
> return -EFAULT;
> - }

ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa : NULL);
if (!ret && oact && copy_to_user(oact, &old_sa.sa, sizeof(old_sa.sa)))
return -EFAULT;

Althought I'd personaly write it as:

ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa : NULL);
if (ret)
return ret;
if (oact && copy_to_user(oact, &old_sa.sa, sizeof(old_sa.sa)))
return -EFAULT;
return 0;