diff mbox series

[8/8] mm/migrate.c: use break instead of goto out_flush

Message ID 20200119030636.11899-9-richardw.yang@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series mm/migrate.c: cleanup on do_pages_move() | expand

Commit Message

Wei Yang Jan. 19, 2020, 3:06 a.m. UTC
Label out_flush is just outside the loop, so break the loop is enough.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 mm/migrate.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Michal Hocko Jan. 20, 2020, 10:03 a.m. UTC | #1
On Sun 19-01-20 11:06:36, Wei Yang wrote:
> Label out_flush is just outside the loop, so break the loop is enough.

I find the explicit label easier to follow than breaking out of the
loop. Especially when there is another break out of the loop with a
different label.

While the patch is correct I find the resulting code worse readable.

> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
>  mm/migrate.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 2a857fec65b6..59bfae11b9d6 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1621,22 +1621,22 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes,
>  
>  		err = -EFAULT;
>  		if (get_user(p, pages + i))
> -			goto out_flush;
> +			break;
>  		if (get_user(node, nodes + i))
> -			goto out_flush;
> +			break;
>  		addr = (unsigned long)untagged_addr(p);
>  
>  		/* Check node if it is not checked. */
>  		if (current_node == NUMA_NO_NODE || node != current_node) {
>  			err = -ENODEV;
>  			if (node < 0 || node >= MAX_NUMNODES)
> -				goto out_flush;
> +				break;
>  			if (!node_state(node, N_MEMORY))
> -				goto out_flush;
> +				break;
>  
>  			err = -EACCES;
>  			if (!node_isset(node, task_nodes))
> -				goto out_flush;
> +				break;
>  		}
>  
>  		if (current_node == NUMA_NO_NODE) {
> @@ -1676,9 +1676,9 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes,
>  		 */
>  		err = store_status(status, i, err ? : current_node, 1);
>  		if (err)
> -			goto out_flush;
> +			break;
>  	}
> -out_flush:
> +
>  	/* Make sure we do not overwrite the existing error */
>  	err1 = move_pages_and_store_status(mm, current_node, &pagelist,
>  				status, start, i - start - need_move);
> -- 
> 2.17.1
Wei Yang Jan. 21, 2020, 1:22 a.m. UTC | #2
On Mon, Jan 20, 2020 at 11:03:28AM +0100, Michal Hocko wrote:
>On Sun 19-01-20 11:06:36, Wei Yang wrote:
>> Label out_flush is just outside the loop, so break the loop is enough.
>
>I find the explicit label easier to follow than breaking out of the
>loop. Especially when there is another break out of the loop with a
>different label.
>
>While the patch is correct I find the resulting code worse readable.
>

ok, as you wish.
diff mbox series

Patch

diff --git a/mm/migrate.c b/mm/migrate.c
index 2a857fec65b6..59bfae11b9d6 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1621,22 +1621,22 @@  static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes,
 
 		err = -EFAULT;
 		if (get_user(p, pages + i))
-			goto out_flush;
+			break;
 		if (get_user(node, nodes + i))
-			goto out_flush;
+			break;
 		addr = (unsigned long)untagged_addr(p);
 
 		/* Check node if it is not checked. */
 		if (current_node == NUMA_NO_NODE || node != current_node) {
 			err = -ENODEV;
 			if (node < 0 || node >= MAX_NUMNODES)
-				goto out_flush;
+				break;
 			if (!node_state(node, N_MEMORY))
-				goto out_flush;
+				break;
 
 			err = -EACCES;
 			if (!node_isset(node, task_nodes))
-				goto out_flush;
+				break;
 		}
 
 		if (current_node == NUMA_NO_NODE) {
@@ -1676,9 +1676,9 @@  static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes,
 		 */
 		err = store_status(status, i, err ? : current_node, 1);
 		if (err)
-			goto out_flush;
+			break;
 	}
-out_flush:
+
 	/* Make sure we do not overwrite the existing error */
 	err1 = move_pages_and_store_status(mm, current_node, &pagelist,
 				status, start, i - start - need_move);