NTB: amd: Silence shift wrapping warning in amd_ntb_db_vector_mask()
Subsystems (3)
PATCH 1/1 NTB: amd: Silence shift wrapping warning in amd_ntb_db_vector_mask()
This code triggers a Smatch warning:
drivers/ntb/hw/amd/ntb_hw_amd.c:336 amd_ntb_db_vector_mask()
warn: should '(1 << db_vector)' be a 64 bit type?
I don't think "db_vector" can be higher than 16 so this doesn't affect runtime, but it's nice to silence the static checker warning and we might increase "ndev->db_count" in the future.
--- drivers/ntb/hw/amd/ntb_hw_amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ntb/hw/amd/ntb_hw_amd.c +1 -1
@@ -333,7 +333,7 @@ static u64 amd_ntb_db_vector_mask(struct ntb_dev *ntb, int db_vector)if (db_vector <0 || db_vector > ndev->db_count)return 0 ; -return ntb_ndev (ntb)->db_valid_mask & (1 << db_vector); +return ntb_ndev (ntb)->db_valid_mask & (1ULL << db_vector); }static u64 amd_ntb_db_read (struct ntb_dev *ntb)
Signature · 1 line
2.17.1
S-k, Shyam-sundar
maintainerT24gMy8yNS8yMDE5IDI6NTMgUE0sIERhbiBDYXJwZW50ZXIgd3JvdGU6DQo+IFRoaXMgY29kZSB0 cmlnZ2VycyBhIFNtYXRjaCB3YXJuaW5nOg0KPg0KPiAgICAgZHJpdmVycy9udGIvaHcvYW1kL250 Yl9od19hbWQuYzozMzYgYW1kX250Yl9kYl92ZWN0b3JfbWFzaygpDQo+ICAgICB3YXJuOiBzaG91 bGQgJygxIDw8IGRiX3ZlY3RvciknIGJlIGEgNjQgYml0IHR5cGU/DQo+DQo+IEkgZG9uJ3QgdGhp bmsgImRiX3ZlY3RvciIgY2FuIGJlIGhpZ2hlciB0aGFuIDE2IHNvIHRoaXMgZG9lc24ndCBhZmZl Y3QNCj4gcnVudGltZSwgYnV0IGl0J3MgbmljZSB0byBzaWxlbmNlIHRoZSBzdGF0aWMgY2hlY2tl ciB3YXJuaW5nIGFuZCB3ZQ0KPiBtaWdodCBpbmNyZWFzZSAibmRldi0+ZGJfY291bnQiIGluIHRo ZSBmdXR1cmUuDQo+DQo+IFNpZ25lZC1vZmYtYnk6IERhbiBDYXJwZW50ZXIgPGRhbi5jYXJwZW50 ZXJAb3JhY2xlLmNvbT4NCkFja2VkLWJ5OiBTaHlhbSBTdW5kYXIgUyBLIDxTaHlhbS1zdW5kYXIu Uy1rQGFtZC5jb20+DQo
Jon Mason
maintainerQuoted 6 lines · Shyam-sundar
Quoted 5 lines · Dan Carpenter
This code triggers a Smatch warning:
drivers/ntb/hw/amd/ntb_hw_amd.c:336amd_ntb_db_vector_mask()
warn: should '(1 <<db_vector)' be a 64 bit type?
Quoted 6 lines
Quoted 5 lines
I don't think "
db_vector" can be higher than 16 so this doesn't affect runtime, but it's nice to silence the static checker warning and we might increase "ndev->db_count" in the future.Signed-off-by Dan Carpenter <[email protected]>Acked-by Shyam Sundar S K <[email protected]>
Sorry for the delay. The patch is now in the ntb branch. We've missed window for 5.2, but it will be in the 5.3 pull request.
Thanks,
Jon