Fix some (digital-mars) compiler warnings In particular, conditional expressions which contain an assignment statement, where the expression type is not explicitly made to be boolean, elicits the following message: warning 2: possible unintended assignment Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
diff --git a/src/delta-apply.c b/src/delta-apply.c
index 4852017..7b592ec 100644
--- a/src/delta-apply.c
+++ b/src/delta-apply.c
@@ -47,7 +47,7 @@ int git__delta_apply(
return GIT_ERROR;
res_sz = hdr_sz(&delta, delta_end);
- if (!(res_dp = git__malloc(res_sz + 1)))
+ if ((res_dp = git__malloc(res_sz + 1)) == NULL)
return GIT_ERROR;
res_dp[res_sz] = '\0';
out->data = res_dp;
diff --git a/src/fileops.c b/src/fileops.c
index 8cc2934..1f8435d 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -232,7 +232,7 @@ int gitfo_dirent(
if (!dir)
return git_os_error();
- while ((de = readdir(dir))) {
+ while ((de = readdir(dir)) != NULL) {
size_t de_len;
int result;
diff --git a/src/odb.c b/src/odb.c
index f34fd00..2ca59d5 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -558,7 +558,7 @@ static int pack_openidx_v1(git_pack *p)
size_t expsz;
int j;
- if (!(im_fanout = git__malloc(sizeof(*im_fanout) * 256)))
+ if ((im_fanout = git__malloc(sizeof(*im_fanout) * 256)) == NULL)
return GIT_ERROR;
im_fanout[0] = decode32(&src_fanout[0]);
@@ -615,7 +615,7 @@ static int pack_openidx_v2(git_pack *p)
uint32_t *im_fanout;
int j;
- if (!(im_fanout = git__malloc(sizeof(*im_fanout) * 256)))
+ if ((im_fanout = git__malloc(sizeof(*im_fanout) * 256)) == NULL)
return GIT_ERROR;
im_fanout[0] = decode32(&src_fanout[0]);
@@ -751,11 +751,11 @@ static int scan_one_pack(void *state, char *name)
if (gitfo_exists(name))
return 0;
- if (!(r = git__malloc(sizeof(*r))))
+ if ((r = git__malloc(sizeof(*r))) == NULL)
return GIT_ERROR;
*d = '\0'; /* "pack-abc.pack" -_> "pack-abc" */
- if (!(r->pack = alloc_pack(s + 1))) {
+ if ((r->pack = alloc_pack(s + 1)) == NULL) {
free(r);
return GIT_ERROR;
}
@@ -811,7 +811,7 @@ static git_packlist *packlist_get(git_odb *db)
git_packlist *pl;
gitlck_lock(&db->lock);
- if ((pl = db->packlist))
+ if ((pl = db->packlist) != NULL)
pl->refcnt++;
else
pl = scan_packs(db);
diff --git a/src/util.c b/src/util.c
index 3184a3a..bc95d2d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -67,7 +67,7 @@ int git__dirname(char *dir, size_t n, char *path)
assert(dir && n > 1);
- if (!path || !*path || !(s = strrchr(path, '/'))) {
+ if (!path || !*path || (s = strrchr(path, '/')) == NULL) {
strcpy(dir, ".");
return 1;
}
@@ -99,7 +99,7 @@ int git__basename(char *base, size_t n, char *path)
}
len = strlen(path);
- if (!(s = strrchr(path, '/'))) {
+ if ((s = strrchr(path, '/')) == NULL) {
if (len >= n)
return GIT_ERROR;
strcpy(base, path);