system: improve system name detection
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 15 Jan 2015 10:51:52 +0000 (11:51 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 15 Jan 2015 11:19:36 +0000 (12:19 +0100)
Skip entries like "Processor: 0" which are common on x86, otherwise
an "ubus call system board" will just return "system: 0".

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
system.c

index 4b3b82c55b0b71fd4b71e3b0fb90c96fe2f47f05..1e88b5dfed84c381cabb2756523ea9e3008a0d24 100644 (file)
--- a/system.c
+++ b/system.c
@@ -20,6 +20,7 @@
 #include <fcntl.h>
 #include <signal.h>
 #include <unistd.h>
+#include <stdlib.h>
 
 #include <libubox/uloop.h>
 
@@ -64,8 +65,13 @@ static int system_board(struct ubus_context *ctx, struct ubus_object *obj,
                            !strcasecmp(key, "processor") ||
                            !strcasecmp(key, "model name"))
                        {
-                               blobmsg_add_string(&b, "system", val + 2);
-                               break;
+                               strtoul(val + 2, &key, 0);
+
+                               if (key == (val + 2) || *key != 0)
+                               {
+                                       blobmsg_add_string(&b, "system", val + 2);
+                                       break;
+                               }
                        }
                }