Skip to content

Commit

Permalink
gve: Unobfuscate code by using nitems directly for loop.
Browse files Browse the repository at this point in the history
While there, also make MODULE_PNP_INFO to reflect that the device
description is provided.

Reported-by:	jrtc27
Reviewed-by:	jrtc27, imp
Differential Revision: https://reviews.freebsd.org/D40430
  • Loading branch information
delphij committed Jun 7, 2023
1 parent e82a629 commit 1177a6c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions sys/dev/gve/gve_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ static struct gve_dev {
} gve_devs[] = {
{ PCI_VENDOR_ID_GOOGLE, PCI_DEV_ID_GVNIC, "gVNIC" }
};
#define GVE_DEVS_COUNT nitems(gve_devs)

struct sx gve_global_lock;

Expand Down Expand Up @@ -717,7 +716,7 @@ gve_probe(device_t dev)
vendorid = pci_get_vendor(dev);
deviceid = pci_get_device(dev);

for (i = 0; i < GVE_DEVS_COUNT; i++) {
for (i = 0; i < nitems(gve_devs); i++) {
if (vendorid == gve_devs[i].vendor_id &&
deviceid == gve_devs[i].device_id) {
device_set_desc(dev, gve_devs[i].name);
Expand Down Expand Up @@ -869,5 +868,5 @@ DRIVER_MODULE(gve, pci, gve_driver, gve_devclass, 0, 0);
#else
DRIVER_MODULE(gve, pci, gve_driver, 0, 0);
#endif
MODULE_PNP_INFO("U16:vendor;U16:device", pci, gve, gve_devs,
GVE_DEVS_COUNT);
MODULE_PNP_INFO("U16:vendor;U16:device;D:#", pci, gve, gve_devs,
nitems(gve_devs));

0 comments on commit 1177a6c

Please sign in to comment.