1 From: Sven Eckelmann <sven@narfation.org>
2 Date: Mon, 15 Feb 2021 20:34:54 +0100
3 Subject: alfred: Save global mode flags in bitfield
5 The verbose and ipv4mode entries in the globals structure is only used to
6 save a boolean information. So just use a bit in a bitfield to store this
7 information instead of a full int.
9 Signed-off-by: Sven Eckelmann <sven@narfation.org>
10 Forwarded: https://patchwork.open-mesh.org/project/b.a.t.m.a.n./patch/20210215200126.140253-3-sven@narfation.org/
12 diff --git a/alfred.h b/alfred.h
13 index 7d6b0b35b5c8b8c3b087589880c390eb035584be..c64ff17ab9be8a16b3e1c86070b93235c226a004 100644
16 @@ -115,8 +115,8 @@ struct globals {
17 enum clientmode clientmode;
19 int clientmode_version;
26 const char *unix_path;
27 diff --git a/main.c b/main.c
28 index 7b866cc4275797beb7f614dd1a19ea0099e1281b..f25b6cc11975b8523abf6c59b77a86e94684b03b 100644
32 #include <arpa/inet.h>
39 @@ -181,8 +182,8 @@ static struct globals *alfred_init(int argc, char *argv[])
40 globals->clientmode_version = 0;
41 globals->mesh_iface = "bat0";
42 globals->unix_path = ALFRED_SOCK_PATH_DEFAULT;
43 - globals->verbose = 0;
44 - globals->ipv4mode = 0;
45 + globals->verbose = false;
46 + globals->ipv4mode = false;
47 globals->update_command = NULL;
48 globals->sync_period.tv_sec = ALFRED_INTERVAL;
49 globals->sync_period.tv_nsec = 0;
50 @@ -252,7 +253,7 @@ static struct globals *alfred_init(int argc, char *argv[])
51 globals->unix_path = optarg;
55 + globals->verbose = true;
58 globals->update_command = optarg;
59 @@ -268,7 +269,7 @@ static struct globals *alfred_init(int argc, char *argv[])
60 printf(" ** Setting sync interval to: %.9f seconds (%ld.%09ld)\n", sync_period, globals->sync_period.tv_sec, globals->sync_period.tv_nsec);
63 - globals->ipv4mode = 1;
64 + globals->ipv4mode = true;
65 inet_pton(AF_INET, optarg, &alfred_mcast.ipv4);
66 printf(" ** IPv4 Multicast Mode: %x\n", alfred_mcast.ipv4.s_addr);