[01/10] alfred: vis: Fix parsing of iface_status

Message ID 1465152428-17299-1-git-send-email-sven@narfation.org (mailing list archive)
State Accepted, archived
Commit f34d03efa7e6a1f1f9f912a3bf15deb612434bc8
Delegated to: Simon Wunderlich
Headers

Commit Message

Sven Eckelmann June 5, 2016, 6:46 p.m. UTC
  The content of batman_adv/iface_status ends with a newline. Thus
register_interfaces has to make sure that it only compares the first line
without the \n when comparing with the status string.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 vis/vis.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Simon Wunderlich July 26, 2016, 11:55 a.m. UTC | #1
On Sunday 05 June 2016 20:46:59 Sven Eckelmann wrote:
> The content of batman_adv/iface_status ends with a newline. Thus
> register_interfaces has to make sure that it only compares the first line
> without the \n when comparing with the status string.
> 
> Signed-off-by: Sven Eckelmann <sven@narfation.org>

I've applied the whole series (78e1d64..5b67293). We can beautify the header 
stuff later.

Cheers,
     Simon
  

Patch

diff --git a/vis/vis.c b/vis/vis.c
index 4d494bc..7eab781 100644
--- a/vis/vis.c
+++ b/vis/vis.c
@@ -257,6 +257,7 @@  static int register_interfaces(struct globals *globals)
 	DIR *iface_base_dir;
 	struct dirent *iface_dir;
 	char *path_buff, *file_content;
+	char *content_newline;
 
 	path_buff = malloc(PATH_BUFF_LEN);
 	if (!path_buff) {
@@ -295,6 +296,10 @@  static int register_interfaces(struct globals *globals)
 		if (!file_content)
 			continue;
 
+		content_newline = strstr(file_content, "\n");
+		if (content_newline)
+			*content_newline = '\0';
+
 		if (strcmp(file_content, "active") == 0)
 			get_if_index(globals, iface_dir->d_name);