dtoverlay: Make empty alias a valid string
authorPhil Elwell <phil@raspberrypi.org>
Wed, 15 Mar 2017 12:34:00 +0000 (12:34 +0000)
committerpopcornmix <popcornmix@gmail.com>
Tue, 21 Mar 2017 20:55:48 +0000 (20:55 +0000)
dtoverlay_get_alias returns a string with no length indication. In
the case that the alias is present but empty, return an empty string.

helpers/dtoverlay/dtoverlay.c

index 22c30947588c71314670571e34079d2c5a0c0221..bf57cdf1b51ade62cd0971569acf58fbf47f12a1 100644 (file)
@@ -1635,10 +1635,15 @@ int dtoverlay_set_property(DTBLOB_T *dtb, int pos,
 const char *dtoverlay_get_alias(DTBLOB_T *dtb, const char *alias_name)
 {
    int node_off;
+   int prop_len;
+   const char *alias;
 
    node_off = fdt_path_offset(dtb->fdt, "/aliases");
 
-   return fdt_getprop(dtb->fdt, node_off, alias_name, NULL);
+   alias = fdt_getprop(dtb->fdt, node_off, alias_name, &prop_len);
+   if (alias && !prop_len)
+       alias = "";
+   return alias;
 }
 
 int dtoverlay_set_alias(DTBLOB_T *dtb, const char *alias_name, const char *value)