| From 6e3dd61bf90a7ca8c36c5b95943cbff7c1ad3c2d Mon Sep 17 00:00:00 2001 |
| From: Yi Zhao <yi.zhao@windriver.com> |
| Date: Wed, 6 Mar 2024 16:12:31 +0800 |
| Subject: [PATCH] networkd.c: define scope specific to case statement |
| |
| Per [1], define a scope specific to case statement to fix build with |
| clang. |
| |
| Fixes: |
| ../git/src/networkd.c:544:13: error: expected expression |
| 544 | gchar* first = g_strcmp0(def->id, def->veth_peer_link->id) < 0 ? def->id : def->veth_peer_link->id; |
| | ^ |
| ../git/src/networkd.c:545:17: error: use of undeclared identifier 'first' |
| 545 | if (first != def->id) { |
| | ^ |
| |
| [1] https://stackoverflow.com/questions/92396/why-cant-variables-be-declared-in-a-switch-statement |
| |
| Upstream-Status: Pending |
| |
| Signed-off-by: Yi Zhao <yi.zhao@windriver.com> |
| --- |
| src/networkd.c | 2 ++ |
| 1 file changed, 2 insertions(+) |
| |
| diff --git a/src/networkd.c b/src/networkd.c |
| index 25121c48..5eb9c0fe 100644 |
| --- a/src/networkd.c |
| +++ b/src/networkd.c |
| @@ -541,12 +541,14 @@ write_netdev_file(const NetplanNetDefinition* def, const char* rootdir, const ch |
| * and, if the selected name is the name of the netdef being written, we generate |
| * the .netdev file. Otherwise we skip the netdef. |
| */ |
| + { |
| gchar* first = g_strcmp0(def->id, def->veth_peer_link->id) < 0 ? def->id : def->veth_peer_link->id; |
| if (first != def->id) { |
| g_string_free(s, TRUE); |
| return; |
| } |
| g_string_append_printf(s, "Kind=veth\n\n[Peer]\nName=%s\n", def->veth_peer_link->id); |
| + } |
| break; |
| |
| case NETPLAN_DEF_TYPE_TUNNEL: |
| -- |
| 2.25.1 |
| |