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

Steve French smfrench at gmail.com
Sun Sep 1 04:43:20 UTC 2024


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 at vivo.com> wrote:
>
> Use the min() macro to simplify the function and improve
> its readability.
>
> Signed-off-by: Shen Lichuan <shenlichuan at 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



More information about the samba-technical mailing list