CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Fri Jan 22 00:44:55 UTC 2021 Modified Files: src/usr.bin/make/unit-tests: include-main.mk Log Message: make(1): fix test for .INCLUDEDFROMFILE The test did not test the intended variable before. If the implementation of the .INCLUDEDFROMFILE had been wrong before, the test would have succeeded nevertheless since it tested whether the variable named "include-main.mk" was defined, which was obviously never the case since that's the value of the variable, not the name. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/include-main.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/include-main.mk diff -u src/usr.bin/make/unit-tests/include-main.mk:1.5 src/usr.bin/make/unit-tests/include-main.mk:1.6 --- src/usr.bin/make/unit-tests/include-main.mk:1.5 Sat Sep 5 18:18:05 2020 +++ src/usr.bin/make/unit-tests/include-main.mk Fri Jan 22 00:44:55 2021 @@ -1,4 +1,4 @@ -# $NetBSD: include-main.mk,v 1.5 2020/09/05 18:18:05 rillig Exp $ +# $NetBSD: include-main.mk,v 1.6 2021/01/22 00:44:55 rillig Exp $ # # Until 2020-09-05, the .INCLUDEDFROMFILE magic variable did not behave # as described in the manual page. @@ -17,7 +17,7 @@ .endif .for i in once -. if !defined(${.INCLUDEDFROMFILE}) +. if !defined(.INCLUDEDFROMFILE) .info main-before-for-ok . else .warning main-before-for-fail(${.INCLUDEDFROMFILE}) @@ -33,7 +33,7 @@ .endif .for i in once -. if !defined(${.INCLUDEDFROMFILE}) +. if !defined(.INCLUDEDFROMFILE) .info main-after-for-ok . else .warning main-after-for-fail(${.INCLUDEDFROMFILE})
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Jan 22 00:12:01 UTC 2021 Modified Files: src/usr.bin/make: cond.c src/usr.bin/make/unit-tests: cond-func-defined.exp cond-func.exp Log Message: make(1): remove "warning" from missing closing parenthesis This only affects the diagnostics for parse errors that involve a missing closing parenthesis. Whether or not this is a parse error is still the same. It may look redundant to pass both the CondParser and the parsing position pp to the functions, but that's necessary since during parsing, not every code path updates the main parsing position immediately. To generate a diff of this commit: cvs rdiff -u -r1.252 -r1.253 src/usr.bin/make/cond.c cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-func-defined.exp \ src/usr.bin/make/unit-tests/cond-func.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.252 src/usr.bin/make/cond.c:1.253 --- src/usr.bin/make/cond.c:1.252 Thu Jan 21 23:32:28 2021 +++ src/usr.bin/make/cond.c Fri Jan 22 00:12:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.252 2021/01/21 23:32:28 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.253 2021/01/22 00:12:01 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.252 2021/01/21 23:32:28 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.253 2021/01/22 00:12:01 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -228,7 +228,7 @@ CondParser_SkipWhitespace(CondParser *pa * Return the length of the argument, or 0 on error. */ static size_t -ParseFuncArg(const char **pp, Boolean doEval, const char *func, +ParseFuncArg(CondParser *par, const char **pp, Boolean doEval, const char *func, char **out_arg) { const char *p = *pp; @@ -288,10 +288,9 @@ ParseFuncArg(const char **pp, Boolean do cpp_skip_hspace(); if (func != NULL && *p++ != ')') { - Parse_Error(PARSE_WARNING, - "Missing closing parenthesis for %s()", - func); - /* The PARSE_FATAL follows in CondEvalExpression. */ + Parse_Error(PARSE_FATAL, + "Missing closing parenthesis for %s()", func); + par->printedError = TRUE; return 0; } @@ -731,8 +730,9 @@ done_lhs: */ /*ARGSUSED*/ static size_t -ParseEmptyArg(const char **pp, Boolean doEval, - const char *func MAKE_ATTR_UNUSED, char **out_arg) +ParseEmptyArg(CondParser *par MAKE_ATTR_UNUSED, const char **pp, + Boolean doEval, const char *func MAKE_ATTR_UNUSED, + char **out_arg) { FStr val; size_t magic_res; @@ -780,8 +780,8 @@ CondParser_Func(CondParser *par, Boolean static const struct fn_def { const char *fn_name; size_t fn_name_len; - size_t (*fn_parse)(const char **, Boolean, const char *, - char **); + size_t (*fn_parse)(CondParser *, const char **, Boolean, + const char *, char **); Boolean (*fn_eval)(size_t, const char *); } fns[] = { { "defined", 7, ParseFuncArg, FuncDefined }, @@ -806,7 +806,7 @@ CondParser_Func(CondParser *par, Boolean if (*cp != '(') break; - arglen = fn->fn_parse(, doEval, fn->fn_name, ); + arglen = fn->fn_parse(par, , doEval, fn->fn_name, ); if (arglen == 0 || arglen == (size_t)-1) { par->p = cp; *out_token = arglen == 0 ? TOK_FALSE : TOK_ERROR; @@ -852,7 +852,7 @@ CondParser_LeafToken(CondParser *par, Bo * syntax would be invalid if we did "defined(a)" - so instead treat * as an expression. */ - arglen = ParseFuncArg(, doEval, NULL, ); + arglen = ParseFuncArg(par, , doEval, NULL, ); cp1 = cp; cpp_skip_whitespace(); if (*cp1 == '=' || *cp1 == '!') Index: src/usr.bin/make/unit-tests/cond-func-defined.exp diff -u src/usr.bin/make/unit-tests/cond-func-defined.exp:1.5 src/usr.bin/make/unit-tests/cond-func-defined.exp:1.6 --- src/usr.bin/make/unit-tests/cond-func-defined.exp:1.5 Sun Nov 15 14:07:53 2020 +++ src/usr.bin/make/unit-tests/cond-func-defined.exp Fri Jan 22 00:12:01 2021 @@ -1,7 +1,5 @@ -make: "cond-func-defined.mk" line 23: warning: Missing closing parenthesis for defined() -make: "cond-func-defined.mk" line 23: Malformed conditional (!defined(A B)) -make: "cond-func-defined.mk" line 33: warning: Missing closing parenthesis for defined() -make: "cond-func-defined.mk" line 33: Malformed conditional (defined(DEF) +make: "cond-func-defined.mk" line 23: Missing closing parenthesis for defined() +make: "cond-func-defined.mk" line 33: Missing closing parenthesis for defined() make: "cond-func-defined.mk" line 45: In .for loops, variable expressions for the loop variables are make: "cond-func-defined.mk" line 46: substituted at evaluation time. There is no actual variable make: "cond-func-defined.mk" line 47: involved, even if it feels like it.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Jan 21 23:32:28 UTC 2021 Modified Files: src/usr.bin/make: cond.c src/usr.bin/make/unit-tests: cond-cmp-numeric.exp cond-cmp-string.exp cond-token-plain.exp cond1.exp Log Message: make(1): replace warning + error with just an error in conditionals Before, there was a "warning" for comparing strings using '<', which was wrong. That warning was then followed by an error, after parsing the whole conditional. This was only because it was easier to implement. Replace the warning with an actual error. This only affects conditionals in .if lines, the conditionals in the :? modifier such as ${"A" < "B":?smaller:greater} still print 2 errors. To generate a diff of this commit: cvs rdiff -u -r1.251 -r1.252 src/usr.bin/make/cond.c cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-cmp-numeric.exp cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-cmp-string.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-token-plain.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cond1.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.251 src/usr.bin/make/cond.c:1.252 --- src/usr.bin/make/cond.c:1.251 Thu Jan 21 23:25:08 2021 +++ src/usr.bin/make/cond.c Thu Jan 21 23:32:28 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.251 2021/01/21 23:25:08 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.252 2021/01/21 23:32:28 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.251 2021/01/21 23:25:08 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.252 2021/01/21 23:32:28 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -603,12 +603,13 @@ EvalCompareNum(double lhs, ComparisonOp } static Token -EvalCompareStr(const char *lhs, ComparisonOp op, const char *rhs) +EvalCompareStr(CondParser *par, const char *lhs, + ComparisonOp op, const char *rhs) { if (op != EQ && op != NE) { - Parse_Error(PARSE_WARNING, + Parse_Error(PARSE_FATAL, "String comparison operator must be either == or !="); - /* The PARSE_FATAL follows in CondEvalExpression. */ + par->printedError = TRUE; return TOK_ERROR; } @@ -619,8 +620,8 @@ EvalCompareStr(const char *lhs, Comparis /* Evaluate a comparison, such as "${VAR} == 12345". */ static Token -EvalCompare(const char *lhs, Boolean lhsQuoted, ComparisonOp op, - const char *rhs, Boolean rhsQuoted) +EvalCompare(CondParser *par, const char *lhs, Boolean lhsQuoted, + ComparisonOp op, const char *rhs, Boolean rhsQuoted) { double left, right; @@ -628,7 +629,7 @@ EvalCompare(const char *lhs, Boolean lhs if (TryParseNumber(lhs, ) && TryParseNumber(rhs, )) return ToToken(EvalCompareNum(left, op, right)); - return EvalCompareStr(lhs, op, rhs); + return EvalCompareStr(par, lhs, op, rhs); } static Boolean @@ -700,9 +701,9 @@ CondParser_Comparison(CondParser *par, B CondParser_SkipWhitespace(par); if (par->p[0] == '\0') { - Parse_Error(PARSE_WARNING, - "Missing right-hand-side of operator"); - /* The PARSE_FATAL follows in CondEvalExpression. */ + Parse_Error(PARSE_FATAL, + "Missing right-hand-side of operator '%s'", opname[op]); + par->printedError = TRUE; goto done_lhs; } @@ -715,7 +716,7 @@ CondParser_Comparison(CondParser *par, B goto done_rhs; } - t = EvalCompare(lhs.str, lhsQuoted, op, rhs.str, rhsQuoted); + t = EvalCompare(par, lhs.str, lhsQuoted, op, rhs.str, rhsQuoted); done_rhs: FStr_Done(); Index: src/usr.bin/make/unit-tests/cond-cmp-numeric.exp diff -u src/usr.bin/make/unit-tests/cond-cmp-numeric.exp:1.4 src/usr.bin/make/unit-tests/cond-cmp-numeric.exp:1.5 --- src/usr.bin/make/unit-tests/cond-cmp-numeric.exp:1.4 Thu Jan 21 23:25:08 2021 +++ src/usr.bin/make/unit-tests/cond-cmp-numeric.exp Thu Jan 21 23:32:28 2021 @@ -1,9 +1,7 @@ CondParser_Eval: !(${:UINF} > 1e100) -make: "cond-cmp-numeric.mk" line 11: warning: String comparison operator must be either == or != -make: "cond-cmp-numeric.mk" line 11: Malformed conditional (!(${:UINF} > 1e100)) +make: "cond-cmp-numeric.mk" line 11: String comparison operator must be either == or != CondParser_Eval: ${:UNaN} > NaN -make: "cond-cmp-numeric.mk" line 16: warning: String comparison operator must be either == or != -make: "cond-cmp-numeric.mk" line 16: Malformed conditional (${:UNaN} > NaN) +make: "cond-cmp-numeric.mk" line 16: String comparison operator must be either == or != CondParser_Eval: !(${:UNaN} == NaN) lhs = "NaN", rhs = "NaN", op = == CondParser_Eval: 123 ! 123 Index: src/usr.bin/make/unit-tests/cond-cmp-string.exp diff -u src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.10
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Jan 21 23:25:08 UTC 2021 Modified Files: src/usr.bin/make: cond.c src/usr.bin/make/unit-tests: cond-cmp-numeric-eq.exp cond-cmp-numeric.exp cond-cmp-string.exp cond-token-plain.exp Log Message: make(1): fix debug output for comparison operators in conditionals This produces fewer warnings than before, but these were edge cases that probably didn't matter in practice. The "Malformaed conditional" is still generated, the set of accepted conditionals is still the same. To generate a diff of this commit: cvs rdiff -u -r1.250 -r1.251 src/usr.bin/make/cond.c cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.exp \ src/usr.bin/make/unit-tests/cond-cmp-numeric.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-cmp-string.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-token-plain.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.250 src/usr.bin/make/cond.c:1.251 --- src/usr.bin/make/cond.c:1.250 Thu Jan 21 23:06:06 2021 +++ src/usr.bin/make/cond.c Thu Jan 21 23:25:08 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.250 2021/01/21 23:06:06 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.251 2021/01/21 23:25:08 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.250 2021/01/21 23:06:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.251 2021/01/21 23:25:08 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -137,6 +137,10 @@ typedef enum CondResult { CR_FALSE, CR_TRUE, CR_ERROR } CondResult; +typedef enum ComparisonOp { + LT, LE, GT, GE, EQ, NE +} ComparisonOp; + typedef struct CondParser { /* @@ -167,6 +171,8 @@ static CondResult CondParser_Or(CondPars static unsigned int cond_depth = 0; /* current .if nesting level */ static unsigned int cond_min_depth = 0; /* depth at makefile open */ +static const char *opname[] = { "<", "<=", ">", ">=", "==", "!=" }; + /* * Indicate when we should be strict about lhs of comparisons. * In strict mode, the lhs must be a variable expression or a string literal @@ -575,65 +581,90 @@ EvalNotEmpty(CondParser *par, const char } /* Evaluate a numerical comparison, such as in ".if ${VAR} >= 9". */ -static Token -EvalCompareNum(double lhs, const char *op, double rhs) +static Boolean +EvalCompareNum(double lhs, ComparisonOp op, double rhs) { - /* FIXME: %2.s is cheated and produces wrong output. */ - DEBUG3(COND, "lhs = %f, rhs = %f, op = %.2s\n", lhs, rhs, op); + DEBUG3(COND, "lhs = %f, rhs = %f, op = %.2s\n", lhs, rhs, opname[op]); - switch (op[0]) { - case '!': - if (op[1] != '=') { - Parse_Error(PARSE_WARNING, "Unknown operator"); - /* The PARSE_FATAL follows in CondEvalExpression. */ - return TOK_ERROR; - } - return ToToken(lhs != rhs); - case '=': - if (op[1] != '=') { - Parse_Error(PARSE_WARNING, "Unknown operator"); - /* The PARSE_FATAL follows in CondEvalExpression. */ - return TOK_ERROR; - } - return ToToken(lhs == rhs); - case '<': - return ToToken(op[1] == '=' ? lhs <= rhs : lhs < rhs); - case '>': - return ToToken(op[1] == '=' ? lhs >= rhs : lhs > rhs); + switch (op) { + case LT: + return lhs < rhs; + case LE: + return lhs <= rhs; + case GT: + return lhs > rhs; + case GE: + return lhs >= rhs; + case NE: + return lhs != rhs; + default: + return lhs == rhs; } - return TOK_ERROR; } static Token -EvalCompareStr(const char *lhs, const char *op, const char *rhs) +EvalCompareStr(const char *lhs, ComparisonOp op, const char *rhs) { - if (!((op[0] == '!' || op[0] == '=') && op[1] == '=')) { + if (op != EQ && op != NE) { Parse_Error(PARSE_WARNING, - "String comparison operator " - "must be either == or !="); + "String comparison operator must be either == or !="); /* The PARSE_FATAL follows in CondEvalExpression. */ return TOK_ERROR; } - /* FIXME: %2.s is cheated and produces wrong output. */ - DEBUG3(COND, "lhs = \"%s\", rhs = \"%s\", op = %.2s\n", lhs, rhs, op); - return ToToken((*op == '=') == (strcmp(lhs, rhs) == 0)); + DEBUG3(COND, "lhs = \"%s\", rhs = \"%s\", op = %.2s\n", + lhs, rhs, opname[op]); + return ToToken((op == EQ) == (strcmp(lhs, rhs) == 0)); } /* Evaluate a comparison, such as "${VAR} == 12345". */ static Token -EvalCompare(const char *lhs, Boolean lhsQuoted, const char *op, +EvalCompare(const char *lhs, Boolean lhsQuoted, ComparisonOp op, const char *rhs, Boolean rhsQuoted) { double left, right; if (!rhsQuoted && !lhsQuoted) if (TryParseNumber(lhs, ) && TryParseNumber(rhs, )) - return EvalCompareNum(left, op, right); + return ToToken(EvalCompareNum(left, op, right));
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Jan 21 23:06:06 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): document wrong debug output in evaluation of conditionals To generate a diff of this commit: cvs rdiff -u -r1.249 -r1.250 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.249 src/usr.bin/make/cond.c:1.250 --- src/usr.bin/make/cond.c:1.249 Thu Jan 21 22:54:13 2021 +++ src/usr.bin/make/cond.c Thu Jan 21 23:06:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.249 2021/01/21 22:54:13 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.250 2021/01/21 23:06:06 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.249 2021/01/21 22:54:13 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.250 2021/01/21 23:06:06 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -578,6 +578,7 @@ EvalNotEmpty(CondParser *par, const char static Token EvalCompareNum(double lhs, const char *op, double rhs) { + /* FIXME: %2.s is cheated and produces wrong output. */ DEBUG3(COND, "lhs = %f, rhs = %f, op = %.2s\n", lhs, rhs, op); switch (op[0]) { @@ -614,6 +615,7 @@ EvalCompareStr(const char *lhs, const ch return TOK_ERROR; } + /* FIXME: %2.s is cheated and produces wrong output. */ DEBUG3(COND, "lhs = \"%s\", rhs = \"%s\", op = %.2s\n", lhs, rhs, op); return ToToken((*op == '=') == (strcmp(lhs, rhs) == 0)); }
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Thu Jan 21 23:03:41 UTC 2021 Modified Files: src/usr.bin/make/unit-tests: directive-ifdef.exp directive-ifdef.mk Log Message: make(1): add tests for string literals in .ifdef To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-ifdef.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-ifdef.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/directive-ifdef.exp diff -u src/usr.bin/make/unit-tests/directive-ifdef.exp:1.2 src/usr.bin/make/unit-tests/directive-ifdef.exp:1.3 --- src/usr.bin/make/unit-tests/directive-ifdef.exp:1.2 Sun Nov 8 22:38:28 2020 +++ src/usr.bin/make/unit-tests/directive-ifdef.exp Thu Jan 21 23:03:41 2021 @@ -1,2 +1,4 @@ make: "directive-ifdef.mk" line 12: Function calls in .ifdef are possible. +make: "directive-ifdef.mk" line 23: String literals are tested for emptiness. +make: "directive-ifdef.mk" line 27: String literals are tested for emptiness. Whitespace is non-empty. exit status 0 Index: src/usr.bin/make/unit-tests/directive-ifdef.mk diff -u src/usr.bin/make/unit-tests/directive-ifdef.mk:1.3 src/usr.bin/make/unit-tests/directive-ifdef.mk:1.4 --- src/usr.bin/make/unit-tests/directive-ifdef.mk:1.3 Sun Nov 8 22:38:28 2020 +++ src/usr.bin/make/unit-tests/directive-ifdef.mk Thu Jan 21 23:03:41 2021 @@ -1,4 +1,4 @@ -# $NetBSD: directive-ifdef.mk,v 1.3 2020/11/08 22:38:28 rillig Exp $ +# $NetBSD: directive-ifdef.mk,v 1.4 2021/01/21 23:03:41 rillig Exp $ # # Tests for the .ifdef directive. @@ -14,5 +14,20 @@ DEFINED= defined . error .endif +# String literals are handled the same in all variants of the .if directive. +# They evaluate to true if they are not empty. Whitespace counts as non-empty +# as well. +.ifdef "" +. error +.else +. info String literals are tested for emptiness. +.endif + +.ifdef " " +. info String literals are tested for emptiness. Whitespace is non-empty. +.else +. error +.endif + all: @:;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Jan 21 22:54:13 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): reformat CondParser_StringExpr To generate a diff of this commit: cvs rdiff -u -r1.248 -r1.249 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.248 src/usr.bin/make/cond.c:1.249 --- src/usr.bin/make/cond.c:1.248 Thu Jan 21 14:24:25 2021 +++ src/usr.bin/make/cond.c Thu Jan 21 22:54:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.248 2021/01/21 14:24:25 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.249 2021/01/21 22:54:13 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.248 2021/01/21 14:24:25 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.249 2021/01/21 22:54:13 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -415,10 +415,9 @@ CondParser_StringExpr(CondParser *par, c VarParseResult parseResult; /* if we are in quotes, an undefined variable is ok */ - eflags = - doEval && !quoted ? VARE_WANTRES | VARE_UNDEFERR : - doEval ? VARE_WANTRES : - VARE_NONE; + eflags = doEval && !quoted ? VARE_WANTRES | VARE_UNDEFERR + : doEval ? VARE_WANTRES + : VARE_NONE; nested_p = par->p; atStart = nested_p == start; @@ -427,23 +426,21 @@ CondParser_StringExpr(CondParser *par, c if (inout_str->str == var_Error) { if (parseResult == VPR_ERR) { /* - * FIXME: Even if an error occurs, - * there is no guarantee that it is - * reported. + * FIXME: Even if an error occurs, there is no + * guarantee that it is reported. * * See cond-token-plain.mk . */ par->printedError = TRUE; } /* - * XXX: Can there be any situation in which - * a returned var_Error requires freeIt? + * XXX: Can there be any situation in which a returned + * var_Error requires freeIt? */ FStr_Done(inout_str); /* - * Even if !doEval, we still report syntax - * errors, which is what getting var_Error - * back with !doEval means. + * Even if !doEval, we still report syntax errors, which is + * what getting var_Error back with !doEval means. */ *inout_str = FStr_InitRefer(NULL); return FALSE; @@ -451,10 +448,9 @@ CondParser_StringExpr(CondParser *par, c par->p = nested_p; /* - * If the '$' started the string literal (which means - * no quotes), and the variable expression is followed - * by a space, looks like a comparison operator or is - * the end of the expression, we are done. + * If the '$' started the string literal (which means no quotes), and + * the variable expression is followed by a space, looks like a + * comparison operator or is the end of the expression, we are done. */ if (atStart && is_separator(par->p[0])) return FALSE;
CVS commit: src/sys/dev/wscons
Module Name:src Committed By: macallan Date: Thu Jan 21 21:45:42 UTC 2021 Modified Files: src/sys/dev/wscons: wsdisplay_vcons.c wsdisplay_vconsvar.h Log Message: introduce a putchar() based implementation of cursor() in order to avoid framebuffer reads quite a speedup on arm64 / genfb To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/dev/wscons/wsdisplay_vcons.c cvs rdiff -u -r1.30 -r1.31 src/sys/dev/wscons/wsdisplay_vconsvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/wscons/wsdisplay_vcons.c diff -u src/sys/dev/wscons/wsdisplay_vcons.c:1.47 src/sys/dev/wscons/wsdisplay_vcons.c:1.48 --- src/sys/dev/wscons/wsdisplay_vcons.c:1.47 Sun Jan 17 19:03:32 2021 +++ src/sys/dev/wscons/wsdisplay_vcons.c Thu Jan 21 21:45:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: wsdisplay_vcons.c,v 1.47 2021/01/17 19:03:32 jmcneill Exp $ */ +/* $NetBSD: wsdisplay_vcons.c,v 1.48 2021/01/21 21:45:42 macallan Exp $ */ /*- * Copyright (c) 2005, 2006 Michael Lorenz @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.47 2021/01/17 19:03:32 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.48 2021/01/21 21:45:42 macallan Exp $"); #include #include @@ -103,6 +103,7 @@ static void vcons_eraserows_cached(void static void vcons_putchar_cached(void *, int, int, u_int, long); #endif static void vcons_cursor(void *, int, int, int); +static void vcons_cursor_noread(void *, int, int, int); /* * methods that avoid framebuffer reads @@ -352,7 +353,12 @@ vcons_init_screen(struct vcons_data *vd, ri->ri_ops.eraserows = vcons_eraserows; ri->ri_ops.erasecols = vcons_erasecols; ri->ri_ops.putchar = vcons_putchar; - ri->ri_ops.cursor= vcons_cursor; + if (scr->scr_flags & VCONS_NO_CURSOR) { + ri->ri_ops.cursor= vcons_cursor_noread; + } else { + ri->ri_ops.cursor= vcons_cursor; + } + ri->ri_ops.copycols = vcons_copycols; ri->ri_ops.copyrows = vcons_copyrows; @@ -469,7 +475,10 @@ vcons_load_font(void *v, void *cookie, s ri->ri_ops.eraserows = vcons_eraserows; ri->ri_ops.erasecols = vcons_erasecols; ri->ri_ops.putchar = vcons_putchar; - ri->ri_ops.cursor= vcons_cursor; + if (scr->scr_flags & VCONS_NO_CURSOR) { + ri->ri_ops.cursor= vcons_cursor_noread; + } else + ri->ri_ops.cursor= vcons_cursor; ri->ri_ops.copycols = vcons_copycols; ri->ri_ops.copyrows = vcons_copyrows; vcons_unlock(vd->active); @@ -609,8 +618,8 @@ vcons_redraw_screen(struct vcons_screen if (c == ' ') { /* * if we already erased the background - * and this blank uses the same colour - * and flags we don't need to do + * and if this blank uses the same + * colour and flags we don't need to do * anything here */ if (acmp == cmp && start == -1) @@ -1301,6 +1310,60 @@ vcons_cursor(void *cookie, int on, int r vcons_unlock(scr); } +static void +vcons_cursor_noread(void *cookie, int on, int row, int col) +{ + struct rasops_info *ri = cookie; + struct vcons_screen *scr = ri->ri_hw; + int offset = 0; + +#if defined(VCONS_DRAW_INTR) + if (scr->scr_vd->use_intr) { + vcons_lock(scr); + if (scr->scr_ri.ri_crow != row || scr->scr_ri.ri_ccol != col) { + scr->scr_ri.ri_crow = row; + scr->scr_ri.ri_ccol = col; + atomic_inc_uint(>scr_dirty); + } + vcons_unlock(scr); + return; + } +#endif + + vcons_lock(scr); + +#ifdef WSDISPLAY_SCROLLSUPPORT + offset = scr->scr_current_offset; +#endif + if (SCREEN_IS_VISIBLE(scr) && SCREEN_CAN_DRAW(scr)) { + int ofs = offset + ri->ri_crow * ri->ri_cols + ri->ri_ccol; + if (ri->ri_flg & RI_CURSOR) { + scr->putchar(cookie, ri->ri_crow, ri->ri_ccol, + scr->scr_chars[ofs], scr->scr_attrs[ofs]); + ri->ri_flg &= ~RI_CURSOR; + } + ri->ri_crow = row; + ri->ri_ccol = col; + ofs = offset + ri->ri_crow * ri->ri_cols + ri->ri_ccol; + if (on) { + scr->putchar(cookie, row, col, scr->scr_chars[ofs], +#ifdef VCONS_DEBUG_CURSOR_NOREAD + /* draw a red cursor so we can tell which cursor() + * implementation is being used */ + ((scr->scr_attrs[ofs] & 0xff00) ^ 0x0f00) | + 0x0001); +#else + scr->scr_attrs[ofs] ^ 0x0f0f); +#endif + ri->ri_flg |= RI_CURSOR; + } + } else { + scr->scr_ri.ri_crow = row; + scr->scr_ri.ri_ccol = col; + } + vcons_unlock(scr); +} + /* methods to read/write characters via ioctl() */ static int Index: src/sys/dev/wscons/wsdisplay_vconsvar.h diff -u src/sys/dev/wscons/wsdisplay_vconsvar.h:1.30 src/sys/dev/wscons/wsdisplay_vconsvar.h:1.31 --- src/sys/dev/wscons/wsdisplay_vconsvar.h:1.30 Sun Jan 17 19:03:32 2021 +++ src/sys/dev/wscons/wsdisplay_vconsvar.h Thu Jan 21 21:45:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: wsdisplay_vconsvar.h,v 1.30 2021/01/17 19:03:32 jmcneill Exp $ */ +/* $NetBSD: wsdisplay_vconsvar.h,v 1.31 2021/01/21 21:45:42 macallan Exp $ */
CVS commit: src/sys/dev/pci
Module Name:src Committed By: reinoud Date: Thu Jan 21 20:48:33 UTC 2021 Modified Files: src/sys/dev/pci: virtio_pci.c Log Message: Remove dependency on bus_space_write_8() for i386 and instead implement it as two bus_space_write_4()'s as allowed in the spec. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/pci/virtio_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/virtio_pci.c diff -u src/sys/dev/pci/virtio_pci.c:1.17 src/sys/dev/pci/virtio_pci.c:1.18 --- src/sys/dev/pci/virtio_pci.c:1.17 Thu Jan 21 08:17:13 2021 +++ src/sys/dev/pci/virtio_pci.c Thu Jan 21 20:48:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: virtio_pci.c,v 1.17 2021/01/21 08:17:13 martin Exp $ */ +/* $NetBSD: virtio_pci.c,v 1.18 2021/01/21 20:48:33 reinoud Exp $ */ /* * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.17 2021/01/21 08:17:13 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.18 2021/01/21 20:48:33 reinoud Exp $"); #include #include @@ -727,6 +727,14 @@ virtio_pci_read_queue_size_10(struct vir return bus_space_read_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_SIZE); } +/* + * By definition little endian only in v1.0 and 8 byters are allowed to be + * written as two 4 byters + */ +#define bus_space_write_le_8(iot, ioh, reg, val) \ + bus_space_write_4(iot, ioh, reg, ((uint64_t) (val)) & 0x); \ + bus_space_write_4(iot, ioh, reg + 4, ((uint64_t) (val)) >> 32); + static void virtio_pci_setup_queue_10(struct virtio_softc *sc, uint16_t idx, uint64_t addr) { @@ -739,15 +747,15 @@ virtio_pci_setup_queue_10(struct virtio_ bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_SELECT, vq->vq_index); if (addr == 0) { bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_ENABLE, 0); - bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_DESC, 0); - bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_AVAIL, 0); - bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_USED, 0); + bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_DESC, 0); + bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_AVAIL, 0); + bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_USED, 0); } else { - bus_space_write_8(iot, ioh, + bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_DESC, addr); - bus_space_write_8(iot, ioh, + bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_AVAIL, addr + vq->vq_availoffset); - bus_space_write_8(iot, ioh, + bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_USED, addr + vq->vq_usedoffset); bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_ENABLE, 1); @@ -763,6 +771,7 @@ virtio_pci_setup_queue_10(struct virtio_ VIRTIO_CONFIG1_QUEUE_MSIX_VECTOR, vec); } } +#undef bus_space_write_le_8 static void virtio_pci_set_status_10(struct virtio_softc *sc, int status)
CVS commit: src/sys/kern
Module Name:src Committed By: jdolecek Date: Thu Jan 21 19:37:23 UTC 2021 Modified Files: src/sys/kern: kern_event.c Log Message: remove stray debug #define DEBUG To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/sys/kern/kern_event.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_event.c diff -u src/sys/kern/kern_event.c:1.112 src/sys/kern/kern_event.c:1.113 --- src/sys/kern/kern_event.c:1.112 Thu Jan 21 18:09:23 2021 +++ src/sys/kern/kern_event.c Thu Jan 21 19:37:23 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_event.c,v 1.112 2021/01/21 18:09:23 jdolecek Exp $ */ +/* $NetBSD: kern_event.c,v 1.113 2021/01/21 19:37:23 jdolecek Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.112 2021/01/21 18:09:23 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.113 2021/01/21 19:37:23 jdolecek Exp $"); #include #include @@ -1322,7 +1322,6 @@ doneunlock: return (error); } -#define DEBUG #if defined(DEBUG) #define KN_FMT(buf, kn) \ (snprintb((buf), sizeof(buf), __KN_FLAG_BITS, (kn)->kn_status), buf)
CVS commit: src/sys/kern
Module Name:src Committed By: jdolecek Date: Thu Jan 21 18:09:23 UTC 2021 Modified Files: src/sys/kern: kern_event.c Log Message: adjust kq_check() (enabled with DEBUG) to new reality - it's now perfectly normal to have kq_count bigger than number of the linked entries on the kqueue PR kern/50094, problem pointed out by Chuck Silvers To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/sys/kern/kern_event.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_event.c diff -u src/sys/kern/kern_event.c:1.111 src/sys/kern/kern_event.c:1.112 --- src/sys/kern/kern_event.c:1.111 Wed Jan 20 21:39:09 2021 +++ src/sys/kern/kern_event.c Thu Jan 21 18:09:23 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_event.c,v 1.111 2021/01/20 21:39:09 jdolecek Exp $ */ +/* $NetBSD: kern_event.c,v 1.112 2021/01/21 18:09:23 jdolecek Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.111 2021/01/20 21:39:09 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.112 2021/01/21 18:09:23 jdolecek Exp $"); #include #include @@ -1322,6 +1322,7 @@ doneunlock: return (error); } +#define DEBUG #if defined(DEBUG) #define KN_FMT(buf, kn) \ (snprintb((buf), sizeof(buf), __KN_FLAG_BITS, (kn)->kn_status), buf) @@ -1356,7 +1357,10 @@ kqueue_check(const char *func, size_t li } count++; if (count > kq->kq_count) { -goto bad; +panic("%s,%zu: kq=%p kq->kq_count(%d) != " +"count(%d), nmarker=%d", + func, line, kq, kq->kq_count, count, +nmarker); } } else { nmarker++; @@ -1370,11 +1374,6 @@ kqueue_check(const char *func, size_t li #endif } } - if (kq->kq_count != count) { -bad: - panic("%s,%zu: kq=%p kq->kq_count(%d) != count(%d), nmarker=%d", - func, line, kq, kq->kq_count, count, nmarker); - } } #define kq_check(a) kqueue_check(__func__, __LINE__, (a)) #else /* defined(DEBUG) */
CVS commit: src/share/misc
Module Name:src Committed By: kamil Date: Thu Jan 21 18:09:10 UTC 2021 Modified Files: src/share/misc: acronyms.comp Log Message: Add SRTP (Secure Real-time Transport Protocol) To generate a diff of this commit: cvs rdiff -u -r1.318 -r1.319 src/share/misc/acronyms.comp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/misc/acronyms.comp diff -u src/share/misc/acronyms.comp:1.318 src/share/misc/acronyms.comp:1.319 --- src/share/misc/acronyms.comp:1.318 Thu Jan 21 17:58:56 2021 +++ src/share/misc/acronyms.comp Thu Jan 21 18:09:10 2021 @@ -1,4 +1,4 @@ -$NetBSD: acronyms.comp,v 1.318 2021/01/21 17:58:56 kamil Exp $ +$NetBSD: acronyms.comp,v 1.319 2021/01/21 18:09:10 kamil Exp $ 3WHS three-way handshake 8VSB 8-state vestigial side band modulation AA anti-aliasing @@ -1548,6 +1548,7 @@ SRAM static random access memory SRC sample rate conversion SRP SCSI RDMA protocol SRR shaped round robin +SRTP Secure Real-time Transport Protocol SS self-snoop SS stack segment SSA static single assignment
CVS commit: src/share/misc
Module Name:src Committed By: kamil Date: Thu Jan 21 17:58:56 UTC 2021 Modified Files: src/share/misc: acronyms.comp Log Message: Add RTP (Real-time Transport Protocol) To generate a diff of this commit: cvs rdiff -u -r1.317 -r1.318 src/share/misc/acronyms.comp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/misc/acronyms.comp diff -u src/share/misc/acronyms.comp:1.317 src/share/misc/acronyms.comp:1.318 --- src/share/misc/acronyms.comp:1.317 Thu Jan 21 17:53:05 2021 +++ src/share/misc/acronyms.comp Thu Jan 21 17:58:56 2021 @@ -1,4 +1,4 @@ -$NetBSD: acronyms.comp,v 1.317 2021/01/21 17:53:05 kamil Exp $ +$NetBSD: acronyms.comp,v 1.318 2021/01/21 17:58:56 kamil Exp $ 3WHS three-way handshake 8VSB 8-state vestigial side band modulation AA anti-aliasing @@ -1385,6 +1385,7 @@ RTL register transfer language RTL resistor-transistor logic RTL right to left RTOS real time operating system +RTP Real-time Transport Protocol RTS request to send RTT round trip time RUP rational unified process
CVS commit: src/share/misc
Module Name:src Committed By: kamil Date: Thu Jan 21 17:53:05 UTC 2021 Modified Files: src/share/misc: acronyms.comp Log Message: Add PBX (private branch exchange) To generate a diff of this commit: cvs rdiff -u -r1.316 -r1.317 src/share/misc/acronyms.comp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/misc/acronyms.comp diff -u src/share/misc/acronyms.comp:1.316 src/share/misc/acronyms.comp:1.317 --- src/share/misc/acronyms.comp:1.316 Tue Nov 17 19:56:42 2020 +++ src/share/misc/acronyms.comp Thu Jan 21 17:53:05 2021 @@ -1,4 +1,4 @@ -$NetBSD: acronyms.comp,v 1.316 2020/11/17 19:56:42 maya Exp $ +$NetBSD: acronyms.comp,v 1.317 2021/01/21 17:53:05 kamil Exp $ 3WHS three-way handshake 8VSB 8-state vestigial side band modulation AA anti-aliasing @@ -1156,6 +1156,7 @@ PAX portable archive exchange PBE pending break encoding PBE programming by example PBR partition boot record +PBX private branch exchange PC personal computer PC program counter PCB printed circuit board
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: nia Date: Thu Jan 21 17:46:28 UTC 2021 Modified Files: src/sys/arch/evbarm/conf: GENERIC64 Log Message: add vcaudio (intentionally this time) gives working audio output on rpi3 without needing to run a 32-bit image. To generate a diff of this commit: cvs rdiff -u -r1.173 -r1.174 src/sys/arch/evbarm/conf/GENERIC64 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/conf/GENERIC64 diff -u src/sys/arch/evbarm/conf/GENERIC64:1.173 src/sys/arch/evbarm/conf/GENERIC64:1.174 --- src/sys/arch/evbarm/conf/GENERIC64:1.173 Thu Jan 21 06:57:26 2021 +++ src/sys/arch/evbarm/conf/GENERIC64 Thu Jan 21 17:46:28 2021 @@ -1,5 +1,5 @@ # -# $NetBSD: GENERIC64,v 1.173 2021/01/21 06:57:26 nia Exp $ +# $NetBSD: GENERIC64,v 1.174 2021/01/21 17:46:28 nia Exp $ # # GENERIC ARM (aarch64) kernel # @@ -381,6 +381,10 @@ spi* at spibus? m25p* at spi? spiflash* at spiflashbus? +# Broadcom VCHIQ, etc +vchiq0 at fdt? +vcaudio0 at vchiq0 + # Audio support hdaudio* at fdt? # Intel HDA hdaudio* at pci? dev ? function ?
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Thu Jan 21 17:33:55 UTC 2021 Modified Files: src/sys/kern: kern_entropy.c Log Message: entropy: Reduce `no seed from bootloader' message to debug level. This does not necessarily indicate a problem -- only x86 and arm pass a seed from the bootloader anyway -- so it makes for an always-on warning on some platforms, including all rump kernels, which is not helpful. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/kern/kern_entropy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_entropy.c diff -u src/sys/kern/kern_entropy.c:1.28 src/sys/kern/kern_entropy.c:1.29 --- src/sys/kern/kern_entropy.c:1.28 Sat Jan 16 02:21:26 2021 +++ src/sys/kern/kern_entropy.c Thu Jan 21 17:33:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_entropy.c,v 1.28 2021/01/16 02:21:26 riastradh Exp $ */ +/* $NetBSD: kern_entropy.c,v 1.29 2021/01/21 17:33:55 riastradh Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -75,7 +75,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.28 2021/01/16 02:21:26 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.29 2021/01/21 17:33:55 riastradh Exp $"); #include #include @@ -378,7 +378,7 @@ entropy_init(void) /* Note if the bootloader didn't provide a seed. */ if (!E->seeded) - printf("entropy: no seed from bootloader\n"); + aprint_debug("entropy: no seed from bootloader\n"); /* Allocate the per-CPU records for all early entropy sources. */ LIST_FOREACH(rs, >sources, list)
CVS commit: src/share/man/man9
Module Name:src Committed By: wiz Date: Thu Jan 21 17:05:51 UTC 2021 Modified Files: src/share/man/man9: strlist.9 Log Message: Quote minus. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/share/man/man9/strlist.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/strlist.9 diff -u src/share/man/man9/strlist.9:1.2 src/share/man/man9/strlist.9:1.3 --- src/share/man/man9/strlist.9:1.2 Thu Jan 21 16:57:52 2021 +++ src/share/man/man9/strlist.9 Thu Jan 21 17:05:50 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: strlist.9,v 1.2 2021/01/21 16:57:52 wiz Exp $ +.\" $NetBSD: strlist.9,v 1.3 2021/01/21 17:05:50 wiz Exp $ .\" .\" Copyright (c) 2021 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -122,7 +122,7 @@ to compare strings, allowing for wildcar .Fa pattern . .It Fn strlist_index "const char *sl" "size_t slsize" "const char *str" Returns the index of the specified string if it appears in the -string list, or -1 if the string does not appear in the string list. +string list, or \-1 if the string does not appear in the string list. .It Fn strlist_append "char **slp" "size_t *slsizep" "const char *str" Appends a copy of the specified string to the stringlist. Begin by initializing
CVS commit: src/share/man/man9
Module Name:src Committed By: wiz Date: Thu Jan 21 16:57:53 UTC 2021 Modified Files: src/share/man/man9: strlist.9 Log Message: Use Nm instead of xref to itself. Fix typo. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/share/man/man9/strlist.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/strlist.9 diff -u src/share/man/man9/strlist.9:1.1 src/share/man/man9/strlist.9:1.2 --- src/share/man/man9/strlist.9:1.1 Thu Jan 21 15:53:16 2021 +++ src/share/man/man9/strlist.9 Thu Jan 21 16:57:52 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: strlist.9,v 1.1 2021/01/21 15:53:16 thorpej Exp $ +.\" $NetBSD: strlist.9,v 1.2 2021/01/21 16:57:52 wiz Exp $ .\" .\" Copyright (c) 2021 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -186,7 +186,7 @@ is_pc_printer_port(const char *pnp_id_li } .Ed .Pp -The folowing example converts an array of strings to a string list using +The following example converts an array of strings to a string list using .Fn strlist_append : .Bd -literal char * @@ -213,6 +213,6 @@ string_array_to_string_list(const char * .Xr pmatch 9 .Sh HISTORY The -.Xr strlist 9 +.Nm functions first appeared in .Nx 10.0 .
CVS commit: src
Module Name:src Committed By: thorpej Date: Thu Jan 21 15:53:16 UTC 2021 Modified Files: src/distrib/sets/lists/comp: mi src/share/man/man9: Makefile Added Files: src/share/man/man9: strlist.9 Log Message: Add a manual page for strlist(9). To generate a diff of this commit: cvs rdiff -u -r1.2371 -r1.2372 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.453 -r1.454 src/share/man/man9/Makefile cvs rdiff -u -r0 -r1.1 src/share/man/man9/strlist.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.2371 src/distrib/sets/lists/comp/mi:1.2372 --- src/distrib/sets/lists/comp/mi:1.2371 Sun Jan 17 19:32:52 2021 +++ src/distrib/sets/lists/comp/mi Thu Jan 21 15:53:15 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.2371 2021/01/17 19:32:52 rillig Exp $ +# $NetBSD: mi,v 1.2372 2021/01/21 15:53:15 thorpej Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. ./etc/mtree/set.compcomp-sys-root @@ -12227,6 +12227,14 @@ ./usr/share/man/cat9/sprintf.0 comp-obsolete obsolete ./usr/share/man/cat9/stathz.0 comp-sys-catman .cat ./usr/share/man/cat9/store.0 comp-obsolete obsolete +./usr/share/man/cat9/strlist.0 comp-sys-catman .cat +./usr/share/man/cat9/strlist_append.0 comp-sys-catman .cat +./usr/share/man/cat9/strlist_count.0 comp-sys-catman .cat +./usr/share/man/cat9/strlist_index.0 comp-sys-catman .cat +./usr/share/man/cat9/strlist_match.0 comp-sys-catman .cat +./usr/share/man/cat9/strlist_next.0 comp-sys-catman .cat +./usr/share/man/cat9/strlist_pmatch.0 comp-sys-catman .cat +./usr/share/man/cat9/strlist_string.0 comp-sys-catman .cat ./usr/share/man/cat9/subyte.0 comp-obsolete obsolete ./usr/share/man/cat9/suibyte.0 comp-obsolete obsolete ./usr/share/man/cat9/suiword.0 comp-obsolete obsolete @@ -20361,6 +20369,14 @@ ./usr/share/man/html9/sprintf.html comp-obsolete obsolete ./usr/share/man/html9/stathz.html comp-sys-htmlman html ./usr/share/man/html9/store.html comp-obsolete obsolete +./usr/share/man/html9/strlist.html comp-sys-htmlman html +./usr/share/man/html9/strlist_append.html comp-sys-htmlman html +./usr/share/man/html9/strlist_count.html comp-sys-htmlman html +./usr/share/man/html9/strlist_index.html comp-sys-htmlman html +./usr/share/man/html9/strlist_match.html comp-sys-htmlman html +./usr/share/man/html9/strlist_next.html comp-sys-htmlman html +./usr/share/man/html9/strlist_pmatch.html comp-sys-htmlman html +./usr/share/man/html9/strlist_string.html comp-sys-htmlman html ./usr/share/man/html9/subyte.html comp-obsolete obsolete ./usr/share/man/html9/suibyte.html comp-obsolete obsolete ./usr/share/man/html9/suiword.html comp-obsolete obsolete @@ -28693,6 +28709,14 @@ ./usr/share/man/man9/sprintf.9 comp-obsolete obsolete ./usr/share/man/man9/stathz.9 comp-sys-man .man ./usr/share/man/man9/store.9 comp-obsolete obsolete +./usr/share/man/man9/strlist.9 comp-sys-man .man +./usr/share/man/man9/strlist_append.9 comp-sys-man .man +./usr/share/man/man9/strlist_count.9 comp-sys-man .man +./usr/share/man/man9/strlist_index.9 comp-sys-man .man +./usr/share/man/man9/strlist_match.9 comp-sys-man .man +./usr/share/man/man9/strlist_next.9 comp-sys-man .man +./usr/share/man/man9/strlist_pmatch.9 comp-sys-man .man +./usr/share/man/man9/strlist_string.9 comp-sys-man .man ./usr/share/man/man9/subyte.9 comp-obsolete obsolete ./usr/share/man/man9/suibyte.9 comp-obsolete obsolete ./usr/share/man/man9/suiword.9 comp-obsolete obsolete Index: src/share/man/man9/Makefile diff -u src/share/man/man9/Makefile:1.453 src/share/man/man9/Makefile:1.454 --- src/share/man/man9/Makefile:1.453 Sat Oct 31 22:43:01 2020 +++ src/share/man/man9/Makefile Thu Jan 21 15:53:16 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.453 2020/10/31 22:43:01 uwe Exp $ +# $NetBSD: Makefile,v 1.454 2021/01/21 15:53:16 thorpej Exp $ # Makefile for section 9 (kernel function and variable) manual pages. @@ -54,6 +54,7 @@ MAN= accept_filter.9 accf_data.9 accf_ht SET.9 setbit.9 setjmp.9 shutdownhook_establish.9 \ signal.9 skpc.9 sockopt.9 softintr.9 spl.9 specificdata.9 \ spi.9 splraiseipl.9 \ + strlist.9 \ suspendsched.9 \ sysctl.9 sysmon_envsys.9 sysmon_pswitch.9 sysmon_taskq.9 tc.9 \ tcp_congctl.9 thmap.9 threadpool.9 timecounter.9 time_second.9 todr.9 \ @@ -885,6 +886,13 @@ MLINKS+=spl.9 spl0.9 spl.9 splbio.9 spl. spl.9 splsoftclock.9 spl.9 splsoftnet.9 spl.9 splsoftserial.9 \ spl.9 splstatclock.9 spl.9 spltty.9 spl.9 splvm.9 spl.9 splx.9 \ spl.9 splsoftbio.9 +MLINKS+=strlist.9 strlist_append.9 \ + strlist.9 strlist_count.9 \ + strlist.9 strlist_index.9 \ + strlist.9 strlist_match.9 \ + strlist.9 strlist_next.9 \ + strlist.9 strlist_pmatch.9 \ + strlist.9 strlist_string.9 MLINKS+=sysctl.9 old_sysctl.9 \ sysctl.9
CVS commit: src/sys/lib/libkern
Module Name:src Committed By: thorpej Date: Thu Jan 21 15:44:14 UTC 2021 Modified Files: src/sys/lib/libkern: pmatch.c Log Message: Allow this to be built for the strlist.c unit tests. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/lib/libkern/pmatch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libkern/pmatch.c diff -u src/sys/lib/libkern/pmatch.c:1.6 src/sys/lib/libkern/pmatch.c:1.7 --- src/sys/lib/libkern/pmatch.c:1.6 Sat Mar 14 21:04:24 2009 +++ src/sys/lib/libkern/pmatch.c Thu Jan 21 15:44:14 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pmatch.c,v 1.6 2009/03/14 21:04:24 dsl Exp $ */ +/* $NetBSD: pmatch.c,v 1.7 2021/01/21 15:44:14 thorpej Exp $ */ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. @@ -30,7 +30,14 @@ */ #include + +/* So we can build this in userland for the tests in strlist.c */ +#if defined(_KERNEL) || defined(_STANDALONE) #include +#else +int pmatch(const char *, const char *, const char **); +#endif + /* * pmatch(): * Return 2 on exact match.
CVS commit: src/sys/lib/libkern
Module Name:src Committed By: thorpej Date: Thu Jan 21 15:43:37 UTC 2021 Modified Files: src/sys/lib/libkern: libkern.h Added Files: src/sys/lib/libkern: strlist.c strlist.h Log Message: Add a generic set of routines for interacting with OpenFirmware-style string lists. To generate a diff of this commit: cvs rdiff -u -r1.141 -r1.142 src/sys/lib/libkern/libkern.h cvs rdiff -u -r0 -r1.1 src/sys/lib/libkern/strlist.c \ src/sys/lib/libkern/strlist.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libkern/libkern.h diff -u src/sys/lib/libkern/libkern.h:1.141 src/sys/lib/libkern/libkern.h:1.142 --- src/sys/lib/libkern/libkern.h:1.141 Sat Jan 16 23:51:51 2021 +++ src/sys/lib/libkern/libkern.h Thu Jan 21 15:43:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: libkern.h,v 1.141 2021/01/16 23:51:51 chs Exp $ */ +/* $NetBSD: libkern.h,v 1.142 2021/01/21 15:43:37 thorpej Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -44,6 +44,8 @@ #include #include +#include + #ifndef LIBKERN_INLINE #define LIBKERN_INLINE static __inline #define LIBKERN_BODY Added files: Index: src/sys/lib/libkern/strlist.c diff -u /dev/null src/sys/lib/libkern/strlist.c:1.1 --- /dev/null Thu Jan 21 15:43:37 2021 +++ src/sys/lib/libkern/strlist.c Thu Jan 21 15:43:37 2021 @@ -0,0 +1,490 @@ +/* $NetBSD: strlist.c,v 1.1 2021/01/21 15:43:37 thorpej Exp $ */ + +/*- + * Copyright (c) 2021 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * strlist -- + * + * A set of routines for interacting with IEEE 1275 (OpenFirmware) + * style string lists. + * + * An OpenFirmware string list is simply a buffer containing + * multiple NUL-terminated strings concatenated together. + * + * So, for example, the a string list consisting of the strings + * "foo", "bar", and "baz" would be represented in memory like: + * + * foo\0bar\0baz\0 + */ + +#include + +/* + * Memory allocation wrappers to handle different environments. + */ +#if defined(_KERNEL) +#include +#include + +static void * +strlist_alloc(size_t const size) +{ + return kmem_zalloc(size, KM_SLEEP); +} + +static void +strlist_free(void * const v, size_t const size) +{ + kmem_free(v, size); +} +#elif defined(_STANDALONE) +#include + +static void * +strlist_alloc(size_t const size) +{ + cp = alloc(size); + if (cp != NULL) { + memset(cp, 0, size); + } + return cp; +} + +static void +strlist_free(void * const v, size_t const size) +{ + dealloc(v, size); +} +#else /* user-space */ +#include +#include + +extern int pmatch(const char *, const char *, const char **); + +static void * +strlist_alloc(size_t const size) +{ + return calloc(1, size); +} + +static void +strlist_free(void * const v, size_t const size __unused) +{ + free(v); +} +#endif + +#include "strlist.h" + +/* + * strlist_next -- + * + * Return a pointer to the next string in the strlist, + * or NULL if there are no more strings. + */ +const char * +strlist_next(const char * const sl, size_t const slsize, size_t * const cursorp) +{ + + if (sl == NULL || slsize == 0 || cursorp == NULL) { + return NULL; + } + + size_t cursor = *cursorp; + + if (cursor >= slsize) { + /* No more strings in the list. */ + return NULL; + } + + const char *cp = sl + cursor; + *cursorp = cursor + strlen(cp) + 1; + + return cp; +} + +/* + * strlist_count -- + * + * Return the number of strings in the strlist. + */ +unsigned int +strlist_count(const char *sl, size_t slsize) +{ + + if (sl == NULL || slsize == 0)
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Jan 21 14:30:01 UTC 2021 Modified Files: src/usr.bin/make: make.h parse.c Log Message: make(1): merge duplicate code in Parse_MainName To generate a diff of this commit: cvs rdiff -u -r1.244 -r1.245 src/usr.bin/make/make.h cvs rdiff -u -r1.526 -r1.527 src/usr.bin/make/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.244 src/usr.bin/make/make.h:1.245 --- src/usr.bin/make/make.h:1.244 Tue Jan 19 20:51:46 2021 +++ src/usr.bin/make/make.h Thu Jan 21 14:30:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.244 2021/01/19 20:51:46 rillig Exp $ */ +/* $NetBSD: make.h,v 1.245 2021/01/21 14:30:01 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -413,7 +413,10 @@ typedef struct GNode { * this node, in the normal sense. */ GNodeList order_succ; - /* Other nodes of the same name, for the '::' dependency operator. */ + /* + * Other nodes of the same name, for targets that were defined using + * the '::' dependency operator (OP_DOUBLEDEP). + */ GNodeList cohorts; /* The "#n" suffix for this cohort, or "" for other nodes */ char cohort_num[8]; Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.526 src/usr.bin/make/parse.c:1.527 --- src/usr.bin/make/parse.c:1.526 Sun Jan 10 21:20:46 2021 +++ src/usr.bin/make/parse.c Thu Jan 21 14:30:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.526 2021/01/10 21:20:46 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.527 2021/01/21 14:30:01 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -109,7 +109,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.526 2021/01/10 21:20:46 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.527 2021/01/21 14:30:01 rillig Exp $"); /* types and constants */ @@ -3259,11 +3259,9 @@ Parse_MainName(GNodeList *mainList) if (mainNode == NULL) Punt("no target to make."); - if (mainNode->type & OP_DOUBLEDEP) { - Lst_Append(mainList, mainNode); + Lst_Append(mainList, mainNode); + if (mainNode->type & OP_DOUBLEDEP) Lst_AppendAll(mainList, >cohorts); - } else - Lst_Append(mainList, mainNode); Var_Append(".TARGETS", mainNode->name, VAR_GLOBAL); }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Jan 21 14:24:25 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): extract CondParser_StringExpr from CondParser_String To generate a diff of this commit: cvs rdiff -u -r1.247 -r1.248 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.247 src/usr.bin/make/cond.c:1.248 --- src/usr.bin/make/cond.c:1.247 Thu Jan 21 14:08:09 2021 +++ src/usr.bin/make/cond.c Thu Jan 21 14:24:25 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.247 2021/01/21 14:08:09 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.248 2021/01/21 14:24:25 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.247 2021/01/21 14:08:09 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.248 2021/01/21 14:24:25 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -399,6 +399,73 @@ is_separator(char ch) } /* + * In a quoted or unquoted string literal or a number, parse a variable + * expression. + * + * Example: .if x${CENTER}y == "${PREFIX}${SUFFIX}" || 0x${HEX} + */ +static Boolean +CondParser_StringExpr(CondParser *par, const char *start, + Boolean const doEval, Boolean const quoted, + Buffer *buf, FStr *const inout_str) +{ + VarEvalFlags eflags; + const char *nested_p; + Boolean atStart; + VarParseResult parseResult; + + /* if we are in quotes, an undefined variable is ok */ + eflags = + doEval && !quoted ? VARE_WANTRES | VARE_UNDEFERR : + doEval ? VARE_WANTRES : + VARE_NONE; + + nested_p = par->p; + atStart = nested_p == start; + parseResult = Var_Parse(_p, VAR_CMDLINE, eflags, inout_str); + /* TODO: handle errors */ + if (inout_str->str == var_Error) { + if (parseResult == VPR_ERR) { + /* + * FIXME: Even if an error occurs, + * there is no guarantee that it is + * reported. + * + * See cond-token-plain.mk . + */ + par->printedError = TRUE; + } + /* + * XXX: Can there be any situation in which + * a returned var_Error requires freeIt? + */ + FStr_Done(inout_str); + /* + * Even if !doEval, we still report syntax + * errors, which is what getting var_Error + * back with !doEval means. + */ + *inout_str = FStr_InitRefer(NULL); + return FALSE; + } + par->p = nested_p; + + /* + * If the '$' started the string literal (which means + * no quotes), and the variable expression is followed + * by a space, looks like a comparison operator or is + * the end of the expression, we are done. + */ + if (atStart && is_separator(par->p[0])) + return FALSE; + + Buf_AddStr(buf, inout_str->str); + FStr_Done(inout_str); + *inout_str = FStr_InitRefer(NULL); /* not finished yet */ + return TRUE; +} + +/* * Parse a string from a variable reference or an optionally quoted * string. This is called for the lhs and rhs of string comparisons. * @@ -413,12 +480,8 @@ CondParser_String(CondParser *par, Boole { Buffer buf; FStr str; - Boolean atStart; - const char *nested_p; Boolean quoted; const char *start; - VarEvalFlags eflags; - VarParseResult parseResult; Buf_Init(); str = FStr_InitRefer(NULL); @@ -455,55 +518,9 @@ CondParser_String(CondParser *par, Boole par->p++; continue; case '$': - /* if we are in quotes, an undefined variable is ok */ - eflags = - doEval && !quoted ? VARE_WANTRES | VARE_UNDEFERR : - doEval ? VARE_WANTRES : - VARE_NONE; - - nested_p = par->p; - atStart = nested_p == start; - parseResult = Var_Parse(_p, VAR_CMDLINE, eflags, - ); - /* TODO: handle errors */ - if (str.str == var_Error) { -if (parseResult == VPR_ERR) { - /* - * FIXME: Even if an error occurs, - * there is no guarantee that it is - * reported. - * - * See cond-token-plain.mk . - */ - par->printedError = TRUE; -} -/* - * XXX: Can there be any situation in which - * a returned var_Error requires freeIt? - */ -FStr_Done(); -/* - * Even if !doEval, we still report syntax - * errors, which is what getting var_Error - * back with !doEval means. - */ -str = FStr_InitRefer(NULL); + if (!CondParser_StringExpr(par, + start, doEval, quoted, , )) goto cleanup; - } - par->p = nested_p; - - /* - * If the '$' started the string literal (which means - * no quotes), and the variable expression is followed - * by a space, looks like a comparison operator or is - * the end of the expression, we are done. - */ - if (atStart && is_separator(par->p[0])) -goto cleanup; - - Buf_AddStr(, str.str); - FStr_Done(); - str = FStr_InitRefer(NULL); /* not finished yet */ continue;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Jan 21 14:08:09 UTC 2021 Modified Files: src/usr.bin/make: cond.c src/usr.bin/make/unit-tests: cond-token-plain.exp cond-token-plain.mk Log Message: make(1): demonstrate parse error without error message in conditional To generate a diff of this commit: cvs rdiff -u -r1.246 -r1.247 src/usr.bin/make/cond.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-token-plain.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-token-plain.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.246 src/usr.bin/make/cond.c:1.247 --- src/usr.bin/make/cond.c:1.246 Thu Jan 21 13:51:24 2021 +++ src/usr.bin/make/cond.c Thu Jan 21 14:08:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.246 2021/01/21 13:51:24 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.247 2021/01/21 14:08:09 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.246 2021/01/21 13:51:24 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.247 2021/01/21 14:08:09 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -467,8 +467,16 @@ CondParser_String(CondParser *par, Boole ); /* TODO: handle errors */ if (str.str == var_Error) { -if (parseResult == VPR_ERR) +if (parseResult == VPR_ERR) { + /* + * FIXME: Even if an error occurs, + * there is no guarantee that it is + * reported. + * + * See cond-token-plain.mk . + */ par->printedError = TRUE; +} /* * XXX: Can there be any situation in which * a returned var_Error requires freeIt? Index: src/usr.bin/make/unit-tests/cond-token-plain.exp diff -u src/usr.bin/make/unit-tests/cond-token-plain.exp:1.6 src/usr.bin/make/unit-tests/cond-token-plain.exp:1.7 --- src/usr.bin/make/unit-tests/cond-token-plain.exp:1.6 Thu Jan 21 13:52:32 2021 +++ src/usr.bin/make/unit-tests/cond-token-plain.exp Thu Jan 21 14:08:09 2021 @@ -49,6 +49,7 @@ CondParser_Eval: \\ make: "cond-token-plain.mk" line 168: Now the variable '\\' is defined. CondParser_Eval: "unquoted\"quoted" != unquoted"quoted lhs = "unquoted"quoted", rhs = "unquoted"quoted", op = != +CondParser_Eval: != "" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/cond-token-plain.mk diff -u src/usr.bin/make/unit-tests/cond-token-plain.mk:1.9 src/usr.bin/make/unit-tests/cond-token-plain.mk:1.10 --- src/usr.bin/make/unit-tests/cond-token-plain.mk:1.9 Thu Jan 21 13:52:32 2021 +++ src/usr.bin/make/unit-tests/cond-token-plain.mk Thu Jan 21 14:08:09 2021 @@ -1,4 +1,4 @@ -# $NetBSD: cond-token-plain.mk,v 1.9 2021/01/21 13:52:32 rillig Exp $ +# $NetBSD: cond-token-plain.mk,v 1.10 2021/01/21 14:08:09 rillig Exp $ # # Tests for plain tokens (that is, string literals without quotes) # in .if conditions. @@ -177,6 +177,14 @@ ${:U}= backslash . error .endif +# FIXME: In CondParser_String, Var_Parse returns var_Error without a +# corresponding error message. +.if != "" +. error +.else +. error +.endif + # See cond-token-string.mk for similar tests where the condition is enclosed # in "quotes".
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Thu Jan 21 13:52:32 UTC 2021 Modified Files: src/usr.bin/make/unit-tests: cond-token-plain.exp cond-token-plain.mk Log Message: make(1): add test case for bare word containing quotes To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-token-plain.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-token-plain.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/cond-token-plain.exp diff -u src/usr.bin/make/unit-tests/cond-token-plain.exp:1.5 src/usr.bin/make/unit-tests/cond-token-plain.exp:1.6 --- src/usr.bin/make/unit-tests/cond-token-plain.exp:1.5 Thu Jan 21 13:32:17 2021 +++ src/usr.bin/make/unit-tests/cond-token-plain.exp Thu Jan 21 13:52:32 2021 @@ -47,6 +47,8 @@ CondParser_Eval: \\ make: "cond-token-plain.mk" line 163: The variable '\\' is not defined. CondParser_Eval: \\ make: "cond-token-plain.mk" line 168: Now the variable '\\' is defined. +CondParser_Eval: "unquoted\"quoted" != unquoted"quoted +lhs = "unquoted"quoted", rhs = "unquoted"quoted", op = != make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/cond-token-plain.mk diff -u src/usr.bin/make/unit-tests/cond-token-plain.mk:1.8 src/usr.bin/make/unit-tests/cond-token-plain.mk:1.9 --- src/usr.bin/make/unit-tests/cond-token-plain.mk:1.8 Thu Jan 21 13:32:17 2021 +++ src/usr.bin/make/unit-tests/cond-token-plain.mk Thu Jan 21 13:52:32 2021 @@ -1,4 +1,4 @@ -# $NetBSD: cond-token-plain.mk,v 1.8 2021/01/21 13:32:17 rillig Exp $ +# $NetBSD: cond-token-plain.mk,v 1.9 2021/01/21 13:52:32 rillig Exp $ # # Tests for plain tokens (that is, string literals without quotes) # in .if conditions. @@ -170,6 +170,13 @@ ${:U}= backslash . error .endif +# Anything that doesn't start with a double quote is considered a "bare word". +# Strangely, a bare word may contain double quotes inside. Nobody should ever +# depend on this since it may well be unintended. See CondParser_String. +.if "unquoted\"quoted" != unquoted"quoted +. error +.endif + # See cond-token-string.mk for similar tests where the condition is enclosed # in "quotes".
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Jan 21 13:51:25 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): make CondParser_String simpler No functional change. To generate a diff of this commit: cvs rdiff -u -r1.245 -r1.246 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.245 src/usr.bin/make/cond.c:1.246 --- src/usr.bin/make/cond.c:1.245 Thu Jan 21 13:31:38 2021 +++ src/usr.bin/make/cond.c Thu Jan 21 13:51:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.245 2021/01/21 13:31:38 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.246 2021/01/21 13:51:24 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.245 2021/01/21 13:31:38 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.246 2021/01/21 13:51:24 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -437,12 +437,10 @@ CondParser_String(CondParser *par, Boole } continue; case '"': - if (quoted) { -par->p++; /* skip the closing quote */ -goto got_str; - } - Buf_AddByte(, par->p[0]); /* likely? */ par->p++; + if (quoted) +goto got_str; /* skip the closing quote */ + Buf_AddByte(, '"'); continue; case ')': /* see is_separator */ case '!':
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Thu Jan 21 13:32:17 UTC 2021 Modified Files: src/usr.bin/make/unit-tests: cond-token-plain.exp cond-token-plain.mk Log Message: make(1): add more tests for edge cases in conditionals To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-token-plain.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-token-plain.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/cond-token-plain.exp diff -u src/usr.bin/make/unit-tests/cond-token-plain.exp:1.4 src/usr.bin/make/unit-tests/cond-token-plain.exp:1.5 --- src/usr.bin/make/unit-tests/cond-token-plain.exp:1.4 Thu Jan 21 00:38:28 2021 +++ src/usr.bin/make/unit-tests/cond-token-plain.exp Thu Jan 21 13:32:17 2021 @@ -38,4 +38,15 @@ CondParser_Eval: 0${:Ux00} make: "cond-token-plain.mk" line 130: Numbers can be composed from literals and variable expressions. CondParser_Eval: 0${:Ux01} make: "cond-token-plain.mk" line 134: Numbers can be composed from literals and variable expressions. -exit status 0 +CondParser_Eval: "" == +make: "cond-token-plain.mk" line 140: warning: Missing right-hand-side of operator +make: "cond-token-plain.mk" line 140: Malformed conditional ("" ==) +CondParser_Eval: == "" +make: "cond-token-plain.mk" line 148: Malformed conditional (== "") +CondParser_Eval: \\ +make: "cond-token-plain.mk" line 163: The variable '\\' is not defined. +CondParser_Eval: \\ +make: "cond-token-plain.mk" line 168: Now the variable '\\' is defined. +make: Fatal errors encountered -- cannot continue +make: stopped in unit-tests +exit status 1 Index: src/usr.bin/make/unit-tests/cond-token-plain.mk diff -u src/usr.bin/make/unit-tests/cond-token-plain.mk:1.7 src/usr.bin/make/unit-tests/cond-token-plain.mk:1.8 --- src/usr.bin/make/unit-tests/cond-token-plain.mk:1.7 Thu Jan 21 00:38:28 2021 +++ src/usr.bin/make/unit-tests/cond-token-plain.mk Thu Jan 21 13:32:17 2021 @@ -1,4 +1,4 @@ -# $NetBSD: cond-token-plain.mk,v 1.7 2021/01/21 00:38:28 rillig Exp $ +# $NetBSD: cond-token-plain.mk,v 1.8 2021/01/21 13:32:17 rillig Exp $ # # Tests for plain tokens (that is, string literals without quotes) # in .if conditions. @@ -136,6 +136,40 @@ VAR= defined . error .endif +# If the right-hand side is missing, it's a parse error. +.if "" == +. error +.else +. error +.endif + +# If the left-hand side is missing, it's a parse error as well, but without +# a specific error message. +.if == "" +. error +.else +. error +.endif + +# The '\\' is not a line continuation. Neither is it an unquoted string +# literal. Instead, it is parsed as a function argument (ParseFuncArg), +# and in that context, the backslash is just an ordinary character. The +# function argument thus stays '\\' (2 backslashes). This string is passed +# to FuncDefined, and since there is no variable named '\\', the condition +# evaluates to false. +.if \\ +. error +.else +. info The variable '\\' is not defined. +.endif + +${:U}= backslash +.if \\ +. info Now the variable '\\' is defined. +.else +. error +.endif + # See cond-token-string.mk for similar tests where the condition is enclosed # in "quotes".
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Jan 21 13:31:38 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): fix Coverity annotation FStr is not an allocated data type. To generate a diff of this commit: cvs rdiff -u -r1.244 -r1.245 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.244 src/usr.bin/make/cond.c:1.245 --- src/usr.bin/make/cond.c:1.244 Tue Jan 19 22:12:44 2021 +++ src/usr.bin/make/cond.c Thu Jan 21 13:31:38 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.244 2021/01/19 22:12:44 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.245 2021/01/21 13:31:38 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.244 2021/01/19 22:12:44 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.245 2021/01/21 13:31:38 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -407,7 +407,6 @@ is_separator(char ch) * Sets out_quoted if the string was quoted. * Sets out_freeIt. */ -/* coverity:[+alloc : arg-*4] */ static void CondParser_String(CondParser *par, Boolean doEval, Boolean strictLHS, FStr *out_str, Boolean *out_quoted)
CVS commit: src/sys/arch/x86/include
Module Name:src Committed By: kre Date: Thu Jan 21 09:50:37 UTC 2021 Modified Files: src/sys/arch/x86/include: bus_defs.h Log Message: PRIx (etc) definitions should not include the % Will fix anything this ends up breaking later. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/include/bus_defs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/include/bus_defs.h diff -u src/sys/arch/x86/include/bus_defs.h:1.5 src/sys/arch/x86/include/bus_defs.h:1.6 --- src/sys/arch/x86/include/bus_defs.h:1.5 Thu Nov 14 16:23:52 2019 +++ src/sys/arch/x86/include/bus_defs.h Thu Jan 21 09:50:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_defs.h,v 1.5 2019/11/14 16:23:52 maxv Exp $ */ +/* $NetBSD: bus_defs.h,v 1.6 2021/01/21 09:50:37 kre Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. @@ -86,8 +86,8 @@ typedef paddr_t bus_addr_t; typedef size_t bus_size_t; #define PRIxBUSADDR PRIxPADDR -#define PRIxBUSSIZE "%zx" -#define PRIuBUSSIZE "%zu" +#define PRIxBUSSIZE "zx" +#define PRIuBUSSIZE "zu" struct bus_space_tag; typedef struct bus_space_tag *bus_space_tag_t;
CVS commit: src/sys/dev/pci
Module Name:src Committed By: martin Date: Thu Jan 21 08:17:13 UTC 2021 Modified Files: src/sys/dev/pci: virtio_pci.c Log Message: Use PRIxBUSSIZE to print a bus_size_t value. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/pci/virtio_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/virtio_pci.c diff -u src/sys/dev/pci/virtio_pci.c:1.16 src/sys/dev/pci/virtio_pci.c:1.17 --- src/sys/dev/pci/virtio_pci.c:1.16 Wed Jan 20 21:59:48 2021 +++ src/sys/dev/pci/virtio_pci.c Thu Jan 21 08:17:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: virtio_pci.c,v 1.16 2021/01/20 21:59:48 reinoud Exp $ */ +/* $NetBSD: virtio_pci.c,v 1.17 2021/01/21 08:17:13 martin Exp $ */ /* * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.16 2021/01/20 21:59:48 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.17 2021/01/21 08:17:13 martin Exp $"); #include #include @@ -489,8 +489,9 @@ virtio_pci_attach_10(device_t self, void ret = EIO; goto err; } - aprint_debug_dev(self, "bar[%d]: iot %p, size 0x%lx\n", - j, psc->sc_bars_iot[j], psc->sc_bars_iosize[j]); + aprint_debug_dev(self, + "bar[%d]: iot %p, size 0x%" PRIxBUSSIZE "\n", + j, psc->sc_bars_iot[j], psc->sc_bars_iosize[j]); bars_idx[i] = j; j++; }