Skip to contentSkip to conversation

infiniband: cleanup a min_t() cast in set_node_desc()

PATCH New Dan Carpenter 1 participant 1 message Sep 26, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 infiniband: cleanup a min_t() cast in set_node_desc()

This is just a cleanup.

The "count" variable here is type size_t so casting it to int in min_t() truncates the higher values. Of course, this is sysfs so count is capped at a PAGE_SIZE but static checkers don't know that.

drivers/infiniband/core/sysfs.c +1 -1
index ab7fc60..feb9867 100644
@@ -641,7 +641,7 @@ static ssize_t set_node_desc(struct device *device,
 	if (!dev->modify_device)
 		return -EIO;
 
-	memcpy(desc.node_desc, buf, min_t(int, count, 64));
+	memcpy(desc.node_desc, buf, min_t(size_t, count, 64));
 	ret = ib_modify_device(dev, IB_DEVICE_MODIFY_NODE_DESC, &desc);
 	if (ret)
 		return ret;