git: 06d98c3bf47e - stable/13 - gve: Unobfuscate code by using nitems directly for loop.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 18 Aug 2023 23:18:47 UTC
The branch stable/13 has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=06d98c3bf47ec79f2e0c2942088eade399ea78b5 commit 06d98c3bf47ec79f2e0c2942088eade399ea78b5 Author: Xin LI <delphij@FreeBSD.org> AuthorDate: 2023-06-07 04:14:30 +0000 Commit: Xin LI <delphij@FreeBSD.org> CommitDate: 2023-08-18 23:18:15 +0000 gve: Unobfuscate code by using nitems directly for loop. 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 (cherry picked from commit 1177a6c8dcfd6625c541d6ffc3c6915b8b6354f7) --- sys/dev/gve/gve_main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/dev/gve/gve_main.c b/sys/dev/gve/gve_main.c index 383fd326d33a..c3ee6d5c3433 100644 --- a/sys/dev/gve/gve_main.c +++ b/sys/dev/gve/gve_main.c @@ -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; @@ -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); @@ -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));