fs: ext4: constify the buffer passed to write functions
[oweals/u-boot.git] / fs / ubifs / ubifs.c
index 8f1c9d167d741fe0a1b65475de10713785d29e1d..d5101d3c4594beec93e9caf8b9c15e8359182678 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * This file is part of UBIFS.
  *
@@ -8,8 +9,6 @@
  *
  * Authors: Artem Bityutskiy (Битюцкий Артём)
  *          Adrian Hunter
- *
- * SPDX-License-Identifier:    GPL-2.0
  */
 
 #include <common.h>
@@ -126,6 +125,7 @@ crypto_comp_decompress(const struct ubifs_info *c, struct crypto_comp *tfm,
 {
        struct ubifs_compressor *compr = ubifs_compressors[tfm->compressor];
        int err;
+       size_t tmp_len = *dlen;
 
        if (compr->compr_type == UBIFS_COMPR_NONE) {
                memcpy(dst, src, slen);
@@ -133,11 +133,12 @@ crypto_comp_decompress(const struct ubifs_info *c, struct crypto_comp *tfm,
                return 0;
        }
 
-       err = compr->decompress(src, slen, dst, (size_t *)dlen);
+       err = compr->decompress(src, slen, dst, &tmp_len);
        if (err)
                ubifs_err(c, "cannot decompress %d bytes, compressor %s, "
                          "error %d", slen, compr->name, err);
 
+       *dlen = tmp_len;
        return err;
 
        return 0;
@@ -350,7 +351,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,
@@ -432,7 +435,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) &&
@@ -462,14 +467,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;
 }