mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: dm-devel@lists.linux.dev, Alasdair Kergon <agk@redhat.com>,
	 Heinz Mauelshagen <heinzm@redhat.com>,
	Josef Bacik <jbacik@fb.com>,  Mike Snitzer <snitzer@kernel.org>,
	 Ross Zwisler <ross.zwisler@linux.intel.com>,
	Zach Brown <zab@zabbo.net>,  LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	 Miaoqian Lin <linmq006@gmail.com>
Subject: Re: [PATCH] dm-log-writes: Use pointers from memcpy() calls for assignments in two functions
Date: Mon, 3 Nov 2025 17:10:15 +0100 (CET)	[thread overview]
Message-ID: <85eba740-899c-6884-93b4-aa441436db97@redhat.com> (raw)
In-Reply-To: <b803a5a1-c2bf-4aad-9527-198e8a8046ca@web.de>

Hi

I think that the code is more readable as it is.

Putting two function calls on one line doesn't make it easier to read.

Mikulas


On Fri, 31 Oct 2025, Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 31 Oct 2025 20:20:56 +0100
> 
> A pointer was assigned to a variable in two function implementations.
> The same pointer was used for the destination parameter of a memcpy() call.
> This function is documented in the way that the same value is returned.
> Thus convert separate statements into a direct variable assignment for
> the return value from a memory copy action.
> 
> The source code was transformed by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/md/dm-log-writes.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c
> index 7bb7174f8f4f..b450bdadfaf2 100644
> --- a/drivers/md/dm-log-writes.c
> +++ b/drivers/md/dm-log-writes.c
> @@ -232,8 +232,7 @@ static int write_metadata(struct log_writes_c *lc, void *entry,
>  		goto error;
>  	}
>  
> -	ptr = kmap_local_page(page);
> -	memcpy(ptr, entry, entrylen);
> +	ptr = memcpy(kmap_local_page(page), entry, entrylen);
>  	if (datalen)
>  		memcpy(ptr + entrylen, data, datalen);
>  	memset(ptr + entrylen + datalen, 0,
> @@ -287,8 +286,7 @@ static int write_inline_data(struct log_writes_c *lc, void *entry,
>  				goto error_bio;
>  			}
>  
> -			ptr = kmap_local_page(page);
> -			memcpy(ptr, data, pg_datalen);
> +			ptr = memcpy(kmap_local_page(page), data, pg_datalen);
>  			if (pg_sectorlen > pg_datalen)
>  				memset(ptr + pg_datalen, 0, pg_sectorlen - pg_datalen);
>  			kunmap_local(ptr);
> -- 
> 2.51.1
> 


      reply	other threads:[~2025-11-03 16:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-31 19:33 Markus Elfring
2025-11-03 16:10 ` Mikulas Patocka [this message]

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=85eba740-899c-6884-93b4-aa441436db97@redhat.com \
    --to=mpatocka@redhat.com \
    --cc=Markus.Elfring@web.de \
    --cc=agk@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=heinzm@redhat.com \
    --cc=jbacik@fb.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linmq006@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ross.zwisler@linux.intel.com \
    --cc=snitzer@kernel.org \
    --cc=zab@zabbo.net \
    /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®