fs: fat: get_contents() always returns -1 for errors
[oweals/u-boot.git] / fs / fs_internal.c
index 58b441030c863dda0ce0ea202b949735e088d024..d369c43ca68a3d9d088102f64feb5023597e6b10 100644 (file)
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * 2017 by Marek Behun <marek.behun@nic.cz>
  *
  * Derived from code in ext4/dev.c, which was based on reiserfs/dev.c
- *
- * SPDX-License-Identifier:    GPL-2.0
  */
 
 #include <common.h>
@@ -15,12 +14,13 @@ int fs_devread(struct blk_desc *blk, disk_partition_t *partition,
               lbaint_t sector, int byte_offset, int byte_len, char *buf)
 {
        unsigned block_len;
-       int log2blksz = blk->log2blksz;
+       int log2blksz;
        ALLOC_CACHE_ALIGN_BUFFER(char, sec_buf, (blk ? blk->blksz : 0));
        if (blk == NULL) {
                printf("** Invalid Block Device Descriptor (NULL)\n");
                return 0;
        }
+       log2blksz = blk->log2blksz;
 
        /* Check partition boundaries */
        if ((sector + ((byte_offset + byte_len - 1) >> log2blksz))