From owner-svn-src-all@freebsd.org Sun Jan 21 04:57:31 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2D1FDEB880D; Sun, 21 Jan 2018 04:57:31 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0723F7B4B0; Sun, 21 Jan 2018 04:57:31 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 563F726C87; Sun, 21 Jan 2018 04:57:30 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0L4vUkD013308; Sun, 21 Jan 2018 04:57:30 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0L4vUb6013306; Sun, 21 Jan 2018 04:57:30 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201801210457.w0L4vUb6013306@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 21 Jan 2018 04:57:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328211 - head/lib/libc/regex X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/lib/libc/regex X-SVN-Commit-Revision: 328211 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jan 2018 04:57:31 -0000 Author: kevans Date: Sun Jan 21 04:57:29 2018 New Revision: 328211 URL: https://svnweb.freebsd.org/changeset/base/328211 Log: regex(3): Resolve issues with higher WARNS levels libc is set for WARNS=2, but the incoming libregex will use WARNS=6. Sprinkle some casts and (void)bc's to alleviate the warnings that come along with the higher WARNS level. These 'bc' parameters could be outright removed, but as of right now they will be used in some parts of libregex land. Silence the warnings instead rather than flip-flopping. Modified: head/lib/libc/regex/engine.c head/lib/libc/regex/regcomp.c Modified: head/lib/libc/regex/engine.c ============================================================================== --- head/lib/libc/regex/engine.c Sat Jan 20 23:46:03 2018 (r328210) +++ head/lib/libc/regex/engine.c Sun Jan 21 04:57:29 2018 (r328211) @@ -398,7 +398,7 @@ dissect(struct match *m, es += OPND(m->g->strip[es]); break; case OCH_: - while (OP(m->g->strip[es]) != O_CH) + while (OP(m->g->strip[es]) != (sop)O_CH) es += OPND(m->g->strip[es]); break; } @@ -512,7 +512,7 @@ dissect(struct match *m, assert(OP(m->g->strip[esub]) == OOR2); ssub = esub + 1; esub += OPND(m->g->strip[esub]); - if (OP(m->g->strip[esub]) == OOR2) + if (OP(m->g->strip[esub]) == (sop)OOR2) esub--; else assert(OP(m->g->strip[esub]) == O_CH); @@ -647,7 +647,7 @@ backref(struct match *m, do { assert(OP(s) == OOR2); ss += OPND(s); - } while (OP(s = m->g->strip[ss]) != O_CH); + } while (OP(s = m->g->strip[ss]) != (sop)O_CH); /* note that the ss++ gets us past the O_CH */ break; default: /* have to make a choice */ @@ -680,7 +680,7 @@ backref(struct match *m, ssp = m->offp + m->pmatch[i].rm_so; if (memcmp(sp, ssp, len) != 0) return(NULL); - while (m->g->strip[ss] != SOP(O_BACK, i)) + while (m->g->strip[ss] != (sop)SOP(O_BACK, i)) ss++; return(backref(m, sp+len, stop, ss+1, stopst, lev, rec)); case OQUEST_: /* to null or not */ @@ -712,13 +712,13 @@ backref(struct match *m, if (dp != NULL) return(dp); /* that one missed, try next one */ - if (OP(m->g->strip[esub]) == O_CH) + if (OP(m->g->strip[esub]) == (sop)O_CH) return(NULL); /* there is none */ esub++; - assert(OP(m->g->strip[esub]) == OOR2); + assert(OP(m->g->strip[esub]) == (sop)OOR2); ssub = esub + 1; esub += OPND(m->g->strip[esub]); - if (OP(m->g->strip[esub]) == OOR2) + if (OP(m->g->strip[esub]) == (sop)OOR2) esub--; else assert(OP(m->g->strip[esub]) == O_CH); @@ -847,7 +847,7 @@ walk(struct match *m, const char *start, const char *s else matchp = p; } - if (EQ(st, empty) || p == stop || clen > stop - p) + if (EQ(st, empty) || p == stop || clen > (size_t)(stop - p)) break; /* NOTE BREAK OUT */ /* no, we must deal with this character */ @@ -969,22 +969,22 @@ step(struct re_guts *g, break; case OCH_: /* mark the first two branches */ FWD(aft, aft, 1); - assert(OP(g->strip[pc+OPND(s)]) == OOR2); + assert(OP(g->strip[pc+OPND(s)]) == (sop)OOR2); FWD(aft, aft, OPND(s)); break; case OOR1: /* done a branch, find the O_CH */ if (ISSTATEIN(aft, here)) { for (look = 1; - OP(s = g->strip[pc+look]) != O_CH; - look += OPND(s)) - assert(OP(s) == OOR2); + OP(s = g->strip[pc+look]) != (sop)O_CH; + look += OPND(s)) + assert(OP(s) == (sop)OOR2); FWD(aft, aft, look + 1); } break; case OOR2: /* propagate OCH_'s marking */ FWD(aft, aft, 1); - if (OP(g->strip[pc+OPND(s)]) != O_CH) { - assert(OP(g->strip[pc+OPND(s)]) == OOR2); + if (OP(g->strip[pc+OPND(s)]) != (sop)O_CH) { + assert(OP(g->strip[pc+OPND(s)]) == (sop)OOR2); FWD(aft, aft, OPND(s)); } break; Modified: head/lib/libc/regex/regcomp.c ============================================================================== --- head/lib/libc/regex/regcomp.c Sat Jan 20 23:46:03 2018 (r328210) +++ head/lib/libc/regex/regcomp.c Sun Jan 21 04:57:29 2018 (r328211) @@ -364,6 +364,7 @@ p_ere_exp(struct parse *p, struct branchc *bc) sopno subno; int wascaret = 0; + (void)bc; assert(MORE()); /* caller should have ensured this */ c = GETNEXT(); @@ -534,6 +535,7 @@ p_branch_eat_delim(struct parse *p, struct branchc *bc { int nskip; + (void)bc; nskip = 0; while (EAT('|')) ++nskip; @@ -587,6 +589,7 @@ static bool p_branch_empty(struct parse *p, struct branchc *bc) { + (void)bc; SETERROR(REG_EMPTY); return (false); } @@ -1617,12 +1620,12 @@ findmust(struct parse *p, struct re_guts *g) scan += OPND(s); s = *scan; /* assert() interferes w debug printouts */ - if (OP(s) != O_QUEST && OP(s) != O_CH && - OP(s) != OOR2) { + if (OP(s) != (sop)O_QUEST && + OP(s) != (sop)O_CH && OP(s) != (sop)OOR2) { g->iflags |= BAD; return; } - } while (OP(s) != O_QUEST && OP(s) != O_CH); + } while (OP(s) != (sop)O_QUEST && OP(s) != (sop)O_CH); /* FALLTHROUGH */ case OBOW: /* things that break a sequence */ case OEOW: @@ -1631,7 +1634,7 @@ findmust(struct parse *p, struct re_guts *g) case O_QUEST: case O_CH: case OEND: - if (newlen > g->mlen) { /* ends one */ + if (newlen > (sopno)g->mlen) { /* ends one */ start = newstart; g->mlen = newlen; if (offset > -1) { @@ -1646,7 +1649,7 @@ findmust(struct parse *p, struct re_guts *g) newlen = 0; break; case OANY: - if (newlen > g->mlen) { /* ends one */ + if (newlen > (sopno)g->mlen) { /* ends one */ start = newstart; g->mlen = newlen; if (offset > -1) { @@ -1664,7 +1667,7 @@ findmust(struct parse *p, struct re_guts *g) break; case OANYOF: /* may or may not invalidate offset */ /* First, everything as OANY */ - if (newlen > g->mlen) { /* ends one */ + if (newlen > (sopno)g->mlen) { /* ends one */ start = newstart; g->mlen = newlen; if (offset > -1) { @@ -1687,7 +1690,7 @@ findmust(struct parse *p, struct re_guts *g) * save the last known good offset, in case the * must sequence doesn't occur later. */ - if (newlen > g->mlen) { /* ends one */ + if (newlen > (sopno)g->mlen) { /* ends one */ start = newstart; g->mlen = newlen; if (offset > -1) @@ -1748,7 +1751,7 @@ altoffset(sop *scan, int offset) largest = 0; try = 0; s = *scan++; - while (OP(s) != O_QUEST && OP(s) != O_CH) { + while (OP(s) != (sop)O_QUEST && OP(s) != (sop)O_CH) { switch (OP(s)) { case OOR1: if (try > largest) @@ -1764,10 +1767,10 @@ altoffset(sop *scan, int offset) do { scan += OPND(s); s = *scan; - if (OP(s) != O_QUEST && OP(s) != O_CH && - OP(s) != OOR2) + if (OP(s) != (sop)O_QUEST && + OP(s) != (sop)O_CH && OP(s) != (sop)OOR2) return -1; - } while (OP(s) != O_QUEST && OP(s) != O_CH); + } while (OP(s) != (sop)O_QUEST && OP(s) != (sop)O_CH); /* We must skip to the next position, or we'll * leave altoffset() too early. */