diff options
| author | ab196087 <none@none> | 2008-06-24 12:23:35 -0700 |
|---|---|---|
| committer | ab196087 <none@none> | 2008-06-24 12:23:35 -0700 |
| commit | 1dd08564e4a3aafe66b00aee6f222b0885346fe8 (patch) | |
| tree | 8dd08acb0caf6ffc7181c901aaff2a29ae462c3e /usr/src/cmd/sgs/yacc/common | |
| parent | 82da9f6027f9bba5379e821f9331f18c4b0ffb15 (diff) | |
| download | illumos-joyent-1dd08564e4a3aafe66b00aee6f222b0885346fe8.tar.gz | |
6716350 usr/src/cmd/sgs should be linted by nightly builds
Diffstat (limited to 'usr/src/cmd/sgs/yacc/common')
| -rw-r--r-- | usr/src/cmd/sgs/yacc/common/dextern.h | 20 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/yacc/common/libmai.c | 9 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/yacc/common/libzer.c | 9 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/yacc/common/y1.c | 25 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/yacc/common/y2.c | 33 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/yacc/common/y3.c | 64 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/yacc/common/y4.c | 37 |
7 files changed, 110 insertions, 87 deletions
diff --git a/usr/src/cmd/sgs/yacc/common/dextern.h b/usr/src/cmd/sgs/yacc/common/dextern.h index 20d44fea43..e90aa60468 100644 --- a/usr/src/cmd/sgs/yacc/common/dextern.h +++ b/usr/src/cmd/sgs/yacc/common/dextern.h @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -327,6 +327,24 @@ extern char *parser; #define PARSER "/usr/share/lib/ccs/yaccpar" #endif +/* + * Lint is unable to properly handle formats with wide strings + * (e.g. %ws) and misdiagnoses them as being malformed. + * This macro is used to work around that, by substituting + * a pointer to a null string when compiled by lint. This + * trick works because lint is not able to evaluate the + * variable. + * + * When lint is able to handle %ws, it would be appropriate + * to come back through and remove the use of this macro. + */ +#if defined(__lint) +static const char *lint_ws_fmt = ""; +#define WSFMT(_fmt) lint_ws_fmt +#else +#define WSFMT(_fmt) _fmt +#endif + #ifdef __cplusplus } #endif diff --git a/usr/src/cmd/sgs/yacc/common/libmai.c b/usr/src/cmd/sgs/yacc/common/libmai.c index dc089d5698..cf969f0f50 100644 --- a/usr/src/cmd/sgs/yacc/common/libmai.c +++ b/usr/src/cmd/sgs/yacc/common/libmai.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -21,7 +20,7 @@ */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -39,7 +38,7 @@ extern int yyparse(void); int main(int argc, char **argv) { - setlocale(LC_ALL, ""); + (void) setlocale(LC_ALL, ""); yyparse(); return (0); } diff --git a/usr/src/cmd/sgs/yacc/common/libzer.c b/usr/src/cmd/sgs/yacc/common/libzer.c index 3cdee7811d..01ba9e29bd 100644 --- a/usr/src/cmd/sgs/yacc/common/libzer.c +++ b/usr/src/cmd/sgs/yacc/common/libzer.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -24,7 +23,7 @@ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -41,5 +40,5 @@ yyerror(s) char *s; #endif { - fprintf(stderr, "%s\n", s); + (void) fprintf(stderr, "%s\n", s); } diff --git a/usr/src/cmd/sgs/yacc/common/y1.c b/usr/src/cmd/sgs/yacc/common/y1.c index 78bf9eb4c6..845f82d367 100644 --- a/usr/src/cmd/sgs/yacc/common/y1.c +++ b/usr/src/cmd/sgs/yacc/common/y1.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -110,7 +110,7 @@ extern int nprodsz; int main(int argc, char *argv[]) { - setlocale(LC_ALL, ""); + (void) setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */ #endif @@ -283,7 +283,7 @@ others() ZAPFILE(DEBUGNAME); if (gen_lines) - fprintf(ftable, "# line\t1 \"%s\"\n", parser); + (void) fprintf(ftable, "# line\t1 \"%s\"\n", parser); tmpline = 1; /* copy parser text */ while ((c = getwc(finput)) != EOF) { @@ -310,7 +310,7 @@ others() (void) putwc(c, ftable); (void) fclose(faction); if (gen_lines) - fprintf(ftable, + (void) fprintf(ftable, "\n# line\t%d \"%s\"", tmpline, parser); @@ -483,6 +483,7 @@ summary() } /* write out error comment */ +/*PRINTFLIKE1*/ void error(char *s, ...) { @@ -523,6 +524,7 @@ error(char *s, ...) /* * Print out a warning message. */ +/*PRINTFLIKE2*/ void warning(int flag, char *s, ...) { @@ -595,7 +597,8 @@ LOOKSETS *p; (void) fprintf(foutput, " { "); TLOOP(j) { if (BIT(pp, j)) - (void) fprintf(foutput, "%ws ", symnam(j)); + (void) fprintf(foutput, WSFMT("%ws "), + symnam(j)); } (void) fprintf(foutput, "}"); } @@ -728,7 +731,8 @@ cpfir() return; if ((foutput != NULL)) { NTLOOP(i) { - (void) fprintf(foutput, "\n%ws: ", nontrst[i].name); + (void) fprintf(foutput, WSFMT("\n%ws: "), + nontrst[i].name); prlook(pfirst[i]); (void) fprintf(foutput, " %d\n", pempty[i]); } @@ -830,7 +834,7 @@ LOOKSETS *lptr; if (pidebug && (foutput != NULL)) (void) fprintf(foutput, - "putitem(%ws), state %d\n", writem(ptr), nstate); + WSFMT("putitem(%ws), state %d\n"), writem(ptr), nstate); j = pstate[nstate+1]; j->pitem = ptr; if (!nolook) @@ -927,7 +931,7 @@ again: if (pempty[*prdptr[i]-NTBASE] == WHOKNOWS) { for (p = prdptr[i]+1; *p >= NTBASE && pempty[*p-NTBASE] == EMPTY; ++p) - /* EMPTY */; + ; /* we have a nontrivially empty nonterminal */ if (*p < 0) { pempty[*prdptr[i]-NTBASE] = EMPTY; @@ -996,7 +1000,7 @@ stagen() NTLOOP(j) { if (temp1[j]) (void) fprintf(foutput, - "%ws %d, ", nontrst[j].name, + WSFMT("%ws %d, "), nontrst[j].name, temp1[j]); } (void) fprintf(foutput, "\n"); @@ -1130,7 +1134,8 @@ closure(int i) if (u->flag) (void) fprintf(foutput, "flag set!\n"); u->flag = 0; - (void) fprintf(foutput, "\t%ws", writem(u->pitem)); + (void) fprintf(foutput, WSFMT("\t%ws"), + writem(u->pitem)); prlook(&u->ws); (void) fprintf(foutput, "\n"); } diff --git a/usr/src/cmd/sgs/yacc/common/y2.c b/usr/src/cmd/sgs/yacc/common/y2.c index d8dfe019a1..3599d40904 100644 --- a/usr/src/cmd/sgs/yacc/common/y2.c +++ b/usr/src/cmd/sgs/yacc/common/y2.c @@ -272,10 +272,10 @@ char *argv[]; * Open y.output if -v is specified */ if (options & v_FLAG) { - strncpy(fname, + (void) strncpy(fname, file_prefix, F_NAME_LENGTH-strlen(".output")); - strcat(fname, ".output"); + (void) strcat(fname, ".output"); foutput = fopen(fname, "w"); if (foutput == NULL) error(gettext( @@ -286,10 +286,10 @@ char *argv[]; * Open y.tab.h if -d is specified */ if (options & d_FLAG) { - strncpy(fname, + (void) strncpy(fname, file_prefix, F_NAME_LENGTH-strlen(".tab.h")); - strcat(fname, ".tab.h"); + (void) strcat(fname, ".tab.h"); fdefine = fopen(fname, "w"); if (fdefine == NULL) error(gettext( @@ -308,10 +308,10 @@ char *argv[]; /* * Open y.tab.c */ - strncpy(fname, + (void) strncpy(fname, file_prefix, F_NAME_LENGTH-strlen(".tab.c")); - strcat(fname, ".tab.c"); + (void) strcat(fname, ".tab.c"); ftable = fopen(fname, "w"); if (ftable == NULL) error(gettext( @@ -1064,7 +1064,7 @@ defout() cp = tokset[i].name; if (*cp == L' ') /* literals */ { - (void) fprintf(fdebug, "\t\"%ws\",\t%d,\n", + (void) fprintf(fdebug, WSFMT("\t\"%ws\",\t%d,\n"), tokset[i].name + 1, tokset[i].value); continue; /* was cp++ */ } @@ -1078,14 +1078,14 @@ defout() } (void) fprintf(fdebug, - "\t\"%ws\",\t%d,\n", tokset[i].name, + WSFMT("\t\"%ws\",\t%d,\n"), tokset[i].name, tokset[i].value); (void) fprintf(ftable, - "# define %ws %d\n", tokset[i].name, + WSFMT("# define %ws %d\n"), tokset[i].name, tokset[i].value); if (fdefine != NULL) (void) fprintf(fdefine, - "# define %ws %d\n", + WSFMT("# define %ws %d\n"), tokset[i].name, tokset[i].value); @@ -1488,7 +1488,7 @@ swt: if (tok < 0) tok = fdtype(*prdptr[nprod]); (void) fprintf(faction, - ".%ws", typeset[tok]); + WSFMT(".%ws"), typeset[tok]); } goto loop; } @@ -1553,7 +1553,8 @@ swt: /* CSTYLED */ fdtype(prdptr[nprod][i]); (void) fprintf(faction, - ".%ws", typeset[tok]); + WSFMT(".%ws"), + typeset[tok]); } goto swt; } @@ -1563,7 +1564,7 @@ swt: * (Likely id with $ in.) * If non-terminal is added, remove it from the list. */ - fprintf(faction, "$%ws", tokname); + (void) fprintf(faction, WSFMT("$%ws"), tokname); /* * TRANSLATION_NOTE -- This is a message from yacc. * This message is passed to warning() function. @@ -1612,7 +1613,7 @@ swt: if (tok < 0) tok = fdtype(prdptr[nprod][j+offset]); (void) fprintf(faction, - ".%ws", typeset[tok]); + WSFMT(".%ws"), typeset[tok]); } goto swt; } @@ -1857,7 +1858,7 @@ lrprnt() /* print out the left and right hand sides */ else rhs = m_rhs; } - (void) fprintf(fdebug, "\t\"%ws :%ws\",\n", lhstext, rhs); + (void) fprintf(fdebug, WSFMT("\t\"%ws :%ws\",\n"), lhstext, rhs); if (m_rhs) free(m_rhs); } @@ -2090,6 +2091,6 @@ put_prefix_define(char *pre) int i; for (i = 0; syms[i]; i++) - fprintf(ftable, "#define\tyy%s\t%s%s\n", + (void) fprintf(ftable, "#define\tyy%s\t%s%s\n", syms[i], pre, syms[i]); } diff --git a/usr/src/cmd/sgs/yacc/common/y3.c b/usr/src/cmd/sgs/yacc/common/y3.c index 6213c9fe01..6cb3016370 100644 --- a/usr/src/cmd/sgs/yacc/common/y3.c +++ b/usr/src/cmd/sgs/yacc/common/y3.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -64,11 +63,11 @@ output() WSLOOP(u, v) { if (c == *(v->pitem)) putitem(v->pitem + 1, - (LOOKSETS *)0); + (LOOKSETS *)0); } temp1[c] = state(c); } else if (c > NTBASE && - temp1[(c -= NTBASE) + ntokens] == 0) { + temp1[(c -= NTBASE) + ntokens] == 0) { temp1[c + ntokens] = amem[indgo[i] + c]; } } @@ -89,15 +88,17 @@ output() * reduce/reduce * conflict */ + /* BEGIN CSTYLED */ if (foutput != NULL) (void) fprintf(foutput, - "\n%d: reduce/reduce conflict" - " (red'ns %d and %d ) on %ws", + WSFMT("\n%d: reduce/reduce conflict" + " (red'ns %d and %d ) on %ws"), i, -temp1[k], lastred, symnam(k)); if (-temp1[k] > lastred) temp1[k] = -lastred; ++zzrrconf; + /* END CSTYLED */ } else /* * potentia @@ -281,9 +282,10 @@ static void go2gen(int c) /* now, we have temp1[c] = 1 if a goto on c in closure of cc */ if (g2debug && foutput != NULL) { - (void) fprintf(foutput, "%ws: gotos on ", nontrst[c].name); + (void) fprintf(foutput, WSFMT("%ws: gotos on "), + nontrst[c].name); NTLOOP(i) if (temp1[i]) - (void) fprintf(foutput, "%ws ", nontrst[i].name); + (void) fprintf(foutput, WSFMT("%ws "), nontrst[i].name); (void) fprintf(foutput, "\n"); } @@ -321,9 +323,9 @@ precftn(int r, int t, int s) /* conflict */ if (foutput != NULL) (void) fprintf(foutput, - "\n%d: shift/reduce conflict" - " (shift %d, red'n %d) on %ws", - s, temp1[t], r, symnam(t)); + WSFMT("\n%d: shift/reduce conflict" + " (shift %d, red'n %d) on %ws"), + s, temp1[t], r, symnam(t)); ++zzsrconf; return; } @@ -408,11 +410,11 @@ wract(int i) if (flag++ == 0) (void) fprintf(ftable, "-1, %d,\n", i); (void) fprintf(ftable, - "\t%d, %d,\n", tokset[p0].value, p1); + "\t%d, %d,\n", tokset[p0].value, p1); ++zzexcp; } else { (void) fprintf(ftemp, - "%d,%d,", tokset[p0].value, p1); + "%d,%d,", tokset[p0].value, p1); ++zzacent; } } @@ -436,20 +438,20 @@ wrstate(int i) return; (void) fprintf(foutput, "\nstate %d\n", i); ITMLOOP(i, pp, qq) { - (void) fprintf(foutput, "\t%ws\n", writem(pp->pitem)); + (void) fprintf(foutput, WSFMT("\t%ws\n"), writem(pp->pitem)); } if (tystate[i] == MUSTLOOKAHEAD) { /* print out empty productions in closure */ WSLOOP(wsets + (pstate[i + 1] - pstate[i]), u) { if (*(u->pitem) < 0) (void) fprintf(foutput, - "\t%ws\n", writem(u->pitem)); + WSFMT("\t%ws\n"), writem(u->pitem)); } } /* check for state equal to another */ TLOOP(j0) if ((j1 = temp1[j0]) != 0) { - (void) fprintf(foutput, "\n\t%ws ", symnam(j0)); + (void) fprintf(foutput, WSFMT("\n\t%ws "), symnam(j0)); if (j1 > 0) { /* shift, error, or accept */ if (j1 == ACCEPTCODE) (void) fprintf(foutput, "accept"); @@ -473,8 +475,8 @@ wrstate(int i) for (j0 = 1; j0 <= nnonter; ++j0) { if (temp1[++j1]) (void) fprintf(foutput, - "\t%ws goto %d\n", - symnam(j0 + NTBASE), temp1[j1]); + WSFMT("\t%ws goto %d\n"), + symnam(j0 + NTBASE), temp1[j1]); } } @@ -482,7 +484,7 @@ static void wdef(wchar_t *s, int n) { /* output a definition of s to the value n */ - (void) fprintf(ftable, "# define %ws %d\n", s, n); + (void) fprintf(ftable, WSFMT("# define %ws %d\n"), s, n); } void @@ -491,7 +493,7 @@ wchar_t *s; int *v, n; { int i; - (void) fprintf(ftable, "static YYCONST yytabelem %ws[]={\n", s); + (void) fprintf(ftable, WSFMT("static YYCONST yytabelem %ws[]={\n"), s); for (i = 0; i < n; ) { if (i % 10 == 0) (void) fprintf(ftable, "\n"); @@ -522,8 +524,8 @@ hideprod() ++j; if (foutput != NULL) { (void) fprintf(foutput, - "Rule not reduced: %ws\n", - writem(prdptr[i])); + WSFMT("Rule not reduced: %ws\n"), + writem(prdptr[i])); } } levprd[i] = *prdptr[i] - NTBASE; @@ -533,9 +535,9 @@ hideprod() * TRANSLATION_NOTE -- This is a message from yacc. * Check how 'reduced' is translated in yacc man page/document. */ - (void) fprintf(stderr, gettext( - "%d rules never reduced\n"), - j); + (void) fprintf(stderr, + gettext("%d rules never reduced\n"), + j); } @@ -553,13 +555,13 @@ wrmbchars() int i; wdef(L"YYNMBCHARS", nmbchars); qsort(mbchars, nmbchars, sizeof (*mbchars), - (int (*)(const void *, const void *))cmpmbchars); + (int (*)(const void *, const void *))cmpmbchars); (void) fprintf(ftable, - "static struct{\n\twchar_t character;" - "\n\tint tvalue;\n}yymbchars[YYNMBCHARS]={\n"); + "static struct{\n\twchar_t character;" + "\n\tint tvalue;\n}yymbchars[YYNMBCHARS]={\n"); for (i = 0; i < nmbchars; ++i) { (void) fprintf(ftable, "\t{%#x,%d}", - (int)mbchars[i].character, mbchars[i].tvalue); + (int)mbchars[i].character, mbchars[i].tvalue); if (i < nmbchars - 1) { /* Not the last. */ (void) fprintf(ftable, ",\n"); diff --git a/usr/src/cmd/sgs/yacc/common/y4.c b/usr/src/cmd/sgs/yacc/common/y4.c index d6e967ab26..e9c6b60a62 100644 --- a/usr/src/cmd/sgs/yacc/common/y4.c +++ b/usr/src/cmd/sgs/yacc/common/y4.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -70,7 +69,7 @@ callopt() * tempfile can be translated as temporary file. */ error(gettext( - "optimizer cannot open tempfile")); + "optimizer cannot open tempfile")); optimmem = tracemem; pgo[0] = 0; @@ -260,7 +259,7 @@ gin(int i) pgo[i] = p - amem; if (adb > 1) (void) fprintf(ftable, - "Nonterminal %d, entry at %d\n", i, pgo[i]); + "Nonterminal %d, entry at %d\n", i, pgo[i]); goto nextgi; nextgp: @@ -319,14 +318,14 @@ stin(int i) */ goto nextn; if (temp1[j+1] + temp1[i] == - temp1[j] + temp1[i+1]) { + temp1[j] + temp1[i+1]) { /* states are equal */ indgo[i] = n; if (adb > 1) (void) fprintf(ftable, - "State %d: entry at" - " %d equals state %d\n", - i, n, j); + "State %d: entry at" + " %d equals state %d\n", + i, n, j); return; } goto nextn; /* we have some disagreement */ @@ -349,14 +348,14 @@ stin(int i) * Leave this untrasnlated. Yacc internal error. */ error(gettext( - "clobber of amem array, pos'n %d, by %d"), - s-amem, r[1]); + "clobber of amem array, pos'n %d, by %d"), + s-amem, r[1]); *s = r[1]; } indgo[i] = n; if (adb > 1) (void) fprintf(ftable, - "State %d: entry at %d\n", i, indgo[i]); + "State %d: entry at %d\n", i, indgo[i]); return; nextn:; } @@ -409,13 +408,13 @@ osummary() } (void) fprintf(foutput, - "Optimizer space used: input %" PRIdPTR - "/%d, output %" PRIdPTR "/%d\n", - optimmem-tracemem + 1, new_memsize, maxa-amem + 1, new_actsize); + "Optimizer space used: input %" PRIdPTR + "/%d, output %" PRIdPTR "/%d\n", + optimmem-tracemem + 1, new_memsize, maxa-amem + 1, new_actsize); (void) fprintf(foutput, - "%" PRIdPTR " table entries, %d zero\n", (maxa-amem) + 1, i); + "%" PRIdPTR " table entries, %d zero\n", (maxa-amem) + 1, i); (void) fprintf(foutput, - "maximum spread: %d, maximum offset: %d\n", maxspr, maxoff); + "maximum spread: %d, maximum offset: %d\n", maxspr, maxoff); } @@ -438,7 +437,7 @@ int *v, n; { int i; - (void) fprintf(ftable, "static YYCONST yytabelem %ws[]={\n", s); + (void) fprintf(ftable, WSFMT("static YYCONST yytabelem %ws[]={\n"), s); for (i = 0; i < n; ) { if (i % 10 == 0) (void) fprintf(ftable, "\n"); |
