diff mbox series

[v1] smb: client: Use min() macro

Message ID 20240827085420.76655-1-shenlichuan@vivo.com (mailing list archive)
State New, archived
Headers show
Series [v1] smb: client: Use min() macro | expand

Commit Message

Shen Lichuan Aug. 27, 2024, 8:54 a.m. UTC
Use the min() macro to simplify the function and improve
its readability.

Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
---
 fs/smb/client/cifsacl.c   | 2 +-
 fs/smb/client/smbdirect.c | 8 +++-----
 2 files changed, 4 insertions(+), 6 deletions(-)

Comments

Steve French Sept. 1, 2024, 4:43 a.m. UTC | #1
tentatively merged to cifs-2.6.git for-next-next (target for 6.12-rc)
pending additional review and testing

On Tue, Aug 27, 2024 at 3:54 AM Shen Lichuan <shenlichuan@vivo.com> wrote:
>
> Use the min() macro to simplify the function and improve
> its readability.
>
> Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
> ---
>  fs/smb/client/cifsacl.c   | 2 +-
>  fs/smb/client/smbdirect.c | 8 +++-----
>  2 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
> index f5b6df82e857..2f9a1bb6e21c 100644
> --- a/fs/smb/client/cifsacl.c
> +++ b/fs/smb/client/cifsacl.c
> @@ -187,7 +187,7 @@ compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid)
>         /* compare all of the subauth values if any */
>         num_sat = ctsid->num_subauth;
>         num_saw = cwsid->num_subauth;
> -       num_subauth = num_sat < num_saw ? num_sat : num_saw;
> +       num_subauth = min(num_sat, num_saw);
>         if (num_subauth) {
>                 for (i = 0; i < num_subauth; ++i) {
>                         if (ctsid->sub_auth[i] != cwsid->sub_auth[i]) {
> diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c
> index 7bcc379014ca..f307122b59fe 100644
> --- a/fs/smb/client/smbdirect.c
> +++ b/fs/smb/client/smbdirect.c
> @@ -1584,11 +1584,9 @@ static struct smbd_connection *_smbd_get_connection(
>         memset(&conn_param, 0, sizeof(conn_param));
>         conn_param.initiator_depth = 0;
>
> -       conn_param.responder_resources =
> -               info->id->device->attrs.max_qp_rd_atom
> -                       < SMBD_CM_RESPONDER_RESOURCES ?
> -               info->id->device->attrs.max_qp_rd_atom :
> -               SMBD_CM_RESPONDER_RESOURCES;
> +       conn_param.responder_resources =
> +               min(info->id->device->attrs.max_qp_rd_atom,
> +                   SMBD_CM_RESPONDER_RESOURCES);
>         info->responder_resources = conn_param.responder_resources;
>         log_rdma_mr(INFO, "responder_resources=%d\n",
>                 info->responder_resources);
> --
> 2.17.1
>
>
Steve French Sept. 10, 2024, 6:30 a.m. UTC | #2
merged into cifs-2.6.git for-next

On Sat, Aug 31, 2024 at 11:43 PM Steve French <smfrench@gmail.com> wrote:
>
> tentatively merged to cifs-2.6.git for-next-next (target for 6.12-rc)
> pending additional review and testing
>
> On Tue, Aug 27, 2024 at 3:54 AM Shen Lichuan <shenlichuan@vivo.com> wrote:
> >
> > Use the min() macro to simplify the function and improve
> > its readability.
> >
> > Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
> > ---
> >  fs/smb/client/cifsacl.c   | 2 +-
> >  fs/smb/client/smbdirect.c | 8 +++-----
> >  2 files changed, 4 insertions(+), 6 deletions(-)
> >
> > diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
> > index f5b6df82e857..2f9a1bb6e21c 100644
> > --- a/fs/smb/client/cifsacl.c
> > +++ b/fs/smb/client/cifsacl.c
> > @@ -187,7 +187,7 @@ compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid)
> >         /* compare all of the subauth values if any */
> >         num_sat = ctsid->num_subauth;
> >         num_saw = cwsid->num_subauth;
> > -       num_subauth = num_sat < num_saw ? num_sat : num_saw;
> > +       num_subauth = min(num_sat, num_saw);
> >         if (num_subauth) {
> >                 for (i = 0; i < num_subauth; ++i) {
> >                         if (ctsid->sub_auth[i] != cwsid->sub_auth[i]) {
> > diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c
> > index 7bcc379014ca..f307122b59fe 100644
> > --- a/fs/smb/client/smbdirect.c
> > +++ b/fs/smb/client/smbdirect.c
> > @@ -1584,11 +1584,9 @@ static struct smbd_connection *_smbd_get_connection(
> >         memset(&conn_param, 0, sizeof(conn_param));
> >         conn_param.initiator_depth = 0;
> >
> > -       conn_param.responder_resources =
> > -               info->id->device->attrs.max_qp_rd_atom
> > -                       < SMBD_CM_RESPONDER_RESOURCES ?
> > -               info->id->device->attrs.max_qp_rd_atom :
> > -               SMBD_CM_RESPONDER_RESOURCES;
> > +       conn_param.responder_resources =
> > +               min(info->id->device->attrs.max_qp_rd_atom,
> > +                   SMBD_CM_RESPONDER_RESOURCES);
> >         info->responder_resources = conn_param.responder_resources;
> >         log_rdma_mr(INFO, "responder_resources=%d\n",
> >                 info->responder_resources);
> > --
> > 2.17.1
> >
> >
>
>
> --
> Thanks,
>
> Steve
diff mbox series

Patch

diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
index f5b6df82e857..2f9a1bb6e21c 100644
--- a/fs/smb/client/cifsacl.c
+++ b/fs/smb/client/cifsacl.c
@@ -187,7 +187,7 @@  compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid)
 	/* compare all of the subauth values if any */
 	num_sat = ctsid->num_subauth;
 	num_saw = cwsid->num_subauth;
-	num_subauth = num_sat < num_saw ? num_sat : num_saw;
+	num_subauth = min(num_sat, num_saw);
 	if (num_subauth) {
 		for (i = 0; i < num_subauth; ++i) {
 			if (ctsid->sub_auth[i] != cwsid->sub_auth[i]) {
diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c
index 7bcc379014ca..f307122b59fe 100644
--- a/fs/smb/client/smbdirect.c
+++ b/fs/smb/client/smbdirect.c
@@ -1584,11 +1584,9 @@  static struct smbd_connection *_smbd_get_connection(
 	memset(&conn_param, 0, sizeof(conn_param));
 	conn_param.initiator_depth = 0;
 
-	conn_param.responder_resources =
-		info->id->device->attrs.max_qp_rd_atom
-			< SMBD_CM_RESPONDER_RESOURCES ?
-		info->id->device->attrs.max_qp_rd_atom :
-		SMBD_CM_RESPONDER_RESOURCES;
+	conn_param.responder_resources =
+		min(info->id->device->attrs.max_qp_rd_atom,
+		    SMBD_CM_RESPONDER_RESOURCES);
 	info->responder_resources = conn_param.responder_resources;
 	log_rdma_mr(INFO, "responder_resources=%d\n",
 		info->responder_resources);