diff options
author | Burt P <pburt0@gmail.com> | 2017-07-25 14:33:49 -0500 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2017-07-25 19:02:32 -0700 |
commit | 81ae37c58709cf1396b09e5136acfc8a0c259476 (patch) | |
tree | f3e502ab9841dd0b1815ef4848d226cba87037ab /modules/devices/devicetree.c | |
parent | 8e4746423c20b525671998b1bc94b3b6d8ec78d6 (diff) |
device tree: fix crash when device tree is not found
* check if device tree was found before add_keys()
* UNKIFNULL(model) before strcmp
* make UNKIFNULL() STRIFNULL() EMPIFNULL() macros more generic
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules/devices/devicetree.c')
-rw-r--r-- | modules/devices/devicetree.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/devices/devicetree.c b/modules/devices/devicetree.c index c9b9542b..7401a7b4 100644 --- a/modules/devices/devicetree.c +++ b/modules/devices/devicetree.c @@ -25,6 +25,7 @@ #include <sys/types.h> #include <stdint.h> #include "devices.h" +#include "cpu_util.h" #include "dt_util.h" /* Hardinfo labels that have # are truncated and/or hidden. @@ -166,6 +167,8 @@ gchar *get_summary() { model = get_dt_string("/model", 0); compat = get_dt_string("/compatible", 1); + UNKIFNULL(model); + EMPIFNULL(compat); /* Expand on the DT information from known machines, like RPi. * RPi stores a revision value in /proc/cpuinfo that can be used @@ -217,6 +220,7 @@ gchar *get_summary() { /* fallback */ if (ret == NULL) { tmp[0] = get_dt_string("/serial-number", 1); + EMPIFNULL(tmp[0]); ret = g_strdup_printf( "[%s]\n" "%s=%s\n" @@ -308,7 +312,8 @@ void __scan_dtree() mi_add("Summary", summary); mi_add("Maps", maps); - add_keys("/"); + if(dtr_was_found(dt)) + add_keys("/"); messages = msg_section(0); mi_add("Messages", messages); |