From patchwork Thu Nov 12 09:31:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Kleine-Budde X-Patchwork-Id: 543284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3439D14030F for ; Thu, 12 Nov 2015 20:33:46 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZwoEo-0003I0-Ge; Thu, 12 Nov 2015 09:32:14 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZwoEX-00037D-EG for linux-mtd@lists.infradead.org; Thu, 12 Nov 2015 09:31:58 +0000 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1ZwoE6-0006Mi-TB; Thu, 12 Nov 2015 10:31:30 +0100 Received: from mkl by dude.hi.pengutronix.de with local (Exim 4.86) (envelope-from ) id 1ZwoE6-0001Z5-Ln; Thu, 12 Nov 2015 10:31:30 +0100 From: Marc Kleine-Budde To: linux-mtd@lists.infradead.org Subject: [PATCH v2 1/5] mkfs.ubifs: change add_directory argument to 'existing' Date: Thu, 12 Nov 2015 10:31:24 +0100 Message-Id: <1447320688-3086-2-git-send-email-mkl@pengutronix.de> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1447320688-3086-1-git-send-email-mkl@pengutronix.de> References: <1447320688-3086-1-git-send-email-mkl@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mtd@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151112_013157_776043_8D37840C X-CRM114-Status: GOOD ( 16.81 ) X-Spam-Score: -2.2 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.3 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sascha Hauer , Marc Kleine-Budde , kernel@pengutronix.de MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Sascha Hauer A 'non_existing' argument which is only used with !non_existing is just too confusing. Change this to positive logic. Signed-off-by: Sascha Hauer Reviewed-by: Daniel Walter Signed-off-by: Marc Kleine-Budde --- ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c index ca17e2bca3ac..1b816ae483e0 100644 --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c @@ -1395,12 +1395,12 @@ static int add_non_dir(const char *path_name, ino_t *inum, unsigned int nlink, * @dir_name: directory path name * @dir_inum: UBIFS inode number of directory * @st: directory inode statistics - * @non_existing: non-zero if this function is called for a directory which - * does not exist on the host file-system and it is being - * created because it is defined in the device table file. + * @existing: zero if this function is called for a directory which + * does not exist on the host file-system and it is being + * created because it is defined in the device table file. */ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, - int non_existing) + int existing) { struct dirent *entry; DIR *dir = NULL; @@ -1416,7 +1416,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, unsigned long long dir_creat_sqnum = ++c->max_sqnum; dbg_msg(2, "%s", dir_name); - if (!non_existing) { + if (existing) { dir = opendir(dir_name); if (dir == NULL) return sys_err_msg("cannot open directory '%s'", @@ -1434,7 +1434,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, * Before adding the directory itself, we have to iterate over all the * entries the device table adds to this directory and create them. */ - for (; !non_existing;) { + for (; existing;) { struct stat dent_st; errno = 0; @@ -1492,7 +1492,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, inum = ++c->highest_inum; if (S_ISDIR(dent_st.st_mode)) { - err = add_directory(name, inum, &dent_st, 0); + err = add_directory(name, inum, &dent_st, 1); if (err) goto out_free; nlink += 1; @@ -1544,7 +1544,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, inum = ++c->highest_inum; if (S_ISDIR(nh_elt->mode)) { - err = add_directory(name, inum, &fake_st, 1); + err = add_directory(name, inum, &fake_st, 0); if (err) goto out_free; nlink += 1; @@ -1570,14 +1570,14 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, goto out_free; free(name); - if (!non_existing && closedir(dir) == -1) + if (existing && closedir(dir) == -1) return sys_err_msg("error closing directory '%s'", dir_name); return 0; out_free: free(name); - if (!non_existing) + if (existing) closedir(dir); return -1; } @@ -1624,7 +1624,7 @@ static int write_data(void) } head_flags = 0; - err = add_directory(root, UBIFS_ROOT_INO, &root_st, !root); + err = add_directory(root, UBIFS_ROOT_INO, &root_st, !!root); if (err) return err; err = add_multi_linked_files();