Merge branch 'next' of git://git.denx.de/u-boot-sh
[oweals/u-boot.git] / common / image-android-dt.c
index c0683ee70f36eecd46d76c4df1c8fcfa0ffcfd74..a2d52df4a2a9e23930fad1be17bee28f16c75399 100644 (file)
@@ -53,8 +53,8 @@ bool android_dt_get_fdt_by_index(ulong hdr_addr, u32 index, ulong *addr,
        entry_size = fdt32_to_cpu(hdr->dt_entry_size);
        unmap_sysmem(hdr);
 
-       if (index > entry_count) {
-               printf("Error: index > dt_entry_count (%u > %u)\n", index,
+       if (index >= entry_count) {
+               printf("Error: index >= dt_entry_count (%u >= %u)\n", index,
                       entry_count);
                return false;
        }
@@ -78,17 +78,18 @@ static void android_dt_print_fdt_info(const struct fdt_header *fdt)
 {
        u32 fdt_size;
        int root_node_off;
-       const char *compatible = NULL;
+       const char *compatible;
 
-       fdt_size = fdt_totalsize(fdt);
        root_node_off = fdt_path_offset(fdt, "/");
        if (root_node_off < 0) {
                printf("Error: Root node not found\n");
-       } else {
-               compatible = fdt_getprop(fdt, root_node_off, "compatible",
-                                        NULL);
+               return;
        }
 
+       fdt_size = fdt_totalsize(fdt);
+       compatible = fdt_getprop(fdt, root_node_off, "compatible",
+                                NULL);
+
        printf("           (FDT)size = %d\n", fdt_size);
        printf("     (FDT)compatible = %s\n",
               compatible ? compatible : "(unknown)");