Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934861AbcJUS0F (ORCPT ); Fri, 21 Oct 2016 14:26:05 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:33680 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932256AbcJUS0D (ORCPT ); Fri, 21 Oct 2016 14:26:03 -0400 Date: Fri, 21 Oct 2016 11:25:59 -0700 From: Eric Biggers To: Richard Weinberger Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, dedekind1@gmail.com, adrian.hunter@intel.com, tytso@mit.edu, jaegeuk@kernel.org, david@sigma-star.at, wd@denx.de, sbabic@denx.de, dengler@linutronix.de Subject: Re: [PATCH 15/26] ubifs: Implement encrypt/decrypt for all IO Message-ID: <20161021182559.GB90712@google.com> References: <1477054121-10198-1-git-send-email-richard@nod.at> <1477054121-10198-16-git-send-email-richard@nod.at> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1477054121-10198-16-git-send-email-richard@nod.at> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 808 Lines: 26 On Fri, Oct 21, 2016 at 02:48:30PM +0200, Richard Weinberger wrote: > + > + if (ubifs_crypt_is_encrypted(inode)) { > + int clen = le16_to_cpu(dn->compr_size); > + > + if (clen <= 0 || clen > UBIFS_BLOCK_SIZE || clen > dlen) > + goto dump; > + > + ubifs_assert(dlen <= UBIFS_BLOCK_SIZE); > + err = fscrypt_decrypt_buffer(inode, &dn->data, &dn->data, dlen, block, GFP_NOFS); > + if (err) { > + ubifs_err(c, "fscrypt_decrypt_buffer failed: %i", err); > + return err; > + } > + > + ubifs_assert(clen <= dlen); > + dlen = clen; > + } > + There are several code blocks like this, calling either fscrypt_decrypt_buffer() or fscrypt_encrypt_buffer(), which seem to be mostly duplicated. Is it possible to refactor them into helper functions? There are also some lines well over 80 characters. Eric