linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] cifs: Get rid of unneeded conditional in the smb2_get_aead_req()
@ 2023-01-20 12:08 Andy Shevchenko
  2023-01-20 14:21 ` Paulo Alcantara
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2023-01-20 12:08 UTC (permalink / raw)
  To: Steve French, linux-cifs, samba-technical, linux-kernel
  Cc: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Andy Shevchenko

In the smb2_get_aead_req() the skip variable is used only for
the very first iteration of the two nested loops, which means
it's basically in invariant to those loops. Hence, instead of
using conditional on each iteration, unconditionally assing
the 'skip' variable before the loops and at the end of the
inner loop.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 fs/cifs/smb2ops.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 519e6124d73d..7fcb79ce6a94 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -4280,6 +4280,12 @@ static void *smb2_get_aead_req(struct crypto_aead *tfm, const struct smb_rqst *r
 	sg_init_table(*sgl, num_sgs);
 	sg = *sgl;
 
+	/*
+	 * The first rqst has a transform header where the
+	 * first 20 bytes are not part of the encrypted blob.
+	 */
+	skip = 20;
+
 	/* Assumes the first rqst has a transform header as the first iov.
 	 * I.e.
 	 * rqst[0].rq_iov[0]  is transform header
@@ -4287,17 +4293,15 @@ static void *smb2_get_aead_req(struct crypto_aead *tfm, const struct smb_rqst *r
 	 * rqst[1+].rq_iov[0+] data to be encrypted/decrypted
 	 */
 	for (i = 0; i < num_rqst; i++) {
-		/*
-		 * The first rqst has a transform header where the
-		 * first 20 bytes are not part of the encrypted blob.
-		 */
 		for (j = 0; j < rqst[i].rq_nvec; j++) {
 			struct kvec *iov = &rqst[i].rq_iov[j];
 
-			skip = (i == 0) && (j == 0) ? 20 : 0;
 			addr = (unsigned long)iov->iov_base + skip;
 			len = iov->iov_len - skip;
 			sg = cifs_sg_set_buf(sg, (void *)addr, len);
+
+			/* See the above comment on the 'skip' assignment */
+			skip = 0;
 		}
 		for (j = 0; j < rqst[i].rq_npages; j++) {
 			rqst_page_get_length(&rqst[i], j, &len, &off);
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] cifs: Get rid of unneeded conditional in the smb2_get_aead_req()
  2023-01-20 12:08 [PATCH v1 1/1] cifs: Get rid of unneeded conditional in the smb2_get_aead_req() Andy Shevchenko
@ 2023-01-20 14:21 ` Paulo Alcantara
  2023-01-20 19:17   ` Steve French
  0 siblings, 1 reply; 3+ messages in thread
From: Paulo Alcantara @ 2023-01-20 14:21 UTC (permalink / raw)
  To: Andy Shevchenko, Steve French, linux-cifs, samba-technical, linux-kernel
  Cc: Steve French, Ronnie Sahlberg, Shyam Prasad N, Tom Talpey,
	Andy Shevchenko

Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:

> In the smb2_get_aead_req() the skip variable is used only for
> the very first iteration of the two nested loops, which means
> it's basically in invariant to those loops. Hence, instead of
> using conditional on each iteration, unconditionally assing
> the 'skip' variable before the loops and at the end of the
> inner loop.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  fs/cifs/smb2ops.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)

Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] cifs: Get rid of unneeded conditional in the smb2_get_aead_req()
  2023-01-20 14:21 ` Paulo Alcantara
@ 2023-01-20 19:17   ` Steve French
  0 siblings, 0 replies; 3+ messages in thread
From: Steve French @ 2023-01-20 19:17 UTC (permalink / raw)
  To: Paulo Alcantara
  Cc: Andy Shevchenko, Steve French, linux-cifs, samba-technical,
	linux-kernel, Steve French, Tom Talpey, Shyam Prasad N,
	Ronnie Sahlberg

merged into cifs-2.6.git for-next

On Fri, Jan 20, 2023 at 8:22 AM Paulo Alcantara via samba-technical
<samba-technical@lists.samba.org> wrote:
>
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:
>
> > In the smb2_get_aead_req() the skip variable is used only for
> > the very first iteration of the two nested loops, which means
> > it's basically in invariant to those loops. Hence, instead of
> > using conditional on each iteration, unconditionally assing
> > the 'skip' variable before the loops and at the end of the
> > inner loop.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >  fs/cifs/smb2ops.c | 14 +++++++++-----
> >  1 file changed, 9 insertions(+), 5 deletions(-)
>
> Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-20 19:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-20 12:08 [PATCH v1 1/1] cifs: Get rid of unneeded conditional in the smb2_get_aead_req() Andy Shevchenko
2023-01-20 14:21 ` Paulo Alcantara
2023-01-20 19:17   ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).