[dpdk-dev] [PATCH v6 09/11] pci: implement find_device bus operation

Stephen Hemminger stephen at networkplumber.org
Wed Jun 28 01:35:14 CEST 2017


On Tue, 27 Jun 2017 18:11:16 +0200
Gaetan Rivet <gaetan.rivet at 6wind.com> wrote:

> +	int start_found = !!(start == NULL);
> +
> +	FOREACH_DEVICE_ON_PCIBUS(dev) {
> +		if (!start_found) {
> +			if (&dev->device == start)
> +				start_found = 1;
> +			continue;
> +		}
> +		if (cmp(&dev->device, data) == 0)
> +			return &dev->device;
> +	}
> +	return NULL;
> +}
> +

Why is start_found not a boolean?

Do you really need start_found at all? Why not just reuse existing
pointer?

	FOREACH_DEVICE_ON_PCIBUS(dev) {
		if (start) {
			if (&dev->device == start)
				start = NULL
			continue;
		}
		if (cmp(&dev->device, data) == 0)
			return &dev->device;
	}
	return NULL;
}


More information about the dev mailing list