linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm/vmalloc: Replace the ternary conditional operator with min()
@ 2023-06-09  9:26 Lu Hongfei
  2023-06-09 10:07 ` Uladzislau Rezki
  2023-06-12  9:22 ` David Hildenbrand
  0 siblings, 2 replies; 4+ messages in thread
From: Lu Hongfei @ 2023-06-09  9:26 UTC (permalink / raw)
  To: Andrew Morton, Uladzislau Rezki, Christoph Hellwig,
	Lorenzo Stoakes, open list:VMALLOC, open list
  Cc: opensource.kernel, luhongfei

It would be better to replace the traditional ternary conditional
operator with min() in zero_iter

Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com>
---
 mm/vmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 29077d61ff81..6125ed506895
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3571,7 +3571,7 @@ static size_t zero_iter(struct iov_iter *iter, size_t count)
 	while (remains > 0) {
 		size_t num, copied;
 
-		num = remains < PAGE_SIZE ? remains : PAGE_SIZE;
+		num = min_t(size_t, remains, PAGE_SIZE);
 		copied = copy_page_to_iter_nofault(ZERO_PAGE(0), 0, num, iter);
 		remains -= copied;
 
-- 
2.39.0



^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH v2] mm/vmalloc: Replace the ternary conditional operator with min()
@ 2023-06-09  9:30 Lu Hongfei
  0 siblings, 0 replies; 4+ messages in thread
From: Lu Hongfei @ 2023-06-09  9:30 UTC (permalink / raw)
  To: Andrew Morton, Uladzislau Rezki, Christoph Hellwig,
	Lorenzo Stoakes, open list:VMALLOC, open list
  Cc: opensource.kernel, luhongfei

It would be better to replace the traditional ternary conditional
operator with min() in zero_iter

Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com>
---
 mm/vmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 29077d61ff81..6125ed506895
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3571,7 +3571,7 @@ static size_t zero_iter(struct iov_iter *iter, size_t count)
 	while (remains > 0) {
 		size_t num, copied;
 
-		num = remains < PAGE_SIZE ? remains : PAGE_SIZE;
+		num = min_t(size_t, remains, PAGE_SIZE);
 		copied = copy_page_to_iter_nofault(ZERO_PAGE(0), 0, num, iter);
 		remains -= copied;
 
-- 
2.39.0



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

end of thread, other threads:[~2023-06-12  9:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-09  9:26 [PATCH v2] mm/vmalloc: Replace the ternary conditional operator with min() Lu Hongfei
2023-06-09 10:07 ` Uladzislau Rezki
2023-06-12  9:22 ` David Hildenbrand
2023-06-09  9:30 Lu Hongfei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox