Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3390326ybx; Sun, 3 Nov 2019 17:48:46 -0800 (PST) X-Google-Smtp-Source: APXvYqxhJQvlINvPlJQ/yRE652yFnMtgCVNPPeBb29V5Mcbam9sOAW+4HBNYvFdFLDCz+btCi4qY X-Received: by 2002:a50:9713:: with SMTP id c19mr26638952edb.206.1572832126877; Sun, 03 Nov 2019 17:48:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572832126; cv=none; d=google.com; s=arc-20160816; b=eSdZ4sUGrFOGpRyoFncVV8mdRwMMs8bofML0Zsu/T5Y/vaDGO6aHItIcTjf1wrPY6m AMjK+eL17bQzxFsKBZVA0Oy7xH+Xav44/ylpO8XSuR8xVI/PHf1iaYCP6V9WLIZpjjnb p72VKnWLjN/k68Qf0RZPvyEenymPlXlWm+O9PeOGt9BrlMqxb6K0IpE+q3dl7iM8JjDj 6l1QgXz2JMUfLYPBEfORH7ujJQlxKchei/4/6rP9wmfFEea49i2fbcFNkSfkxezTQKK5 R10O9zsywDGYIhrRhzxvOTO783hJwhxfyfqFPaWN3DRZ8C5K8ung7yOzdgCZzm8MSrdq WOaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=u019LskbZP8VabhKx0LyX0aafFHStxhhypj6hGUDhZI=; b=yDLBlIN4MW77kOfmjrwu3t/VrjNNIwGdjOHcFFgcXU8B6j0AMa0PeWS7dOboyL2IIl GVqpE06EKM6DRjd2FT5qS1M3AA1kANipIhElXPr+ScKGFn7d9ionel05FSDa7AAPj8EQ N0eXK4uUMtD4wItKGHSL2Tnoxz3gY++qMThry2mj/fL3H3JKpbimyoGZAKi1YrJ23I4x 3qUTXP19PVcVp1C86eRJ0nXuJ2z/5zjKdR0CB6lywGnMSyHw/eS9MkgDnBvuoRyGhnOW SaWG7OiZnL7A6RouQ+oXM/z9hweRjVE9oxGTe1QGXyix1BIniIgzcY+GXqccJJXJc6Qs qrPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vt.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p15si6457907edi.27.2019.11.03.17.48.23; Sun, 03 Nov 2019 17:48:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vt.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729062AbfKDBqi (ORCPT + 99 others); Sun, 3 Nov 2019 20:46:38 -0500 Received: from outbound.smtp.vt.edu ([198.82.183.121]:39796 "EHLO omr1.cc.vt.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729034AbfKDBqi (ORCPT ); Sun, 3 Nov 2019 20:46:38 -0500 Received: from mr6.cc.vt.edu (mr6.cc.vt.edu [IPv6:2607:b400:92:8500:0:af:2d00:4488]) by omr1.cc.vt.edu (8.14.4/8.14.4) with ESMTP id xA41kavI025878 for ; Sun, 3 Nov 2019 20:46:36 -0500 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by mr6.cc.vt.edu (8.14.7/8.14.7) with ESMTP id xA41kVF2017933 for ; Sun, 3 Nov 2019 20:46:36 -0500 Received: by mail-qt1-f198.google.com with SMTP id u26so17367913qtq.1 for ; Sun, 03 Nov 2019 17:46:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=u019LskbZP8VabhKx0LyX0aafFHStxhhypj6hGUDhZI=; b=bAxUXcquZ7f5fxaGFNH6KHy1Ia1vB3hGXOUXrha6FTp135wJLGx4EjdnigNZVoTneq G/5mX/Dq/9YPUWiBkf8o7PrMxwdR4k/+4F1rmQlX62+Nge9BvF7ynLbdWBY6cQJA+zbM 2wsgT2fmp0xzNcaairlc6U3/Nlhwc+GFkbpx6uarGhfgDFP49WETBK6oULugEfUOFky6 KWBmas1sISli6K2f5uplvqqGTlZjrRzOSiNr76wv1VJ53xZxk4pm04AaBARSh2ipTS3f 0lKWhUhzy6DdSc1qal4H0BQAwUu1ojWpSaHk8KZ439whHUj7VdSI9MEgRJmOmLRzyXXZ oMVQ== X-Gm-Message-State: APjAAAVSpfphhLAmhTQt9V2Spoh1sEw8YLMvaTp2h+i6NPB8hoRFhItB S5/lyZ4siJqN2BRNMZ8ptzdiV11jwHjYKjEv+2R0kXuwBjTtXIxiw0MDAfAC+r6XszYASbykZZn nb+fWUi5VKgLpRiNMQVh1luZ9xS/tuWurYLA= X-Received: by 2002:a05:620a:55c:: with SMTP id o28mr2946035qko.131.1572831991124; Sun, 03 Nov 2019 17:46:31 -0800 (PST) X-Received: by 2002:a05:620a:55c:: with SMTP id o28mr2946018qko.131.1572831990805; Sun, 03 Nov 2019 17:46:30 -0800 (PST) Received: from turing-police.lan ([2601:5c0:c001:c9e1::359]) by smtp.gmail.com with ESMTPSA id d2sm8195354qkg.77.2019.11.03.17.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2019 17:46:29 -0800 (PST) From: Valdis Kletnieks X-Google-Original-From: Valdis Kletnieks To: Valdis Kletnieks Cc: Valdis Kletnieks , Greg Kroah-Hartman , linux-fsdevel@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 08/10] staging: exfat: Collapse redundant return code translations Date: Sun, 3 Nov 2019 20:45:04 -0500 Message-Id: <20191104014510.102356-9-Valdis.Kletnieks@vt.edu> X-Mailer: git-send-email 2.24.0.rc1 In-Reply-To: <20191104014510.102356-1-Valdis.Kletnieks@vt.edu> References: <20191104014510.102356-1-Valdis.Kletnieks@vt.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we no longer use odd internal return codes, we can heave the translation code over the side, and just pass the error code back up the call chain. Signed-off-by: Valdis Kletnieks --- drivers/staging/exfat/exfat_super.c | 92 +++++------------------------ 1 file changed, 14 insertions(+), 78 deletions(-) diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 5d538593b5f6..a97a61a60517 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -650,7 +650,7 @@ static int ffsCreateFile(struct inode *inode, char *path, u8 mode, struct uni_name_t uni_name; struct super_block *sb = inode->i_sb; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - int ret; + int ret = 0; /* check the validity of pointer parameters */ if (!fid || !path || (*path == '\0')) @@ -2366,19 +2366,9 @@ static int exfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, pr_debug("%s entered\n", __func__); err = ffsCreateFile(dir, (u8 *)dentry->d_name.name, FM_REGULAR, &fid); - if (err) { - if (err == -EINVAL) - err = -EINVAL; - else if (err == -EEXIST) - err = -EEXIST; - else if (err == -ENOSPC) - err = -ENOSPC; - else if (err == -ENAMETOOLONG) - err = -ENAMETOOLONG; - else - err = -EIO; + if (err) goto out; - } + INC_IVERSION(dir); curtime = current_time(dir); dir->i_ctime = curtime; @@ -2543,13 +2533,9 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry) EXFAT_I(inode)->fid.size = i_size_read(inode); err = ffsRemoveFile(dir, &(EXFAT_I(inode)->fid)); - if (err) { - if (err == -EPERM) - err = -EPERM; - else - err = -EIO; + if (err) goto out; - } + INC_IVERSION(dir); curtime = current_time(dir); dir->i_mtime = curtime; @@ -2589,27 +2575,14 @@ static int exfat_symlink(struct inode *dir, struct dentry *dentry, pr_debug("%s entered\n", __func__); err = ffsCreateFile(dir, (u8 *)dentry->d_name.name, FM_SYMLINK, &fid); - if (err) { - if (err == -EINVAL) - err = -EINVAL; - else if (err == -EEXIST) - err = -EEXIST; - else if (err == -ENOSPC) - err = -ENOSPC; - else - err = -EIO; + if (err) goto out; - } + err = ffsWriteFile(dir, &fid, (char *)target, len, &ret); if (err) { ffsRemoveFile(dir, &fid); - - if (err == -ENOSPC) - err = -ENOSPC; - else - err = -EIO; goto out; } @@ -2666,19 +2639,9 @@ static int exfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) pr_debug("%s entered\n", __func__); err = ffsCreateDir(dir, (u8 *)dentry->d_name.name, &fid); - if (err) { - if (err == -EINVAL) - err = -EINVAL; - else if (err == -EEXIST) - err = -EEXIST; - else if (err == -ENOSPC) - err = -ENOSPC; - else if (err == -ENAMETOOLONG) - err = -ENAMETOOLONG; - else - err = -EIO; + if (err) goto out; - } + INC_IVERSION(dir); curtime = current_time(dir); dir->i_ctime = curtime; @@ -2727,19 +2690,9 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) EXFAT_I(inode)->fid.size = i_size_read(inode); err = ffsRemoveDir(dir, &(EXFAT_I(inode)->fid)); - if (err) { - if (err == -EINVAL) - err = -EINVAL; - else if (err == -EEXIST) - err = -ENOTEMPTY; - else if (err == -ENOENT) - err = -ENOENT; - else if (err == -EBUSY) - err = -EBUSY; - else - err = -EIO; + if (err) goto out; - } + INC_IVERSION(dir); curtime = current_time(dir); dir->i_mtime = curtime; @@ -2787,21 +2740,9 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, err = ffsMoveFile(old_dir, &(EXFAT_I(old_inode)->fid), new_dir, new_dentry); - if (err) { - if (err == -EPERM) - err = -EPERM; - else if (err == -EINVAL) - err = -EINVAL; - else if (err == -EEXIST) - err = -EEXIST; - else if (err == -ENOENT) - err = -ENOENT; - else if (err == -ENOSPC) - err = -ENOSPC; - else - err = -EIO; + if (err) goto out; - } + INC_IVERSION(new_dir); curtime = current_time(new_dir); new_dir->i_ctime = curtime; @@ -3161,12 +3102,7 @@ static int exfat_bmap(struct inode *inode, sector_t sector, sector_t *phys, err = ffsMapCluster(inode, clu_offset, &cluster); - if (err) { - if (err == -ENOSPC) - return -ENOSPC; - else - return -EIO; - } else if (cluster != CLUSTER_32(~0)) { + if (!err && (cluster != CLUSTER_32(~0))) { *phys = START_SECTOR(cluster) + sec_offset; *mapped_blocks = p_fs->sectors_per_clu - sec_offset; } -- 2.24.0.rc1