Skip to contentSkip to conversation

pipeline: fix build with sanitizers or debug options

PATCH Applied David Marchand 4 participants 5 messages Mar 20 – May 18

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pipeline: fix build with sanitizers or debug options

Similar to commit 84f5ac9418ea ("pipeline: fix build with ASan").

Here we are again. Depending on options (like debug, or ASan, or UBSan), compilation can fail because of dumb construct like CHECK(0, XXX). Dumb, because such an expression macro expands as: if (0) return -XXX;

../lib/pipeline/rte_swx_pipeline.c: In function ‘instr_movh_translate’:
../lib/pipeline/rte_swx_pipeline.c:3461:1: error: control reaches end of
non-void function [-Werror=return-type]
3461 | }

      | ^

Remove any such call when at the end of functions, using a regexp:
%s/CHECK(0, \(.*\))\(;\n}\)/return -\1\2/

---
 lib/pipeline/rte_swx_pipeline.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/pipeline/rte_swx_pipeline.c +3 -3
index a9157815e4..8ceb1fe88d 100644
@@ -2524,7 +2524,7 @@ instr_table_translate(struct rte_swx_pipeline *p,
 		return 0;
 	}
 
-	CHECK(0, EINVAL);
+	return -EINVAL;
 }
 
 static inline void
@@ -3049,7 +3049,7 @@ instr_extern_translate(struct rte_swx_pipeline *p,
 		return 0;
 	}
 
-	CHECK(0, EINVAL);
+	return -EINVAL;
 }
 
 static inline void
@@ -3457,7 +3457,7 @@ instr_movh_translate(struct rte_swx_pipeline *p,
 		return 0;
 	}
 
-	CHECK(0, EINVAL);
+	return -EINVAL;
 }
 
 static inline void
Signature · 1 line
2.53.0
Acked-by on v1 1/1
#1 lore raw
Quoted 21 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Friday, March 20, 2026 1:33 PM
To: [email protected]
Cc: [email protected]; Dumitrescu, Cristian <[email protected]>
Subject: [PATCH] pipeline: fix build with sanitizers or debug options

Similar to commit 84f5ac9418ea ("pipeline: fix build with ASan").

Here we are again. Depending on options (like debug, or ASan, or UBSan), compilation can fail because of dumb construct like CHECK(0, XXX). Dumb, because such an expression macro expands as: if (0) return -XXX;

../lib/pipeline/rte_swx_pipeline.c: In function ‘instr_movh_translate’:
../lib/pipeline/rte_swx_pipeline.c:3461:1: error: control reaches end of
non-void function [-Werror=return-type]
3461 | }

      | ^
Quoted 7 lines

Remove any such call when at the end of functions, using a regexp:
%s/CHECK(0, \(.*\))\(;\n}\)/return -\1\2/

---

#2 lore raw
Quoted 15 lines
Quoted 15 lines

Similar to commit 84f5ac9418ea ("pipeline: fix build with ASan").

Here we are again. Depending on options (like debug, or ASan, or UBSan), compilation can fail because of dumb construct like CHECK(0, XXX). Dumb, because such an expression macro expands as: if (0) return -XXX;

../lib/pipeline/rte_swx_pipeline.c: In function ‘instr_movh_translate’:
../lib/pipeline/rte_swx_pipeline.c:3461:1: error: control reaches end of
non-void function [-Werror=return-type]
3461 | }

      | ^

Remove any such call when at the end of functions, using a regexp:
%s/CHECK(0, \(.*\))\(;\n}\)/return -\1\2/

Quoted 6 lines
Quoted 4 lines

---

Fixes 2f8168eac37a ("pipeline: add instruction for IPv6 address upper half")
Fixes cdaa937d3eaa ("pipeline: support selector table")
Fixes c6b752cdf215 ("pipeline: introduce SWX extern instruction")

Applied, thanks.

Should we remove the other instances of "CHECK(0," ?

#3 lore raw
In reply to David Marchand
Quoted 61 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Friday 20 March 2026 13:33
To: [email protected]
Cc: [email protected]; Cristian Dumitrescu <[email protected]>
Subject: [PATCH] pipeline: fix build with sanitizers or debug options

Similar to commit 84f5ac9418ea ("pipeline: fix build with ASan").

Here we are again. Depending on options (like debug, or ASan, or UBSan), compilation can fail because of dumb construct like CHECK(0, XXX). Dumb, because such an expression macro expands as: if (0) return -XXX;

../lib/pipeline/rte_swx_pipeline.c: In function ‘instr_movh_translate’:
../lib/pipeline/rte_swx_pipeline.c:3461:1: error: control reaches end of
non-void function [-Werror=return-type]
3461 | }

      | ^

Remove any such call when at the end of functions, using a regexp:
%s/CHECK(0, \(.*\))\(;\n}\)/return -\1\2/

---
 lib/pipeline/rte_swx_pipeline.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/pipeline/rte_swx_pipeline.c +3 -4
index a9157815e4..8ceb1fe88d 100644
@@ -2524,7 +2524,7 @@ instr_table_translate(struct rte_swx_pipeline *p,
 		return 0;
 	}
 
-	CHECK(0, EINVAL);
+	return -EINVAL;
 }
 
 static inline void
@@ -3049,7 +3049,7 @@ instr_extern_translate(struct rte_swx_pipeline *p,
 		return 0;
 	}
 
-	CHECK(0, EINVAL);
+	return -EINVAL;
 }
 
 static inline void
@@ -3457,7 +3457,7 @@ instr_movh_translate(struct rte_swx_pipeline *p,
 		return 0;
 	}
 
-	CHECK(0, EINVAL);
+	return -EINVAL;
 }
 
 static inline void
--
Quoted 1 line

2.53.0

Should we only fix those at the end of a function? Other cases may not cause issues immediately, but may still confuse compilers and readers in the future.

We are using the following hot-patch command in our CI:

```bash
sed -r 's/\bCHECK\(0, (\w+)\)/return -\1/g' -i lib/pipeline/rte_swx_pipeline.c
```

And it performs 6 replacements.

#4 lore raw

Hello,

Quoted 10 lines · Marat Khalili

Should we only fix those at the end of a function? Other cases may not cause issues immediately, but may still confuse compilers and readers in the future.

We are using the following hot-patch command in our CI:

```bash
sed -r 's/\bCHECK\(0, (\w+)\)/return -\1/g' -i lib/pipeline/rte_swx_pipeline.c
```

And it performs 6 replacements.

Yep, I did this on purpose: I fixed what was breaking compilation. The other cases are not strictly wrong.
Usage of this macro seemed intentional (for consistency?) so I did not touch the rest.

Signature · 1 line
David Marchand