From: Hiroyuki Sano <sh19910711@gmail.com>
To: git@vger.kernel.org
Cc: Hiroyuki Sano <sh19910711@gmail.com>
Subject: [PATCH v3][GSOC] fsck: use bitwise-or assignment operator to set flag
Date: Thu, 20 Mar 2014 08:02:04 +0900 [thread overview]
Message-ID: <1395270124-2242-1-git-send-email-sh19910711@gmail.com> (raw)
fsck_tree() has two different ways to set a flag,
which are the followings:
1. Using a if-statement that guards assignment.
2. Using a bitwise-or assignment operator.
Currently, many with the former way,
and one with the latter way.
In this patch, unify them to the latter way,
because it makes the code shorter and easier to read,
and it is brief and to the point.
Signed-off-by: Hiroyuki Sano <sh19910711@gmail.com>
---
fsck.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/fsck.c b/fsck.c
index b3022ad..abed62b 100644
--- a/fsck.c
+++ b/fsck.c
@@ -165,18 +165,12 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
sha1 = tree_entry_extract(&desc, &name, &mode);
- if (is_null_sha1(sha1))
- has_null_sha1 = 1;
- if (strchr(name, '/'))
- has_full_path = 1;
- if (!*name)
- has_empty_name = 1;
- if (!strcmp(name, "."))
- has_dot = 1;
- if (!strcmp(name, ".."))
- has_dotdot = 1;
- if (!strcmp(name, ".git"))
- has_dotgit = 1;
+ has_null_sha1 |= is_null_sha1(sha1);
+ has_full_path |= !!strchr(name, '/');
+ has_empty_name |= !*name;
+ has_dot |= !strcmp(name, ".");
+ has_dotdot |= !strcmp(name, "..");
+ has_dotgit |= !strcmp(name, ".git");
has_zero_pad |= *(char *)desc.buffer == '0';
update_tree_entry(&desc);
--
1.9.0
next reply other threads:[~2014-03-19 23:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-19 23:02 Hiroyuki Sano [this message]
2014-03-20 18:20 ` [PATCH v3][GSOC] fsck: use bitwise-or assignment operator to set flag Junio C Hamano
2014-03-20 18:45 ` Junio C Hamano
2014-03-20 23:27 ` Hiroyuki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1395270124-2242-1-git-send-email-sh19910711@gmail.com \
--to=sh19910711@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).