Skip to contentSkip to conversation

nvmet-auth: remove unnecessary break after goto

PATCH Applied Chaitanya Kulkarni 6 participants 9 messages May 19, 2023 – May 26, 2023

Subsystems (4)
lore
Share & tools
lore

Chaitanya Kulkarni

author maintainer
#0 lore raw

PATCH 1/2 nvmet-auth: remove unnecessary break after goto

Remove dead break after goto.

---
 drivers/nvme/target/fabrics-cmd-auth.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/nvme/target/fabrics-cmd-auth.c +0 -4
index 7970a7640e58..6c9a1ce6068d 100644
@@ -295,13 +295,11 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
 			status = 0;
 		}
 		goto done_kfree;
-		break;
 	case NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2:
 		req->sq->authenticated = true;
 		pr_debug("%s: ctrl %d qid %d ctrl authenticated\n",
 			 __func__, ctrl->cntlid, req->sq->qid);
 		goto done_kfree;
-		break;
 	case NVME_AUTH_DHCHAP_MESSAGE_FAILURE2:
 		status = nvmet_auth_failure2(d);
 		if (status) {
@@ -312,7 +310,6 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
 			status = 0;
 		}
 		goto done_kfree;
-		break;
 	default:
 		req->sq->dhchap_status =
 			NVME_AUTH_DHCHAP_FAILURE_INCORRECT_MESSAGE;
@@ -320,7 +317,6 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
 			NVME_AUTH_DHCHAP_MESSAGE_FAILURE2;
 		req->sq->authenticated = false;
 		goto done_kfree;
-		break;
 	}
 done_failure1:
 	req->sq->dhchap_status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_MESSAGE;
Signature · 1 line
2.40.0
author maintainer
#1 lore raw

PATCH 2/2 nvme-fcloop: no need to return from void function

Remove return at the end of void function.

---
 drivers/nvme/target/fcloop.c | 2 --
 1 file changed, 2 deletions(-)
drivers/nvme/target/fcloop.c +0 -2
index e940a7d37a9d..1ab3d900f2bf 100644
@@ -645,8 +645,6 @@ fcloop_fcp_recv_work(struct work_struct *work)
 	}
 	if (ret)
 		fcloop_call_host_done(fcpreq, tfcp_req, ret);
-
-	return;
 }
 
 static void
Signature · 1 line
2.40.0
Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] nvme-fcloop: no need to return from void function

In reply to Chaitanya Kulkarni

Hi CK,

Quoted 12 lines · Chaitanya Kulkarni

Remove return at the end of void function.

---
  drivers/nvme/target/fcloop.c | 2 --
  1 file changed, 2 deletions(-)
drivers/nvme/target/fcloop.c +0 -0
index e940a7d37a9d..1ab3d900f2bf 100644

drivers/nvme/target/fcloop.c fcloop_fcp_recv_work(struct work_struct *work) · line 650

Quoted 8 lines
drivers/nvme/target/fcloop.c +0 -2
@@ -645,8 +645,6 @@ fcloop_fcp_recv_work(struct work_struct *work)
  	}
  	if (ret)
  		fcloop_call_host_done(fcpreq, tfcp_req, ret);
-
-	return;
  }
 
  static void

Looks good,

BTW, are patches 1/2 and 2/2 related to each other ? Can you split between them please if not related.

Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] nvme-fcloop: no need to return from void function

In reply to Chaitanya Kulkarni
Quoted 19 lines · Chaitanya Kulkarni

Remove return at the end of void function.

---
drivers/nvme/target/fcloop.c | 2 --

1 file changed, 2 deletions(-)
drivers/nvme/target/fcloop.c +0 -2
index e940a7d37a9d..1ab3d900f2bf 100644
@@ -645,8 +645,6 @@ fcloop_fcp_recv_work(struct work_struct *work)
 	}
 	if (ret)
 		fcloop_call_host_done(fcpreq, tfcp_req, ret);
-
-	return;
 }
 
Quoted 5 lines

static void

Signature · 1 line
2.40.0
#5 lore raw
In reply to Chaitanya Kulkarni
Quoted 1 line · Chaitanya Kulkarni

Remove dead break after goto.

As a trivial cleanup this looks fine, but I really hate the structure of this code.

Can't we have local variables that we set to the dhchap_status and dhchap_step, and then after the done label just conditionally assign them if dhchap_status is non-zero? This should clean up a lot of mess, especially we'd be done to very few assignments of the step, and we could avoid jumping out of the switch entirely.

#6 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 1 line · Chaitanya Kulkarni

Remove dead break after goto.

As a trivial cleanup this looks fine, but I really hate the structure of this code.

Can't we have local variables that we set to the dhchap_status and dhchap_step, and then after the done label just conditionally assign them if dhchap_status is non-zero? This should clean up a lot of mess, especially we'd be done to very few assignments of the step, and we could avoid jumping out of the switch entirely.

similar cleanup is also needed in nvmet_execute_auth_receive(), in general nvmet_execute_auth_receive() and nvmet_execute_auth_send() has a lot of common code that can use cleanup, I've a series on the top of this one ..

but prior to that we need these two patches to make both functions close enough so I can send a final cleanup on the top of this ..

-ck

Reviewed-by on v1 1/2
#8 lore raw
In reply to Chaitanya Kulkarni
Quoted 40 lines · Chaitanya Kulkarni

Remove dead break after goto.

---
drivers/nvme/target/fabrics-cmd-auth.c | 4 ----

1 file changed, 4 deletions(-)
drivers/nvme/target/fabrics-cmd-auth.c +0 -4
index 7970a7640e58..6c9a1ce6068d 100644
@@ -295,13 +295,11 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
 			status = 0;
 		}
 		goto done_kfree;
-		break;
 	case NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2:
 		req->sq->authenticated = true;
 		pr_debug("%s: ctrl %d qid %d ctrl authenticated\n",
 			 __func__, ctrl->cntlid, req->sq->qid);
 		goto done_kfree;
-		break;
 	case NVME_AUTH_DHCHAP_MESSAGE_FAILURE2:
 		status = nvmet_auth_failure2(d);
 		if (status) {
@@ -312,7 +310,6 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
 			status = 0;
 		}
 		goto done_kfree;
-		break;
 	default:
 		req->sq->dhchap_status =
 			NVME_AUTH_DHCHAP_FAILURE_INCORRECT_MESSAGE;
@@ -320,7 +317,6 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
 			NVME_AUTH_DHCHAP_MESSAGE_FAILURE2;
 		req->sq->authenticated = false;
 		goto done_kfree;
-		break;
 	}

done_failure1:

Quoted 5 lines
	req->sq->dhchap_status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_MESSAGE;
Signature · 1 line
2.40.0