Remove assignments in if-statements.
Signed-off-by: Michael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm_segment_t oldfs;
int rc;
- if ((rc = ecryptfs_open_lower_file(&lower_file, dentry, mnt,
- O_RDONLY))) {
+ rc = ecryptfs_open_lower_file(&lower_file, dentry, mnt, O_RDONLY);
+ if (rc) {
printk(KERN_ERR
"Error opening lower_file to read header region\n");
goto out;
rc = lower_file->f_op->read(lower_file, (char __user *)data,
ECRYPTFS_DEFAULT_EXTENT_SIZE, &lower_file->f_pos);
set_fs(oldfs);
- if ((rc = ecryptfs_close_lower_file(lower_file))) {
+ rc = ecryptfs_close_lower_file(lower_file);
+ if (rc) {
printk(KERN_ERR "Error closing lower_file\n");
goto out;
}
strncpy(tmp_tfm->cipher_name, cipher_name,
ECRYPTFS_MAX_CIPHER_NAME_SIZE);
tmp_tfm->key_size = key_size;
- if ((rc = ecryptfs_process_key_cipher(&tmp_tfm->key_tfm,
- tmp_tfm->cipher_name,
- &tmp_tfm->key_size))) {
+ rc = ecryptfs_process_key_cipher(&tmp_tfm->key_tfm,
+ tmp_tfm->cipher_name,
+ &tmp_tfm->key_size);
+ if (rc) {
printk(KERN_ERR "Error attempting to initialize key TFM "
"cipher with name = [%s]; rc = [%d]\n",
tmp_tfm->cipher_name, rc);
}
}
mutex_unlock(&key_tfm_list_mutex);
- if ((rc = ecryptfs_add_new_key_tfm(&key_tfm, cipher_name, 0))) {
+ rc = ecryptfs_add_new_key_tfm(&key_tfm, cipher_name, 0);
+ if (rc) {
printk(KERN_ERR "Error adding new key_tfm to list; rc = [%d]\n",
rc);
goto out;
lower_flags &= ~O_APPEND;
lower_mnt = ecryptfs_dentry_to_lower_mnt(ecryptfs_dentry);
/* Corresponding fput() in ecryptfs_release() */
- if ((rc = ecryptfs_open_lower_file(&lower_file, lower_dentry, lower_mnt,
- lower_flags))) {
+ rc = ecryptfs_open_lower_file(&lower_file, lower_dentry, lower_mnt,
+ lower_flags);
+ if (rc) {
ecryptfs_printk(KERN_ERR, "Error opening lower file\n");
goto out_puts;
}
struct inode *lower_inode = ecryptfs_inode_to_lower(inode);
int rc;
- if ((rc = ecryptfs_close_lower_file(lower_file))) {
+ rc = ecryptfs_close_lower_file(lower_file);
+ if (rc) {
printk(KERN_ERR "Error closing lower_file\n");
goto out;
}
lower_flags = ((O_CREAT | O_TRUNC) & O_ACCMODE) | O_RDWR;
lower_mnt = ecryptfs_dentry_to_lower_mnt(ecryptfs_dentry);
/* Corresponding fput() at end of this function */
- if ((rc = ecryptfs_open_lower_file(&lower_file, lower_dentry, lower_mnt,
- lower_flags))) {
+ rc = ecryptfs_open_lower_file(&lower_file, lower_dentry, lower_mnt,
+ lower_flags);
+ if (rc) {
ecryptfs_printk(KERN_ERR,
"Error opening dentry; rc = [%i]\n", rc);
goto out;
}
rc = grow_file(ecryptfs_dentry, lower_file, inode, lower_inode);
out_fput:
- if ((rc = ecryptfs_close_lower_file(lower_file)))
+ rc = ecryptfs_close_lower_file(lower_file);
+ if (rc)
printk(KERN_ERR "Error closing lower_file\n");
out:
return rc;
lower_dentry = ecryptfs_dentry_to_lower(dentry);
/* This dget & mntget is released through fput at out_fput: */
lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry);
- if ((rc = ecryptfs_open_lower_file(&lower_file, lower_dentry, lower_mnt,
- O_RDWR))) {
+ rc = ecryptfs_open_lower_file(&lower_file, lower_dentry, lower_mnt,
+ O_RDWR);
+ if (rc) {
ecryptfs_printk(KERN_ERR,
"Error opening dentry; rc = [%i]\n", rc);
goto out_free;
end_pos_in_page = ((new_length - 1) & ~PAGE_CACHE_MASK);
}
if (end_pos_in_page != (PAGE_CACHE_SIZE - 1)) {
- if ((rc = ecryptfs_write_zeros(&fake_ecryptfs_file,
- index,
- (end_pos_in_page + 1),
- ((PAGE_CACHE_SIZE - 1)
- - end_pos_in_page)))) {
+ rc = ecryptfs_write_zeros(&fake_ecryptfs_file,
+ index,
+ (end_pos_in_page + 1),
+ ((PAGE_CACHE_SIZE - 1)
+ - end_pos_in_page));
+ if (rc) {
printk(KERN_ERR "Error attempting to zero out "
"the remainder of the end page on "
"reducing truncate; rc = [%d]\n", rc);
= CURRENT_TIME;
mark_inode_dirty_sync(inode);
out_fput:
- if ((rc = ecryptfs_close_lower_file(lower_file)))
+ rc = ecryptfs_close_lower_file(lower_file);
+ if (rc)
printk(KERN_ERR "Error closing lower_file\n");
out_free:
if (ecryptfs_file_to_private(&fake_ecryptfs_file))
lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry);
lower_flags = O_RDONLY;
- if ((rc = ecryptfs_open_lower_file(&lower_file, lower_dentry,
- lower_mnt, lower_flags))) {
+ rc = ecryptfs_open_lower_file(&lower_file, lower_dentry,
+ lower_mnt, lower_flags);
+ if (rc) {
printk(KERN_ERR
"Error opening lower file; rc = [%d]\n", rc);
mutex_unlock(&crypt_stat->cs_mutex);
}
mount_crypt_stat = &ecryptfs_superblock_to_private(
dentry->d_sb)->mount_crypt_stat;
- if ((rc = ecryptfs_read_metadata(dentry, lower_file))) {
+ rc = ecryptfs_read_metadata(dentry, lower_file);
+ if (rc) {
if (!(mount_crypt_stat->flags
& ECRYPTFS_PLAINTEXT_PASSTHROUGH_ENABLED)) {
rc = -EIO;
size_t netlink_message_length;
int rc;
- if ((rc = ecryptfs_get_auth_tok_sig(&auth_tok_sig, auth_tok))) {
+ rc = ecryptfs_get_auth_tok_sig(&auth_tok_sig, auth_tok);
+ if (rc) {
printk(KERN_ERR "Unrecognized auth tok type: [%d]\n",
auth_tok->token_type);
goto out;
goto out;
}
(*new_auth_tok) = &auth_tok_list_item->auth_tok;
- if ((rc = parse_packet_length(&data[(*packet_size)], &body_size,
- &length_size))) {
+ rc = parse_packet_length(&data[(*packet_size)], &body_size,
+ &length_size);
+ if (rc) {
printk(KERN_WARNING "Error parsing packet length; "
"rc = [%d]\n", rc);
goto out_free;
goto out;
}
(*new_auth_tok) = &auth_tok_list_item->auth_tok;
- if ((rc = parse_packet_length(&data[(*packet_size)], &body_size,
- &length_size))) {
+ rc = parse_packet_length(&data[(*packet_size)], &body_size,
+ &length_size);
+ if (rc) {
printk(KERN_WARNING "Error parsing packet length; rc = [%d]\n",
rc);
goto out_free;
rc = -EINVAL;
goto out;
}
- if ((rc = parse_packet_length(&data[(*packet_size)], &body_size,
- &length_size))) {
+ rc = parse_packet_length(&data[(*packet_size)], &body_size,
+ &length_size);
+ if (rc) {
printk(KERN_WARNING "Invalid tag 11 packet format\n");
goto out;
}
crypt_stat->cipher, rc);
goto out;
}
- if ((rc = virt_to_scatterlist(auth_tok->session_key.encrypted_key,
- auth_tok->session_key.encrypted_key_size,
- &src_sg, 1)) != 1) {
+ rc = virt_to_scatterlist(auth_tok->session_key.encrypted_key,
+ auth_tok->session_key.encrypted_key_size,
+ &src_sg, 1);
+ if (rc != 1) {
printk(KERN_ERR "Internal error whilst attempting to convert "
"auth_tok->session_key.encrypted_key to scatterlist; "
"expected rc = 1; got rc = [%d]. "
}
auth_tok->session_key.decrypted_key_size =
auth_tok->session_key.encrypted_key_size;
- if ((rc = virt_to_scatterlist(auth_tok->session_key.decrypted_key,
- auth_tok->session_key.decrypted_key_size,
- &dst_sg, 1)) != 1) {
+ rc = virt_to_scatterlist(auth_tok->session_key.decrypted_key,
+ auth_tok->session_key.decrypted_key_size,
+ &dst_sg, 1);
+ if (rc != 1) {
printk(KERN_ERR "Internal error whilst attempting to convert "
"auth_tok->session_key.decrypted_key to scatterlist; "
"expected rc = 1; got rc = [%d]\n", rc);
"Considering cadidate auth tok:\n");
ecryptfs_dump_auth_tok(candidate_auth_tok);
}
- if ((rc = ecryptfs_get_auth_tok_sig(&candidate_auth_tok_sig,
- candidate_auth_tok))) {
+ rc = ecryptfs_get_auth_tok_sig(&candidate_auth_tok_sig,
+ candidate_auth_tok);
+ if (rc) {
printk(KERN_ERR
"Unrecognized candidate auth tok type: [%d]\n",
candidate_auth_tok->token_type);
rc = -EINVAL;
goto out_wipe_list;
}
- if ((rc = ecryptfs_find_auth_tok_for_sig(
- &matching_auth_tok, crypt_stat,
- candidate_auth_tok_sig)))
- rc = 0;
+ ecryptfs_find_auth_tok_for_sig(&matching_auth_tok, crypt_stat,
+ candidate_auth_tok_sig);
if (matching_auth_tok) {
found_auth_tok = 1;
goto found_matching_auth_tok;
ecryptfs_printk(KERN_DEBUG, "Session key encryption key:\n");
ecryptfs_dump_hex(session_key_encryption_key, 16);
}
- if ((rc = virt_to_scatterlist(crypt_stat->key,
- key_rec->enc_key_size, &src_sg, 1))
- != 1) {
+ rc = virt_to_scatterlist(crypt_stat->key, key_rec->enc_key_size,
+ &src_sg, 1);
+ if (rc != 1) {
ecryptfs_printk(KERN_ERR, "Error generating scatterlist "
"for crypt_stat session key; expected rc = 1; "
"got rc = [%d]. key_rec->enc_key_size = [%d]\n",
rc = -ENOMEM;
goto out;
}
- if ((rc = virt_to_scatterlist(key_rec->enc_key,
- key_rec->enc_key_size, &dst_sg, 1))
- != 1) {
+ rc = virt_to_scatterlist(key_rec->enc_key, key_rec->enc_key_size,
+ &dst_sg, 1);
+ if (rc != 1) {
ecryptfs_printk(KERN_ERR, "Error generating scatterlist "
"for crypt_stat encrypted session key; "
"expected rc = 1; got rc = [%d]. "
list_for_each_entry(global_auth_tok,
&mount_crypt_stat->global_auth_tok_list,
mount_crypt_stat_list) {
- if ((rc = ecryptfs_keyring_auth_tok_for_sig(
- &global_auth_tok->global_auth_tok_key,
- &global_auth_tok->global_auth_tok,
- global_auth_tok->sig))) {
+ rc = ecryptfs_keyring_auth_tok_for_sig(
+ &global_auth_tok->global_auth_tok_key,
+ &global_auth_tok->global_auth_tok,
+ global_auth_tok->sig);
+ if (rc) {
printk(KERN_ERR "Could not find valid key in user "
"session keyring for sig specified in mount "
"option: [%s]\n", global_auth_tok->sig);
if (!cipher_key_bytes_set) {
mount_crypt_stat->global_default_cipher_key_size = 0;
}
- if ((rc = ecryptfs_add_new_key_tfm(
- NULL, mount_crypt_stat->global_default_cipher_name,
- mount_crypt_stat->global_default_cipher_key_size))) {
+ rc = ecryptfs_add_new_key_tfm(
+ NULL, mount_crypt_stat->global_default_cipher_name,
+ mount_crypt_stat->global_default_cipher_key_size);
+ if (rc) {
printk(KERN_ERR "Error attempting to initialize cipher with "
"name = [%s] and key size = [%td]; rc = [%d]\n",
mount_crypt_stat->global_default_cipher_name,
rc = -EINVAL;
goto out;
}
- if ((rc = ecryptfs_init_global_auth_toks(mount_crypt_stat))) {
+ rc = ecryptfs_init_global_auth_toks(mount_crypt_stat);
+ if (rc) {
printk(KERN_WARNING "One or more global auth toks could not "
"properly register; rc = [%d]\n", rc);
}
sb->s_maxbytes = lower_root->d_sb->s_maxbytes;
ecryptfs_set_dentry_lower(sb->s_root, lower_root);
ecryptfs_set_dentry_lower_mnt(sb->s_root, lower_mnt);
- if ((rc = ecryptfs_interpose(lower_root, sb->s_root, sb, 0)))
+ rc = ecryptfs_interpose(lower_root, sb->s_root, sb, 0);
+ if (rc)
goto out_free;
rc = 0;
goto out;
{
int rc;
- if ((rc = subsystem_register(&ecryptfs_subsys))) {
+ rc = subsystem_register(&ecryptfs_subsys);
+ if (rc) {
printk(KERN_ERR
"Unable to register ecryptfs sysfs subsystem\n");
goto out;
{
int rc;
- if ((rc = ecryptfs_destroy_crypto())) {
+ rc = ecryptfs_destroy_crypto();
+ if (rc) {
printk(KERN_ERR "Failure whilst attempting to destroy crypto; "
"rc = [%d]\n", rc);
}
}
mutex_init(&ecryptfs_daemon_id_hash_mux);
mutex_lock(&ecryptfs_daemon_id_hash_mux);
- ecryptfs_hash_buckets = 0;
- while (ecryptfs_number_of_users >> ++ecryptfs_hash_buckets);
+ ecryptfs_hash_buckets = 1;
+ while (ecryptfs_number_of_users >> ecryptfs_hash_buckets)
+ ecryptfs_hash_buckets++;
ecryptfs_daemon_id_hash = kmalloc(sizeof(struct hlist_head)
* ecryptfs_hash_buckets, GFP_KERNEL);
if (!ecryptfs_daemon_id_hash) {
rc = PTR_ERR(tmp_page);
goto out;
}
- if ((rc = ecryptfs_prepare_write_no_truncate(file, tmp_page, start,
- (start + num_zeros)))) {
+ rc = ecryptfs_prepare_write_no_truncate(file, tmp_page, start,
+ (start + num_zeros));
+ if (rc) {
ecryptfs_printk(KERN_ERR, "Error preparing to write zero's "
"to page at index [0x%.16x]\n",
index);