Permalink
Browse files

Minor styling changes. I know Yoda-style comparisons are preferred, b…

…ut the rest of the code is the other way and modern linters will complain about assignments in if statements.
  • Loading branch information...
1 parent 4c05a34 commit 1e56553ae2fd86df53006490f664154438f74267 @ggreer committed May 12, 2012
Showing with 9 additions and 9 deletions.
  1. +9 −9 src/search.c
View
@@ -236,7 +236,7 @@ void search_dir(const pcre *re, const pcre_extra *re_extra, const char* path, co
int rc = 0;
struct stat stDirInfo;
- for (i=0; i<results; i++) {
+ for (i = 0; i < results; i++) {
dir = dir_list[i];
/* TODO: this is copy-pasted from about 30 lines above */
path_length = (size_t)(strlen(path) + strlen(dir->d_name) + 2); /* 2 for slash and null char */
@@ -248,16 +248,16 @@ void search_dir(const pcre *re, const pcre_extra *re_extra, const char* path, co
/* Some filesystems, e.g. ReiserFS, always return a type DT_UNKNOWN from readdir or scandir. */
/* Call lstat if we find DT_UNKNOWN to get the information we need. */
if (dir->d_type == DT_UNKNOWN) {
- if (-1 != lstat(dir_full_path, &stDirInfo)) {
+ if (lstat(dir_full_path, &stDirInfo) != -1) {
if (S_ISDIR(stDirInfo.st_mode)) {
- dir->d_type=DT_DIR;
+ dir->d_type = DT_DIR;
}
else if (S_ISLNK(stDirInfo.st_mode)) {
- dir->d_type=DT_LNK;
+ dir->d_type = DT_LNK;
}
}
else {
- log_err("lstat failed on %s", dir_full_path);
+ log_err("lstat() failed on %s", dir_full_path);
/* If lstat fails we may as well carry on and hope for the best. */
}
@@ -267,15 +267,15 @@ void search_dir(const pcre *re, const pcre_extra *re_extra, const char* path, co
}
}
- /* If a link points to a directory then we need to treat it as a directory. */
+ /* If a link points to a directory then we need to treat it as a directory. */
if (dir->d_type == DT_LNK) {
- if (-1 != stat(dir_full_path, &stDirInfo)) {
+ if (stat(dir_full_path, &stDirInfo) != -1) {
if (S_ISDIR(stDirInfo.st_mode)) {
- dir->d_type=DT_DIR;
+ dir->d_type = DT_DIR;
}
}
else {
- log_err("stat failed on %s", dir_full_path);
+ log_err("stat() failed on %s", dir_full_path);
/* If stat fails we may as well carry on and hope for the best. */
}
}

0 comments on commit 1e56553

Please sign in to comment.