[RFC 47/47] drivers/raw: replace with TAILQ_FOREACH_SAFE

Stephen Hemminger
2025-08-18T23:37:09Z

There is now a standard macro to safely walk tailq.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/raw/ifpga/base/ifpga_enumerate.c | 6 +++---
drivers/raw/ifpga/base/opae_intel_max10.c | 8 +-------
2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/raw/ifpga/base/ifpga_enumerate.c b/drivers/raw/ifpga/base/ifpga_enumerate.c
index 61eb6601ea..ff0790038c 100644
--- a/drivers/raw/ifpga/base/ifpga_enumerate.c
+++ b/drivers/raw/ifpga/base/ifpga_enumerate.c
@@ -6,6 +6,8 @@
#include <inttypes.h>
#include <unistd.h>

+#include <bsd_queue.h>
+
#include "opae_hw_api.h"
#include "ifpga_api.h"

@@ -725,9 +727,7 @@ static void dfl_fpga_enum_info_free(struct dfl_fpga_enum_info *info)
return;

/* remove all device feature lists in the list. */
- for (dfl = TAILQ_FIRST(&info->dfls);
- dfl && (tmp = TAILQ_NEXT(dfl, node), 1);
- dfl = tmp) {
+ TAILQ_FOREACH_SAFE(dfl, &info->dfls, node, tmp) {
TAILQ_REMOVE(&info->dfls, dfl, node);
opae_free(dfl);
}
diff --git a/drivers/raw/ifpga/base/opae_intel_max10.c b/drivers/raw/ifpga/base/opae_intel_max10.c
index 58c884a8d8..84e0767b3a 100644
--- a/drivers/raw/ifpga/base/opae_intel_max10.c
+++ b/drivers/raw/ifpga/base/opae_intel_max10.c
@@ -4,14 +4,8 @@

#include "opae_intel_max10.h"
#include <libfdt.h>
-#include "opae_osdep.h"

-#ifndef TAILQ_FOREACH_SAFE
-#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = TAILQ_FIRST((head)); \
- (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
- (var) = (tvar))
-#endif
+#include "opae_osdep.h"

int max10_sys_read(struct intel_max10_device *dev,
unsigned int offset, unsigned int *val)
--
2.47.2