Message ID | 20221031114506.10501-1-jirislaby@kernel.org (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | RDMA/srp (gcc13): force int types for max_send_sge and can_queue | expand |
On 10/31/22 04:45, Jiri Slaby (SUSE) wrote: > Since gcc13, each member of an enum has the same type as the enum [1]. And > that is inherited from its members. Provided "SRP_TAG_TSK_MGMT = 1U << 31", > SRP_MAX_SGE and SRP_TSK_MGMT_SQ_SIZE are unsigned ints. > > This results in the following warnings: > include/linux/minmax.h:20:35: error: comparison of distinct pointer types lacks a cast > drivers/infiniband/ulp/srp/ib_srp.c:563:42: note: in expansion of macro 'min' > > include/linux/minmax.h:20:35: error: comparison of distinct pointer types lacks a cast > drivers/infiniband/ulp/srp/ib_srp.c:2369:27: note: in expansion of macro 'min' > > Force the use of min_t() instead of min() to use int for all those, as > this is what both targets > target->scsi_host->can_queue > and > init_attr->cap.max_send_sge > are. > > [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36113 > > Cc: Martin Liska <mliska@suse.cz> > Cc: Bart Van Assche <bvanassche@acm.org> > Cc: Jason Gunthorpe <jgg@ziepe.ca> > Cc: Leon Romanovsky <leon@kernel.org> > Cc: linux-rdma@vger.kernel.org > Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> > --- > drivers/infiniband/ulp/srp/ib_srp.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c > index 1075c2ac8fe2..7db487da8293 100644 > --- a/drivers/infiniband/ulp/srp/ib_srp.c > +++ b/drivers/infiniband/ulp/srp/ib_srp.c > @@ -560,7 +560,8 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch) > init_attr->cap.max_send_wr = m * target->queue_size; > init_attr->cap.max_recv_wr = target->queue_size + 1; > init_attr->cap.max_recv_sge = 1; > - init_attr->cap.max_send_sge = min(SRP_MAX_SGE, attr->max_send_sge); > + init_attr->cap.max_send_sge = min_t(int, SRP_MAX_SGE, > + attr->max_send_sge); > init_attr->sq_sig_type = IB_SIGNAL_REQ_WR; > init_attr->qp_type = IB_QPT_RC; > init_attr->send_cq = send_cq; > @@ -2366,7 +2367,7 @@ static void srp_cm_rep_handler(struct ib_cm_id *cm_id, > * bounce requests back to the SCSI mid-layer. > */ > target->scsi_host->can_queue > - = min(ch->req_lim - SRP_TSK_MGMT_SQ_SIZE, > + = min_t(int, ch->req_lim - SRP_TSK_MGMT_SQ_SIZE, > target->scsi_host->can_queue); > target->scsi_host->cmd_per_lun > = min_t(int, target->scsi_host->can_queue, I don't like this patch because it changes min() into min_t(). The former checks its arguments types while the latter uses casts and hence ignores most information that is present in the argument types. Please split the enum in ib_srp.h instead of changing min() into min_t(). Thanks, Bart.
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 1075c2ac8fe2..7db487da8293 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -560,7 +560,8 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch) init_attr->cap.max_send_wr = m * target->queue_size; init_attr->cap.max_recv_wr = target->queue_size + 1; init_attr->cap.max_recv_sge = 1; - init_attr->cap.max_send_sge = min(SRP_MAX_SGE, attr->max_send_sge); + init_attr->cap.max_send_sge = min_t(int, SRP_MAX_SGE, + attr->max_send_sge); init_attr->sq_sig_type = IB_SIGNAL_REQ_WR; init_attr->qp_type = IB_QPT_RC; init_attr->send_cq = send_cq; @@ -2366,7 +2367,7 @@ static void srp_cm_rep_handler(struct ib_cm_id *cm_id, * bounce requests back to the SCSI mid-layer. */ target->scsi_host->can_queue - = min(ch->req_lim - SRP_TSK_MGMT_SQ_SIZE, + = min_t(int, ch->req_lim - SRP_TSK_MGMT_SQ_SIZE, target->scsi_host->can_queue); target->scsi_host->cmd_per_lun = min_t(int, target->scsi_host->can_queue,
Since gcc13, each member of an enum has the same type as the enum [1]. And that is inherited from its members. Provided "SRP_TAG_TSK_MGMT = 1U << 31", SRP_MAX_SGE and SRP_TSK_MGMT_SQ_SIZE are unsigned ints. This results in the following warnings: include/linux/minmax.h:20:35: error: comparison of distinct pointer types lacks a cast drivers/infiniband/ulp/srp/ib_srp.c:563:42: note: in expansion of macro 'min' include/linux/minmax.h:20:35: error: comparison of distinct pointer types lacks a cast drivers/infiniband/ulp/srp/ib_srp.c:2369:27: note: in expansion of macro 'min' Force the use of min_t() instead of min() to use int for all those, as this is what both targets target->scsi_host->can_queue and init_attr->cap.max_send_sge are. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36113 Cc: Martin Liska <mliska@suse.cz> Cc: Bart Van Assche <bvanassche@acm.org> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: Leon Romanovsky <leon@kernel.org> Cc: linux-rdma@vger.kernel.org Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> --- drivers/infiniband/ulp/srp/ib_srp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)