Make sure the ib_wr_opcode enum is signed by adding a negative dummy element.

Different compilers may optimise the enum type in different ways. This ensures
coherency when range checking the value of enums in ibcore.

Sponsored by:	Mellanox Technologies
MFC after:	1 week
This commit is contained in:
Hans Petter Selasky 2017-11-14 14:51:37 +00:00
parent 3b8c4b3619
commit dd00abf2d7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=325807
3 changed files with 4 additions and 2 deletions

View File

@ -2497,7 +2497,7 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
}
for (nreq = 0; wr; nreq++, wr = wr->next) {
if (unlikely(wr->opcode >= ARRAY_SIZE(mlx5_ib_opcode))) {
if (unlikely(wr->opcode < 0 || wr->opcode >= ARRAY_SIZE(mlx5_ib_opcode))) {
mlx5_ib_warn(dev, "Invalid opcode 0x%x\n", wr->opcode);
err = -EINVAL;
*bad_wr = wr;

View File

@ -1765,7 +1765,7 @@ int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
qp->wrid[ind] = wr->wr_id;
if (wr->opcode >= ARRAY_SIZE(mthca_opcode)) {
if (wr->opcode < 0 || wr->opcode >= ARRAY_SIZE(mthca_opcode)) {
mthca_err(dev, "opcode invalid\n");
err = -EINVAL;
*bad_wr = wr;

View File

@ -1136,6 +1136,8 @@ enum ib_wr_opcode {
IB_WR_RESERVED8,
IB_WR_RESERVED9,
IB_WR_RESERVED10,
IB_WR_DUMMY = -1, /* force enum type signed */
};
enum ib_send_flags {