Merge branch 'js/comma-semicolon-confusion'

Code clean-up.

* js/comma-semicolon-confusion:
  detect-compiler: detect clang even if it found CUDA
  clang: warn when the comma operator is used
  compat/regex: explicitly mark intentional use of the comma operator
  wildmatch: avoid using of the comma operator
  diff-delta: avoid using the comma operator
  xdiff: avoid using the comma operator unnecessarily
  clar: avoid using the comma operator unnecessarily
  kwset: avoid using the comma operator unnecessarily
  rebase: avoid using the comma operator unnecessarily
  remote-curl: avoid using the comma operator unnecessarily
maint
Junio C Hamano 2025-04-15 13:50:16 -07:00
commit 7b03646f85
12 changed files with 88 additions and 51 deletions

View File

@ -1843,7 +1843,7 @@ int cmd_rebase(int argc,
strbuf_addf(&msg, "%s (start): checkout %s",
options.reflog_action, options.onto_name);
ropts.oid = &options.onto->object.oid;
ropts.orig_head = &options.orig_head->object.oid,
ropts.orig_head = &options.orig_head->object.oid;
ropts.flags = RESET_HEAD_DETACH | RESET_ORIG_HEAD |
RESET_HEAD_RUN_POST_CHECKOUT_HOOK;
ropts.head_msg = msg.buf;

View File

@ -1232,7 +1232,10 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
is = src->nelem - 1, id = dest->nelem - 1; is >= 0 && id >= 0; )
{
if (dest->elems[id] == src->elems[is])
is--, id--;
{
is--;
id--;
}
else if (dest->elems[id] < src->elems[is])
dest->elems[--sbase] = src->elems[is--];
else /* if (dest->elems[id] > src->elems[is]) */

View File

@ -2210,7 +2210,7 @@ sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
/* mctx->bkref_ents may have changed, reload the pointer. */
entry = mctx->bkref_ents + enabled_idx;
}
while (enabled_idx++, entry++->more);
while ((void)enabled_idx++, entry++->more);
}
err = REG_NOERROR;
free_return:

View File

@ -41,6 +41,10 @@ DEVELOPER_CFLAGS += -Wwrite-strings
DEVELOPER_CFLAGS += -fno-common
DEVELOPER_CFLAGS += -Wunreachable-code

ifneq ($(filter clang9,$(COMPILER_FEATURES)),)
DEVELOPER_CFLAGS += -Wcomma
endif

ifneq ($(filter clang4,$(COMPILER_FEATURES)),)
DEVELOPER_CFLAGS += -Wtautological-constant-out-of-range-compare
endif

View File

@ -9,7 +9,7 @@ CC="$*"
#
# FreeBSD clang version 3.4.1 (tags/RELEASE...)
get_version_line() {
LANG=C LC_ALL=C $CC -v 2>&1 | grep ' version '
LANG=C LC_ALL=C $CC -v 2>&1 | sed -n '/ version /{p;q;}'
}

get_family() {

View File

@ -438,19 +438,31 @@ create_delta(const struct delta_index *index,
op = out + outpos++;
i = 0x80;

if (moff & 0x000000ff)
out[outpos++] = moff >> 0, i |= 0x01;
if (moff & 0x0000ff00)
out[outpos++] = moff >> 8, i |= 0x02;
if (moff & 0x00ff0000)
out[outpos++] = moff >> 16, i |= 0x04;
if (moff & 0xff000000)
out[outpos++] = moff >> 24, i |= 0x08;
if (moff & 0x000000ff) {
out[outpos++] = moff >> 0;
i |= 0x01;
}
if (moff & 0x0000ff00) {
out[outpos++] = moff >> 8;
i |= 0x02;
}
if (moff & 0x00ff0000) {
out[outpos++] = moff >> 16;
i |= 0x04;
}
if (moff & 0xff000000) {
out[outpos++] = moff >> 24;
i |= 0x08;
}

if (msize & 0x00ff)
out[outpos++] = msize >> 0, i |= 0x10;
if (msize & 0xff00)
out[outpos++] = msize >> 8, i |= 0x20;
if (msize & 0x00ff) {
out[outpos++] = msize >> 0;
i |= 0x10;
}
if (msize & 0xff00) {
out[outpos++] = msize >> 8;
i |= 0x20;
}

*op = i;


54
kwset.c
View File

@ -197,10 +197,13 @@ kwsincr (kwset_t kws, char const *text, size_t len)
while (link && label != link->label)
{
links[depth] = link;
if (label < link->label)
dirs[depth++] = L, link = link->llink;
else
dirs[depth++] = R, link = link->rlink;
if (label < link->label) {
dirs[depth++] = L;
link = link->llink;
} else {
dirs[depth++] = R;
link = link->rlink;
}
}

/* The current character doesn't have an outgoing link at
@ -257,14 +260,14 @@ kwsincr (kwset_t kws, char const *text, size_t len)
switch (dirs[depth + 1])
{
case L:
r = links[depth], t = r->llink, rl = t->rlink;
t->rlink = r, r->llink = rl;
r = links[depth]; t = r->llink; rl = t->rlink;
t->rlink = r; r->llink = rl;
t->balance = r->balance = 0;
break;
case R:
r = links[depth], l = r->llink, t = l->rlink;
rl = t->rlink, lr = t->llink;
t->llink = l, l->rlink = lr, t->rlink = r, r->llink = rl;
r = links[depth]; l = r->llink; t = l->rlink;
rl = t->rlink; lr = t->llink;
t->llink = l; l->rlink = lr; t->rlink = r; r->llink = rl;
l->balance = t->balance != 1 ? 0 : -1;
r->balance = t->balance != (char) -1 ? 0 : 1;
t->balance = 0;
@ -277,14 +280,14 @@ kwsincr (kwset_t kws, char const *text, size_t len)
switch (dirs[depth + 1])
{
case R:
l = links[depth], t = l->rlink, lr = t->llink;
t->llink = l, l->rlink = lr;
l = links[depth]; t = l->rlink; lr = t->llink;
t->llink = l; l->rlink = lr;
t->balance = l->balance = 0;
break;
case L:
l = links[depth], r = l->rlink, t = r->llink;
lr = t->llink, rl = t->rlink;
t->llink = l, l->rlink = lr, t->rlink = r, r->llink = rl;
l = links[depth]; r = l->rlink; t = r->llink;
lr = t->llink; rl = t->rlink;
t->llink = l; l->rlink = lr; t->rlink = r; r->llink = rl;
l->balance = t->balance != 1 ? 0 : -1;
r->balance = t->balance != (char) -1 ? 0 : 1;
t->balance = 0;
@ -567,22 +570,22 @@ bmexec (kwset_t kws, char const *text, size_t size)
{
while (tp <= ep)
{
d = d1[U(tp[-1])], tp += d;
d = d1[U(tp[-1])], tp += d;
d = d1[U(tp[-1])]; tp += d;
d = d1[U(tp[-1])]; tp += d;
if (d == 0)
goto found;
d = d1[U(tp[-1])], tp += d;
d = d1[U(tp[-1])], tp += d;
d = d1[U(tp[-1])], tp += d;
d = d1[U(tp[-1])]; tp += d;
d = d1[U(tp[-1])]; tp += d;
d = d1[U(tp[-1])]; tp += d;
if (d == 0)
goto found;
d = d1[U(tp[-1])], tp += d;
d = d1[U(tp[-1])], tp += d;
d = d1[U(tp[-1])], tp += d;
d = d1[U(tp[-1])]; tp += d;
d = d1[U(tp[-1])]; tp += d;
d = d1[U(tp[-1])]; tp += d;
if (d == 0)
goto found;
d = d1[U(tp[-1])], tp += d;
d = d1[U(tp[-1])], tp += d;
d = d1[U(tp[-1])]; tp += d;
d = d1[U(tp[-1])]; tp += d;
}
break;
found:
@ -649,7 +652,8 @@ cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch)
mch = NULL;
else
{
mch = text, accept = kwset->trie;
mch = text;
accept = kwset->trie;
goto match;
}


View File

@ -715,6 +715,7 @@ libgit_dependencies = [ ]
# Makefile.
if get_option('warning_level') in ['2','3', 'everything'] and compiler.get_argument_syntax() == 'gcc'
foreach cflag : [
'-Wcomma',
'-Wdeclaration-after-statement',
'-Wformat-security',
'-Wold-style-definition',

View File

@ -1239,7 +1239,7 @@ static int fetch_git(struct discovery *heads,
packet_buf_flush(&preamble);

memset(&rpc, 0, sizeof(rpc));
rpc.service_name = "git-upload-pack",
rpc.service_name = "git-upload-pack";
rpc.gzip_request = 1;

err = rpc_service(&rpc, heads, args.v, &preamble, &rpc_result);
@ -1401,7 +1401,7 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs)
packet_buf_flush(&preamble);

memset(&rpc, 0, sizeof(rpc));
rpc.service_name = "git-receive-pack",
rpc.service_name = "git-receive-pack";

err = rpc_service(&rpc, heads, args.v, &preamble, &rpc_result);
if (rpc_result.len)

View File

@ -376,9 +376,12 @@ fs_copydir_helper(const char *source, const char *dest, int dest_mode)
mkdir(dest, dest_mode);

cl_assert_(source_dir = opendir(source), "Could not open source dir");
while ((d = (errno = 0, readdir(source_dir))) != NULL) {
for (;;) {
char *child;

errno = 0;
if ((d = readdir(source_dir)) == NULL)
break;
if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
continue;

@ -479,9 +482,12 @@ fs_rmdir_helper(const char *path)
struct dirent *d;

cl_assert_(dir = opendir(path), "Could not open dir");
while ((d = (errno = 0, readdir(dir))) != NULL) {
for (;;) {
char *child;

errno = 0;
if ((d = readdir(dir)) == NULL)
break;
if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
continue;


View File

@ -223,7 +223,7 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
p_ch = '[';
if (t_ch == p_ch)
matched = 1;
continue;
goto next;
}
if (CC_EQ(s,i, "alnum")) {
if (ISALNUM(t_ch))
@ -268,7 +268,10 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
p_ch = 0; /* This makes "prev_ch" get set to 0. */
} else if (t_ch == p_ch)
matched = 1;
} while (prev_ch = p_ch, (p_ch = *++p) != ']');
next:
prev_ch = p_ch;
p_ch = *++p;
} while (p_ch != ']');
if (matched == negated ||
((flags & WM_PATHNAME) && t_ch == '/'))
return WM_NOMATCH;

View File

@ -211,8 +211,10 @@ static long xdl_split(unsigned long const *ha1, long off1, long lim1,
for (d = fmax; d >= fmin; d -= 2) {
i1 = XDL_MIN(kvdf[d], lim1);
i2 = i1 - d;
if (lim2 < i2)
i1 = lim2 + d, i2 = lim2;
if (lim2 < i2) {
i1 = lim2 + d;
i2 = lim2;
}
if (fbest < i1 + i2) {
fbest = i1 + i2;
fbest1 = i1;
@ -223,8 +225,10 @@ static long xdl_split(unsigned long const *ha1, long off1, long lim1,
for (d = bmax; d >= bmin; d -= 2) {
i1 = XDL_MAX(off1, kvdb[d]);
i2 = i1 - d;
if (i2 < off2)
i1 = off2 + d, i2 = off2;
if (i2 < off2) {
i1 = off2 + d;
i2 = off2;
}
if (i1 + i2 < bbest) {
bbest = i1 + i2;
bbest1 = i1;