* [PATCH] dm vdo indexer: Use swap() instead of open coding it
@ 2024-05-24 7:41 Jiapeng Chong
2024-05-24 13:48 ` Markus Elfring
2024-05-29 2:00 ` Matthew Sakai
0 siblings, 2 replies; 3+ messages in thread
From: Jiapeng Chong @ 2024-05-24 7:41 UTC (permalink / raw)
To: msakai; +Cc: dm-devel, linux-kernel, Jiapeng Chong, Abaci Robot
Swap is a function interface that provides exchange function. To avoid
code duplication, we can use swap function.
./drivers/md/dm-vdo/indexer/index.c:207:43-44: WARNING opportunity for swap().
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9173
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
drivers/md/dm-vdo/indexer/index.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/md/dm-vdo/indexer/index.c b/drivers/md/dm-vdo/indexer/index.c
index 1ba767144426..df4934846244 100644
--- a/drivers/md/dm-vdo/indexer/index.c
+++ b/drivers/md/dm-vdo/indexer/index.c
@@ -197,15 +197,12 @@ static int finish_previous_chapter(struct uds_index *index, u64 current_chapter_
static int swap_open_chapter(struct index_zone *zone)
{
int result;
- struct open_chapter_zone *temporary_chapter;
result = finish_previous_chapter(zone->index, zone->newest_virtual_chapter);
if (result != UDS_SUCCESS)
return result;
- temporary_chapter = zone->open_chapter;
- zone->open_chapter = zone->writing_chapter;
- zone->writing_chapter = temporary_chapter;
+ swap(zone->open_chapter, zone->writing_chapter);
return UDS_SUCCESS;
}
--
2.20.1.7.g153144c
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dm vdo indexer: Use swap() instead of open coding it
2024-05-24 7:41 [PATCH] dm vdo indexer: Use swap() instead of open coding it Jiapeng Chong
@ 2024-05-24 13:48 ` Markus Elfring
2024-05-29 2:00 ` Matthew Sakai
1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2024-05-24 13:48 UTC (permalink / raw)
To: Jiapeng Chong, abaci, dm-devel, kernel-janitors, Matthew Sakai; +Cc: LKML
> Swap is a function interface that provides exchange function. To avoid
> code duplication, we can use swap function.
Would a wording approach (like the following) be a bit nicer
for the second sentence?
Use existing swap() function rather than duplicating its implementation.
How do you think about to apply the summary phrase “Use swap() in swap_open_chapter()”?
> ./drivers/md/dm-vdo/indexer/index.c:207:43-44: WARNING opportunity for swap().
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9173
Would another indication be helpful for the involved analysis tool?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/coccinelle/misc/swap.cocci?h=v6.9
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dm vdo indexer: Use swap() instead of open coding it
2024-05-24 7:41 [PATCH] dm vdo indexer: Use swap() instead of open coding it Jiapeng Chong
2024-05-24 13:48 ` Markus Elfring
@ 2024-05-29 2:00 ` Matthew Sakai
1 sibling, 0 replies; 3+ messages in thread
From: Matthew Sakai @ 2024-05-29 2:00 UTC (permalink / raw)
To: Jiapeng Chong; +Cc: dm-devel, linux-kernel, Abaci Robot, Mike Snitzer
On 5/24/24 03:41, Jiapeng Chong wrote:
> Swap is a function interface that provides exchange function. To avoid
> code duplication, we can use swap function.
>
> ./drivers/md/dm-vdo/indexer/index.c:207:43-44: WARNING opportunity for swap().
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9173
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Reviewed-by: Matthew Sakai <msakai@redhat.com>
Mike, can you make sure this gets applied with the rest of the pending
dm patches?
> ---
> drivers/md/dm-vdo/indexer/index.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/md/dm-vdo/indexer/index.c b/drivers/md/dm-vdo/indexer/index.c
> index 1ba767144426..df4934846244 100644
> --- a/drivers/md/dm-vdo/indexer/index.c
> +++ b/drivers/md/dm-vdo/indexer/index.c
> @@ -197,15 +197,12 @@ static int finish_previous_chapter(struct uds_index *index, u64 current_chapter_
> static int swap_open_chapter(struct index_zone *zone)
> {
> int result;
> - struct open_chapter_zone *temporary_chapter;
>
> result = finish_previous_chapter(zone->index, zone->newest_virtual_chapter);
> if (result != UDS_SUCCESS)
> return result;
>
> - temporary_chapter = zone->open_chapter;
> - zone->open_chapter = zone->writing_chapter;
> - zone->writing_chapter = temporary_chapter;
> + swap(zone->open_chapter, zone->writing_chapter);
> return UDS_SUCCESS;
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-29 2:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-24 7:41 [PATCH] dm vdo indexer: Use swap() instead of open coding it Jiapeng Chong
2024-05-24 13:48 ` Markus Elfring
2024-05-29 2:00 ` Matthew Sakai
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®