Thread (15 messages) flat view 15 messages, 4 authors, 2022-09-19

Re: [PATCH net-next v13 2/6] net: dsa: Add convenience functions for frame handling

From: Vladimir Oltean <olteanv@gmail.com>
Date: 2022-09-16 13:48:07

On Fri, Sep 16, 2022 at 08:06:38AM +0200, Christian Marangi wrote:
quoted
+static inline void dsa_switch_inband_complete(struct dsa_switch *ds, struct completion *completion)
+{
+	/* Custom completion? */
+	complete(completion ?: &ds->inband_done);
Missing handling for custom completion!

Should be

complete(completion ? completion : &ds->inband_done);
!!!!

https://en.wikipedia.org/wiki/%3F:#C
https://en.wikipedia.org/wiki/Elvis_operator

| A GNU extension to C allows omitting the second operand, and using
| implicitly the first operand as the second also:
|
| a == x ? : y;
|
| The expression is equivalent to
|
| a == x ? (a == x) : y;
|
| except that if x is an expression, it is evaluated only once. The
| difference is significant if evaluating the expression has side effects.
| This shorthand form is sometimes known as the Elvis operator in other
| languages.

cat ternary.c
#include <stdio.h>

int main(void)
{
	printf("%d\n", 3 ?: 4);
	return 0;
}

make ternary
./ternary
3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help