aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-networkd.c-define-scope-specific-to-case-statement.patch
blob: 9f01108a208183df29e3c0a529e2a0407a04196e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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