mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@wdc.com>
To: linux-riscv@lists.infradead.org
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] riscv: ptrace: Improve the style in NT_PRFPREG regset handling
Date: Fri, 24 Jul 2020 00:22:30 +0100 (BST)	[thread overview]
Message-ID: <alpine.DEB.2.20.2007232216420.4462@tpp.orcam.me.uk> (raw)
In-Reply-To: <alpine.LFD.2.21.2007232038170.24175@redsun52.ssa.fujisawa.hgst.com>

Use an auxiliary variable for the size taken by floating point general 
registers in `struct __riscv_d_ext_state' to improve the readability of 
code in the `riscv_fpr_get' and `riscv_fpr_set' handlers, by avoiding 
excessive line wrapping and extending beyond 80 columns.  Also shuffle 
local variables in the reverse Christmas tree order.  No functional 
change.

Signed-off-by: Maciej W. Rozycki <macro@wdc.com>
---
 arch/riscv/kernel/ptrace.c |   24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

linux-riscv-ptrace-fpr-style.diff
Index: linux-hv/arch/riscv/kernel/ptrace.c
===================================================================
--- linux-hv.orig/arch/riscv/kernel/ptrace.c
+++ linux-hv/arch/riscv/kernel/ptrace.c
@@ -58,18 +58,16 @@ static int riscv_fpr_get(struct task_str
 			 unsigned int pos, unsigned int count,
 			 void *kbuf, void __user *ubuf)
 {
-	int ret;
+	const size_t fgr_size = offsetof(struct __riscv_d_ext_state, fcsr);
 	struct __riscv_d_ext_state *fstate = &target->thread.fstate;
+	int ret;
 
 	ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &fstate->f, 0,
-				  offsetof(struct __riscv_d_ext_state, fcsr));
+				  fgr_size);
 	if (!ret) {
 		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
-					  &fstate->fcsr,
-					  offsetof(struct __riscv_d_ext_state,
-						   fcsr),
-					  offsetof(struct __riscv_d_ext_state, fcsr) +
-					  sizeof(fstate->fcsr));
+					  &fstate->fcsr, fgr_size,
+					  fgr_size + sizeof(fstate->fcsr));
 	}
 
 	return ret;
@@ -80,18 +78,16 @@ static int riscv_fpr_set(struct task_str
 			 unsigned int pos, unsigned int count,
 			 const void *kbuf, const void __user *ubuf)
 {
-	int ret;
+	const size_t fgr_size = offsetof(struct __riscv_d_ext_state, fcsr);
 	struct __riscv_d_ext_state *fstate = &target->thread.fstate;
+	int ret;
 
 	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &fstate->f, 0,
-				 offsetof(struct __riscv_d_ext_state, fcsr));
+				 fgr_size);
 	if (!ret) {
 		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
-					 &fstate->fcsr,
-					 offsetof(struct __riscv_d_ext_state,
-						  fcsr),
-					 offsetof(struct __riscv_d_ext_state, fcsr) +
-					 sizeof(fstate->fcsr));
+					 &fstate->fcsr, fgr_size,
+					 fgr_size + sizeof(fstate->fcsr));
 	}
 
 	return ret;

  parent reply	other threads:[~2020-07-23 23:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23 23:21 [PATCH 0/2] riscv: ptrace: NT_PRFPREG regset access fixes Maciej W. Rozycki
2020-07-23 23:22 ` [PATCH 1/2] riscv: ptrace: Use the correct API for `fcsr' access Maciej W. Rozycki
2020-08-05  2:01   ` Palmer Dabbelt
2020-08-05  2:07     ` Al Viro
2020-08-05  2:20       ` Palmer Dabbelt
2020-08-05  2:48         ` Al Viro
2020-08-05  3:15           ` Palmer Dabbelt
2020-08-05 10:25           ` Maciej W. Rozycki
2020-08-05 19:48             ` Palmer Dabbelt
2020-08-19 20:00               ` Maciej W. Rozycki
2020-07-23 23:22 ` Maciej W. Rozycki [this message]
2020-08-05  2:01   ` [PATCH 2/2] riscv: ptrace: Improve the style in NT_PRFPREG regset handling Palmer Dabbelt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.2007232216420.4462@tpp.orcam.me.uk \
    --to=macro@wdc.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®