---
 toys/net/rfkill.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
From 9d453a014aaf52d38aaf859c6c31c531dddd412f Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Tue, 29 Oct 2019 22:26:48 -0700
Subject: [PATCH] rfkill: remove get_line().

---
 toys/net/rfkill.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/toys/net/rfkill.c b/toys/net/rfkill.c
index 26879e92..47e7ab28 100644
--- a/toys/net/rfkill.c
+++ b/toys/net/rfkill.c
@@ -73,23 +73,26 @@ void rfkill_main(void)
   } else {
     // show list.
     while (sizeof(rfevent) == readall(fd, &rfevent, sizeof(rfevent))) {
-      char *line, *name = 0, *type = 0;
+      char *line = 0, *name = 0, *type = 0;
+      FILE *fp;
+      size_t l = 0;
+      ssize_t len;
 
       // filter list items
       if ((tid > 0 && tid != rfevent.type) || (idx != -1 && idx != rfevent.idx))
         continue;
 
       sprintf(toybuf, "/sys/class/rfkill/rfkill%u/uevent", rfevent.idx);
-      tvar = xopenro(toybuf);
-      while ((line = get_line(tvar))) {
+      fp = xfopen(toybuf, "r");
+      while ((len = getline(&line, &l, fp)) > 0) {
         char *s = line;
 
+        line[len-1] = 0;
         if (strstart(&s, "RFKILL_NAME=")) name = xstrdup(s);
         else if (strstart(&s, "RFKILL_TYPE=")) type = xstrdup(s);
-
-        free(line);
       }
-      xclose(tvar);
+      free(line);
+      fclose(fp);
 
       xprintf("%u: %s: %s\n", rfevent.idx, name, type);
       xprintf("\tSoft blocked: %s\n", rfevent.soft ? "yes" : "no");
-- 
2.24.0.rc1.363.gb1bccd3e3d-goog

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to