Commit 472dea1d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Tyler Hicks
Browse files

ecryptfs: combine the two ATTR_SIZE blocks in ecryptfs_setattr



Simplify the logic in ecryptfs_setattr by combining the two ATTR_SIZE
blocks.  This initializes lower_ia before the size check, which is
obviously correct as the size check doesn't look at it.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarTyler Hicks <code@tyhicks.com>
parent b19fe74e
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -934,16 +934,15 @@ static int ecryptfs_setattr(struct mnt_idmap *idmap,
	rc = setattr_prepare(&nop_mnt_idmap, dentry, ia);
	if (rc)
		goto out;
	if (ia->ia_valid & ATTR_SIZE) {
		rc = ecryptfs_inode_newsize_ok(inode, ia->ia_size);
		if (rc)
			goto out;
	}

	memcpy(&lower_ia, ia, sizeof(lower_ia));
	if (ia->ia_valid & ATTR_FILE)
		lower_ia.ia_file = ecryptfs_file_to_lower(ia->ia_file);
	if (ia->ia_valid & ATTR_SIZE) {
		rc = ecryptfs_inode_newsize_ok(inode, ia->ia_size);
		if (rc)
			goto out;

		rc = truncate_upper(dentry, ia, &lower_ia);
		if (rc < 0)
			goto out;