]> git.sur5r.net Git - u-boot/blobdiff - fs/ubifs/ubifs.c
ubifs: avoid assert failed in ubifs.c
[u-boot] / fs / ubifs / ubifs.c
index 50355e988e9716d916579b7a763f9da8237212e7..47fa41ad1dd329fdc5ee595e0436fd192779d6c6 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * This file is part of UBIFS.
  *
@@ -6,19 +7,6 @@
  * (C) Copyright 2008-2010
  * Stefan Roese, DENX Software Engineering, sr@denx.de.
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
  * Authors: Artem Bityutskiy (Битюцкий Артём)
  *          Adrian Hunter
  */
@@ -361,7 +349,9 @@ static int ubifs_printdir(struct file *file, void *dirent)
                dbg_gen("feed '%s', ino %llu, new f_pos %#x",
                        dent->name, (unsigned long long)le64_to_cpu(dent->inum),
                        key_hash_flash(c, &dent->key));
+#ifndef __UBOOT__
                ubifs_assert(le64_to_cpu(dent->ch.sqnum) > ubifs_inode(dir)->creat_sqnum);
+#endif
 
                nm.len = le16_to_cpu(dent->nlen);
                over = filldir(c, (char *)dent->name, nm.len,
@@ -443,7 +433,9 @@ static int ubifs_finddir(struct super_block *sb, char *dirname,
                dbg_gen("feed '%s', ino %llu, new f_pos %#x",
                        dent->name, (unsigned long long)le64_to_cpu(dent->inum),
                        key_hash_flash(c, &dent->key));
+#ifndef __UBOOT__
                ubifs_assert(le64_to_cpu(dent->ch.sqnum) > ubifs_inode(dir)->creat_sqnum);
+#endif
 
                nm.len = le16_to_cpu(dent->nlen);
                if ((strncmp(dirname, (char *)dent->name, nm.len) == 0) &&
@@ -473,14 +465,10 @@ out:
                dbg_gen("cannot find next direntry, error %d", err);
 
 out_free:
-       if (file->private_data)
-               kfree(file->private_data);
-       if (file)
-               free(file);
-       if (dentry)
-               free(dentry);
-       if (dir)
-               free(dir);
+       kfree(file->private_data);
+       free(file);
+       free(dentry);
+       free(dir);
 
        return ret;
 }
@@ -572,7 +560,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)
        return 0;
 }
 
-int ubifs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info)
+int ubifs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info)
 {
        if (rbdd) {
                debug("UBIFS cannot be used with normal block devices\n");
@@ -580,7 +568,7 @@ int ubifs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info)
        }
 
        /*
-        * Should never happen since get_device_and_partition() already checks
+        * Should never happen since blk_get_device_part_str() already checks
         * this, but better safe then sorry.
         */
        if (!ubifs_is_mounted()) {
@@ -865,7 +853,7 @@ int ubifs_read(const char *filename, void *buf, loff_t offset,
        *actread = 0;
 
        if (offset & (PAGE_SIZE - 1)) {
-               printf("ubifs: Error offset must be a multple of %d\n",
+               printf("ubifs: Error offset must be a multiple of %d\n",
                       PAGE_SIZE);
                return -1;
        }
@@ -950,9 +938,9 @@ int ubifs_load(char *filename, u32 addr, u32 size)
 
        printf("Loading file '%s' to addr 0x%08x...\n", filename, addr);
 
-       err = ubifs_read(filename, (void *)addr, 0, size, &actread);
+       err = ubifs_read(filename, (void *)(uintptr_t)addr, 0, size, &actread);
        if (err == 0) {
-               setenv_hex("filesize", actread);
+               env_set_hex("filesize", actread);
                printf("Done\n");
        }