Return-path: Received: from mail-ee0-f48.google.com ([74.125.83.48]:49874 "EHLO mail-ee0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752975AbaBCU63 (ORCPT ); Mon, 3 Feb 2014 15:58:29 -0500 Received: by mail-ee0-f48.google.com with SMTP id t10so3868937eei.35 for ; Mon, 03 Feb 2014 12:58:28 -0800 (PST) From: Emmanuel Grumbach To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Emmanuel Grumbach Subject: [PATCH 08/62] iwlwifi: pcie: make FH debugfs file code easier to understand Date: Mon, 3 Feb 2014 22:57:14 +0200 Message-Id: <1391461088-8082-8-git-send-email-egrumbach@gmail.com> (sfid-20140203_220007_293282_F229CC60) In-Reply-To: References: Sender: linux-wireless-owner@vger.kernel.org List-ID: From: Johannes Berg The code seems fine, as buf won't be assigned when an error is returned, but checking for the error first is easier to understand. Signed-off-by: Johannes Berg Signed-off-by: Emmanuel Grumbach --- drivers/net/wireless/iwlwifi/pcie/trans.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c index 7290f42..61ae1af 100644 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c @@ -1434,16 +1434,15 @@ static ssize_t iwl_dbgfs_fh_reg_read(struct file *file, { struct iwl_trans *trans = file->private_data; char *buf = NULL; - int pos = 0; - ssize_t ret = -EFAULT; - - ret = pos = iwl_dump_fh(trans, &buf); - if (buf) { - ret = simple_read_from_buffer(user_buf, - count, ppos, buf, pos); - kfree(buf); - } + ssize_t ret; + ret = iwl_dump_fh(trans, &buf); + if (ret < 0) + return ret; + if (!buf) + return -EINVAL; + ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); + kfree(buf); return ret; } -- 1.7.9.5