dm-log-writes: Use pointers from memcpy() calls for assignments in two functions
Subsystems (2)
PATCH 1/1 dm-log-writes: Use pointers from memcpy() calls for assignments in two functions
From: Markus Elfring <[email protected]>
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.
--- drivers/md/dm-log-writes.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/md/dm-log-writes.c +2 -4
@@ -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);
Signature · 1 line
2.51.1
Mikulas Patocka
maintainerHi
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
Quoted 43 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 31 Oct 2025 20:20:56 +0100A 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 <[email protected]>--- drivers/md/dm-log-writes.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/md/dm-log-writes.c +2
-4@@ -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);Signature · 1 line
2.51.1