CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Jan 5 07:37:41 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: print.c Log Message: lint: add missing strings for operators It's difficult to keep these lists in sync when they are spread over several files. The lists had been inconsistent since 2008-04-26. The inconsistency didn't lead to undefined behavior though since the operator names are only used in 2 places: 1. check_integer_conversion in message 324 only calls that function with a few selected operators, all of which are above the missing ones. 2. mkinit prints the node including its operator, but only in debug mode. Furthermore I'm not sure whether any of the broken operator names could ever be accessed at this place since mkinit is only called for expressions, and the node types are INIT, CASE, FARG, which are all special. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/lint1/print.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/xlint/lint1/print.c diff -u src/usr.bin/xlint/lint1/print.c:1.8 src/usr.bin/xlint/lint1/print.c:1.9 --- src/usr.bin/xlint/lint1/print.c:1.8 Sun Jan 3 18:35:51 2021 +++ src/usr.bin/xlint/lint1/print.c Tue Jan 5 07:37:41 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.8 2021/01/03 18:35:51 rillig Exp $ */ +/* $NetBSD: print.c,v 1.9 2021/01/05 07:37:41 rillig Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #ifndef lint -__RCSID("$NetBSD: print.c,v 1.8 2021/01/03 18:35:51 rillig Exp $"); +__RCSID("$NetBSD: print.c,v 1.9 2021/01/05 07:37:41 rillig Exp $"); #endif #include @@ -101,6 +101,8 @@ static const char *str_op_t[] = "*load*", "*push*", "return", + "real", + "imag", "*init*", "*case*", "*farg*",
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Jan 5 00:22:05 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: func.c Log Message: lint: clean up comments To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/usr.bin/xlint/lint1/func.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/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.50 src/usr.bin/xlint/lint1/func.c:1.51 --- src/usr.bin/xlint/lint1/func.c:1.50 Mon Jan 4 22:26:50 2021 +++ src/usr.bin/xlint/lint1/func.c Tue Jan 5 00:22:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.50 2021/01/04 22:26:50 rillig Exp $ */ +/* $NetBSD: func.c,v 1.51 2021/01/05 00:22:04 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.50 2021/01/04 22:26:50 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.51 2021/01/05 00:22:04 rillig Exp $"); #endif #include @@ -496,7 +496,7 @@ case_label(tnode_t *tn) { cstk_t *ci; - /* find the stack entry for the innermost switch statement */ + /* find the innermost switch statement */ for (ci = cstmt; ci != NULL && !ci->c_switch; ci = ci->c_surrounding) continue; @@ -512,7 +512,7 @@ default_label(void) { cstk_t *ci; - /* find the stack entry for the innermost switch statement */ + /* find the innermost switch statement */ for (ci = cstmt; ci != NULL && !ci->c_switch; ci = ci->c_surrounding) continue;
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Jan 5 00:17:21 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: extract code for determining possible precedence confusion The function check_precedence_confusion was pretty long, and right in the middle of that function was the complicated part of determining which of the operand combinations are confusing and which aren't. Extract this part into a separate function to document on which information this decision is based. This makes it easier to understand the code since there are fewer local variables around. As a left-over from a previous commit, rop and rparn don't need to be initialized twice, now that the assertion for a binary operator is in place. Remove the large and useless switch statement over all operator types. This list was completely unsorted, for no apparent reason. To see the list of operators, better look them up in ops.def, there was no need to have this list duplicated here. To generate a diff of this commit: cvs rdiff -u -r1.133 -r1.134 src/usr.bin/xlint/lint1/tree.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/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.133 src/usr.bin/xlint/lint1/tree.c:1.134 --- src/usr.bin/xlint/lint1/tree.c:1.133 Mon Jan 4 23:58:19 2021 +++ src/usr.bin/xlint/lint1/tree.c Tue Jan 5 00:17:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.133 2021/01/04 23:58:19 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.134 2021/01/05 00:17:21 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.133 2021/01/04 23:58:19 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.134 2021/01/05 00:17:21 rillig Exp $"); #endif #include @@ -3977,6 +3977,46 @@ cat_strings(strg_t *strg1, strg_t *strg2 return strg1; } +static bool +is_confusing_precedence(op_t op, op_t lop, bool lparen, op_t rop, bool rparen) +{ + + if (op == SHL || op == SHR) { + if (!lparen && (lop == PLUS || lop == MINUS)) { + return true; + } else if (!rparen && (rop == PLUS || rop == MINUS)) { + return true; + } + return false; + } + + if (op == LOGOR) { + if (!lparen && lop == LOGAND) { + return true; + } else if (!rparen && rop == LOGAND) { + return true; + } + return false; + } + + lint_assert(op == AND || op == XOR || op == OR); + if (!lparen && lop != op) { + if (lop == PLUS || lop == MINUS) { + return true; + } else if (lop == AND || lop == XOR) { + return true; + } + } + if (!rparen && rop != op) { + if (rop == PLUS || rop == MINUS) { + return true; + } else if (rop == AND || rop == XOR) { + return true; + } + } + return false; +} + /* * Print a warning if the given node has operands which should be * parenthesized. @@ -3988,10 +4028,9 @@ static void check_precedence_confusion(tnode_t *tn) { tnode_t *ln, *rn; - op_t lop, rop = NOOP; - int lparn, rparn = 0; + op_t lop, rop; + bool lparn, rparn; mod_t *mp; - int dowarn; if (!hflag) return; @@ -4001,117 +4040,20 @@ check_precedence_confusion(tnode_t *tn) dprint_node(tn); - lparn = 0; + lparn = false; for (ln = tn->tn_left; ln->tn_op == CVT; ln = ln->tn_left) lparn |= ln->tn_parenthesized; lparn |= ln->tn_parenthesized; lop = ln->tn_op; - rparn = 0; + rparn = false; for (rn = tn->tn_right; rn->tn_op == CVT; rn = rn->tn_left) rparn |= rn->tn_parenthesized; rparn |= rn->tn_parenthesized; rop = rn->tn_op; - dowarn = 0; - - switch (tn->tn_op) { - case SHL: - case SHR: - if (!lparn && (lop == PLUS || lop == MINUS)) { - dowarn = 1; - } else if (!rparn && (rop == PLUS || rop == MINUS)) { - dowarn = 1; - } - break; - case LOGOR: - if (!lparn && lop == LOGAND) { - dowarn = 1; - } else if (!rparn && rop == LOGAND) { - dowarn = 1; - } - break; - case AND: - case XOR: - case OR: - if (!lparn && lop != tn->tn_op) { - if (lop == PLUS || lop == MINUS) { -dowarn = 1; - } else if (lop == AND || lop == XOR) { -dowarn = 1; - } - } - if (!dowarn && !rparn && rop != tn->tn_op) { - if (rop == PLUS || rop == MINUS) { -dowarn = 1; - } else if (rop == AND || rop == XOR) { -dowarn = 1; - } - } - break; - /* LINTED206: (enumeration values not handled in switch) */ - case DECAFT: - case XORASS: - case SHLASS: - case NOOP: - case ARROW: - case ORASS: - case POINT: - case NAME: - case NOT: - case COMPL: - case CON: - case INC: - case STRING: - case DEC: - case INCBEF: - case DECBEF: - case INCAFT: - case FSEL: - case CALL: - case COMMA: - case CVT: - case ICALL: - case LOAD: - case PUSH: - case RETURN: - case INIT: - case CASE: - case FARG: - case SUBASS: - case ADDASS: - case MODASS: - case DIVASS: - case MULASS: - case ASSIGN: - case COLON: - case QUEST: - case LOGAND: - case NE: - case EQ: - case GE: - case GT: - case LE: - case LT: - case
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Jan 5 00:02:52 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: remove unused TBUILTIN_SIZEOF from the C grammar This token is not generated by the lexer, and it was misspelled anyway. All other token names start with "T_", this one was missing the underscore. To generate a diff of this commit: cvs rdiff -u -r1.130 -r1.131 src/usr.bin/xlint/lint1/cgram.y 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/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.130 src/usr.bin/xlint/lint1/cgram.y:1.131 --- src/usr.bin/xlint/lint1/cgram.y:1.130 Sun Jan 3 21:33:50 2021 +++ src/usr.bin/xlint/lint1/cgram.y Tue Jan 5 00:02:52 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.130 2021/01/03 21:33:50 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.131 2021/01/05 00:02:52 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.130 2021/01/03 21:33:50 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.131 2021/01/05 00:02:52 rillig Exp $"); #endif #include @@ -259,7 +259,7 @@ anonymize(sym_t *s) %left T_SHFTOP %left T_ADDOP %left T_MULT T_DIVOP -%right T_UNOP T_INCDEC T_SIZEOF TBUILTIN_SIZEOF T_ALIGNOF T_REAL T_IMAG +%right T_UNOP T_INCDEC T_SIZEOF T_ALIGNOF T_REAL T_IMAG %left T_LPAREN T_LBRACK T_STROP %token T_NAME
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Mon Jan 4 23:58:19 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: op.h tree.c Log Message: lint: precedence confusion is only possible with binary operators No functional change. The operator table in ops.def states that every operator that has possibly confusing precedence is also a binary operator, so assert that instead of having two different code paths. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/lint1/op.h cvs rdiff -u -r1.132 -r1.133 src/usr.bin/xlint/lint1/tree.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/xlint/lint1/op.h diff -u src/usr.bin/xlint/lint1/op.h:1.8 src/usr.bin/xlint/lint1/op.h:1.9 --- src/usr.bin/xlint/lint1/op.h:1.8 Sat Jan 2 01:06:15 2021 +++ src/usr.bin/xlint/lint1/op.h Mon Jan 4 23:58:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: op.h,v 1.8 2021/01/02 01:06:15 rillig Exp $ */ +/* $NetBSD: op.h,v 1.9 2021/01/04 23:58:19 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -49,7 +49,7 @@ typedef struct { bool m_sideeff : 1; /* operator has side effect */ bool m_tlansiu : 1; /* warn if left op. is unsign. in ANSI C */ bool m_transiu : 1; /* warn if right op. is unsign. in ANSI C */ - bool m_tpconf : 1; /* test possible precedence confusion */ + bool m_possible_precedence_confusion : 1; bool m_comp : 1; /* operator performs comparison */ bool m_valid_on_enum : 1; /* valid operation on enums */ bool m_bad_on_enum : 1; /* dubious operation on enums */ Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.132 src/usr.bin/xlint/lint1/tree.c:1.133 --- src/usr.bin/xlint/lint1/tree.c:1.132 Mon Jan 4 23:50:46 2021 +++ src/usr.bin/xlint/lint1/tree.c Mon Jan 4 23:58:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.132 2021/01/04 23:50:46 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.133 2021/01/04 23:58:19 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.132 2021/01/04 23:50:46 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.133 2021/01/04 23:58:19 rillig Exp $"); #endif #include @@ -608,7 +608,7 @@ build(op_t op, tnode_t *ln, tnode_t *rn) return NULL; /* Print a warning if precedence confusion is possible */ - if (mp->m_tpconf) + if (mp->m_possible_precedence_confusion) check_precedence_confusion(ntn); /* @@ -3997,6 +3997,9 @@ check_precedence_confusion(tnode_t *tn) return; mp = &modtab[tn->tn_op]; + lint_assert(mp->m_binary); + + dprint_node(tn); lparn = 0; for (ln = tn->tn_left; ln->tn_op == CVT; ln = ln->tn_left) @@ -4004,15 +4007,11 @@ check_precedence_confusion(tnode_t *tn) lparn |= ln->tn_parenthesized; lop = ln->tn_op; - dprint_node(tn); - - if (mp->m_binary) { - rparn = 0; - for (rn = tn->tn_right; rn->tn_op == CVT; rn = rn->tn_left) - rparn |= rn->tn_parenthesized; + rparn = 0; + for (rn = tn->tn_right; rn->tn_op == CVT; rn = rn->tn_left) rparn |= rn->tn_parenthesized; - rop = rn->tn_op; - } + rparn |= rn->tn_parenthesized; + rop = rn->tn_op; dowarn = 0;
CVS commit: src
Module Name:src Committed By: rillig Date: Mon Jan 4 23:50:47 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_169.exp src/usr.bin/xlint/lint1: tree.c Log Message: lint: fix bug in "precedence confusion possible [169]" To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_169.exp cvs rdiff -u -r1.131 -r1.132 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_169.exp diff -u src/tests/usr.bin/xlint/lint1/msg_169.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_169.exp:1.4 --- src/tests/usr.bin/xlint/lint1/msg_169.exp:1.3 Mon Jan 4 23:47:27 2021 +++ src/tests/usr.bin/xlint/lint1/msg_169.exp Mon Jan 4 23:50:46 2021 @@ -23,3 +23,4 @@ msg_169.c(126): warning: precedence conf msg_169.c(127): warning: precedence confusion possible: parenthesize! [169] msg_169.c(131): warning: precedence confusion possible: parenthesize! [169] msg_169.c(161): warning: precedence confusion possible: parenthesize! [169] +msg_169.c(162): warning: precedence confusion possible: parenthesize! [169] Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.131 src/usr.bin/xlint/lint1/tree.c:1.132 --- src/usr.bin/xlint/lint1/tree.c:1.131 Mon Jan 4 23:47:26 2021 +++ src/usr.bin/xlint/lint1/tree.c Mon Jan 4 23:50:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.131 2021/01/04 23:47:26 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.132 2021/01/04 23:50:46 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.131 2021/01/04 23:47:26 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.132 2021/01/04 23:50:46 rillig Exp $"); #endif #include @@ -4008,16 +4008,7 @@ check_precedence_confusion(tnode_t *tn) if (mp->m_binary) { rparn = 0; - /* - * FIXME: There is a typo "tn->tn_op == CVT", which should - * rather be "rn->tn_op". Since tn must be a binary operator, - * it can never be CVT, so the loop is never taken. - * - * Since the loop is never taken, if the right-hand operand - * is CVT, it is not followed to the actually interesting - * operator. - */ - for (rn = tn->tn_right; tn->tn_op == CVT; rn = rn->tn_left) + for (rn = tn->tn_right; rn->tn_op == CVT; rn = rn->tn_left) rparn |= rn->tn_parenthesized; rparn |= rn->tn_parenthesized; rop = rn->tn_op;
CVS commit: src
Module Name:src Committed By: rillig Date: Mon Jan 4 23:47:27 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_169.c msg_169.exp src/usr.bin/xlint/lint1: tree.c Log Message: lint: document and demonstrate the bug in check_precedence_confusion It took quite a while to get to the correct interpretation of this small piece of code and to draw the right conclusions from it. Now the bug is finally ready to be fixed, as already announced in the test. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_169.c cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_169.exp cvs rdiff -u -r1.130 -r1.131 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_169.c diff -u src/tests/usr.bin/xlint/lint1/msg_169.c:1.3 src/tests/usr.bin/xlint/lint1/msg_169.c:1.4 --- src/tests/usr.bin/xlint/lint1/msg_169.c:1.3 Mon Jan 4 22:41:56 2021 +++ src/tests/usr.bin/xlint/lint1/msg_169.c Mon Jan 4 23:47:27 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_169.c,v 1.3 2021/01/04 22:41:56 rillig Exp $ */ +/* $NetBSD: msg_169.c,v 1.4 2021/01/04 23:47:27 rillig Exp $ */ # 3 "msg_169.c" // Test for message: precedence confusion possible: parenthesize! [169] @@ -146,6 +146,36 @@ expected_precedence(int a, int b, int c) ok = a + b * c; } -// TODO: add a test with unsigned long instead of unsigned, trying to -// demonstrate that the typo in check_precedence_confusion actually has an -// effect. +/* + * Before tree.c 1.132 from 2021-01-04, there was a typo in + * check_precedence_confusion that prevented the right-hand operand from + * being flagged as possibly confusing if there was an implicit conversion + * or an explicit cast between the main operator ('|') and the nested + * operator ('&'). + */ +void +implicit_conversion_to_long(long la, int a) +{ + int ok; + + ok = a & a | la; /* always marked as confusing */ + ok = la | a & a; /* marked as confusing since tree.c 1.132 */ + + ok = (a & a) | la; /* always ok */ + ok = la | (a & a); /* always ok */ + + /* + * Before tree.c 1.132, this expression didn't generate a warning + * because the right-hand operand was CVT, and there is no confusing + * precedence between BITOR and CVT. + * + * Since tree.c 1.132, this expression doesn't generate a warning + * because the right-hand operand is parenthesized. There is no way + * to have the right operand casted and at the same time not + * parenthesized since the cast operator has higher precedence. + * + * In summary, there is no visible change, but the implementation is + * now works as intended. + */ + ok = la | (int)(a & a); /* always ok */ +} Index: src/tests/usr.bin/xlint/lint1/msg_169.exp diff -u src/tests/usr.bin/xlint/lint1/msg_169.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_169.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_169.exp:1.2 Mon Jan 4 15:52:51 2021 +++ src/tests/usr.bin/xlint/lint1/msg_169.exp Mon Jan 4 23:47:27 2021 @@ -22,3 +22,4 @@ msg_169.c(101): warning: precedence conf msg_169.c(126): warning: precedence confusion possible: parenthesize! [169] msg_169.c(127): warning: precedence confusion possible: parenthesize! [169] msg_169.c(131): warning: precedence confusion possible: parenthesize! [169] +msg_169.c(161): warning: precedence confusion possible: parenthesize! [169] Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.130 src/usr.bin/xlint/lint1/tree.c:1.131 --- src/usr.bin/xlint/lint1/tree.c:1.130 Mon Jan 4 23:17:03 2021 +++ src/usr.bin/xlint/lint1/tree.c Mon Jan 4 23:47:26 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.130 2021/01/04 23:17:03 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.131 2021/01/04 23:47:26 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.130 2021/01/04 23:17:03 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.131 2021/01/04 23:47:26 rillig Exp $"); #endif #include @@ -4011,28 +4011,11 @@ check_precedence_confusion(tnode_t *tn) /* * FIXME: There is a typo "tn->tn_op == CVT", which should * rather be "rn->tn_op". Since tn must be a binary operator, - * it can never be CVT. + * it can never be CVT, so the loop is never taken. * - * Before fixing this though, there should be a unit test - * that demonstrates an actual change in behavior when this - * bug gets fixed. - * - * rn must be a chain of casts and conversions, and at least - * one of these must be a parenthesized cast. - * - * The argument of the innermost cast or conversion must not - * be parenthesized. - * - * The argument of the innermost cast or conversion must be - * an expression with confusing precedence. Since all these - * expressions have lower precedence than a cast, these can - * only appear
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Mon Jan 4 23:17:04 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: add more rationale for removing effect-less code To generate a diff of this commit: cvs rdiff -u -r1.129 -r1.130 src/usr.bin/xlint/lint1/tree.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/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.129 src/usr.bin/xlint/lint1/tree.c:1.130 --- src/usr.bin/xlint/lint1/tree.c:1.129 Mon Jan 4 22:41:56 2021 +++ src/usr.bin/xlint/lint1/tree.c Mon Jan 4 23:17:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.129 2021/01/04 22:41:56 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.130 2021/01/04 23:17:03 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.129 2021/01/04 22:41:56 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.130 2021/01/04 23:17:03 rillig Exp $"); #endif #include @@ -4017,18 +4017,22 @@ check_precedence_confusion(tnode_t *tn) * that demonstrates an actual change in behavior when this * bug gets fixed. * - * Right now, the condition is always false. To make it true - * after fixing the typo, the right-hand operand must be an - * explicit cast or an implicit conversion that is - * parenthesized. For the right-hand operand itself, this - * would already be done using the line below the loop. + * rn must be a chain of casts and conversions, and at least + * one of these must be a parenthesized cast. * - * To make a difference, the right-hand operand must not be - * parenthesized, but its indirect cast or conversion must be. + * The argument of the innermost cast or conversion must not + * be parenthesized. * - * An implicit conversion is never parenthesized. Therefore - * this must be a cast that is later converted, to build a - * chain. + * The argument of the innermost cast or conversion must be + * an expression with confusing precedence. Since all these + * expressions have lower precedence than a cast, these can + * only appear as a parenthesized expression. This in turn + * makes the whole loop superfluous. + * + * An edge case might be due to constant folding, if the + * nodes created from constant folding did not preserve + * tn_parenthesized properly. But that would be another bug, + * so it doesn't count as an argument. */ for (rn = tn->tn_right; tn->tn_op == CVT; rn = rn->tn_left) rparn |= rn->tn_parenthesized;
CVS commit: src
Module Name:src Committed By: rillig Date: Mon Jan 4 22:41:56 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_169.c src/usr.bin/xlint/lint1: tree.c Log Message: lint: finish the comments in check_precedence_confusion To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_169.c cvs rdiff -u -r1.128 -r1.129 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_169.c diff -u src/tests/usr.bin/xlint/lint1/msg_169.c:1.2 src/tests/usr.bin/xlint/lint1/msg_169.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_169.c:1.2 Mon Jan 4 15:52:51 2021 +++ src/tests/usr.bin/xlint/lint1/msg_169.c Mon Jan 4 22:41:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_169.c,v 1.2 2021/01/04 15:52:51 rillig Exp $ */ +/* $NetBSD: msg_169.c,v 1.3 2021/01/04 22:41:56 rillig Exp $ */ # 3 "msg_169.c" // Test for message: precedence confusion possible: parenthesize! [169] @@ -146,5 +146,6 @@ expected_precedence(int a, int b, int c) ok = a + b * c; } -// TODO: add a test with unsigned long instead of unsigned, to demonstrate -// that the typo in +// TODO: add a test with unsigned long instead of unsigned, trying to +// demonstrate that the typo in check_precedence_confusion actually has an +// effect. Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.128 src/usr.bin/xlint/lint1/tree.c:1.129 --- src/usr.bin/xlint/lint1/tree.c:1.128 Mon Jan 4 22:33:47 2021 +++ src/usr.bin/xlint/lint1/tree.c Mon Jan 4 22:41:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.128 2021/01/04 22:33:47 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.129 2021/01/04 22:41:56 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.128 2021/01/04 22:33:47 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.129 2021/01/04 22:41:56 rillig Exp $"); #endif #include @@ -4016,6 +4016,19 @@ check_precedence_confusion(tnode_t *tn) * Before fixing this though, there should be a unit test * that demonstrates an actual change in behavior when this * bug gets fixed. + * + * Right now, the condition is always false. To make it true + * after fixing the typo, the right-hand operand must be an + * explicit cast or an implicit conversion that is + * parenthesized. For the right-hand operand itself, this + * would already be done using the line below the loop. + * + * To make a difference, the right-hand operand must not be + * parenthesized, but its indirect cast or conversion must be. + * + * An implicit conversion is never parenthesized. Therefore + * this must be a cast that is later converted, to build a + * chain. */ for (rn = tn->tn_right; tn->tn_op == CVT; rn = rn->tn_left) rparn |= rn->tn_parenthesized;
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Mon Jan 4 22:33:47 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: replace LERROR with lint_assert in check_expr_misc This reduces the visual clutter. There is no reason for anyone to modify the code around the CALL operator, therefore the assertion is not expected to fail anytime soon. To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/usr.bin/xlint/lint1/tree.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/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.127 src/usr.bin/xlint/lint1/tree.c:1.128 --- src/usr.bin/xlint/lint1/tree.c:1.127 Mon Jan 4 22:26:50 2021 +++ src/usr.bin/xlint/lint1/tree.c Mon Jan 4 22:33:47 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.127 2021/01/04 22:26:50 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.128 2021/01/04 22:33:47 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.127 2021/01/04 22:26:50 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.128 2021/01/04 22:33:47 rillig Exp $"); #endif #include @@ -3646,10 +3646,8 @@ check_expr_misc(tnode_t *tn, int vctx, i check_array_index(ln->tn_left, 0); break; case CALL: - if (ln->tn_op != AMPER || ln->tn_left->tn_op != NAME) - LERROR("check_expr_misc(op=%s != %s || %s != %s)", - getopname(ln->tn_op), getopname(AMPER), - getopname(ln->tn_left->tn_op), getopname(NAME)); + lint_assert(ln->tn_op == AMPER); + lint_assert(ln->tn_left->tn_op == NAME); if (!szof) outcall(tn, vctx || tctx, rvdisc); break;
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Mon Jan 4 22:29:01 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: mem1.c Log Message: lint: reduce comment for xgetblk to the actually interesting part To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/xlint/lint1/mem1.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/xlint/lint1/mem1.c diff -u src/usr.bin/xlint/lint1/mem1.c:1.21 src/usr.bin/xlint/lint1/mem1.c:1.22 --- src/usr.bin/xlint/lint1/mem1.c:1.21 Wed Dec 30 10:46:11 2020 +++ src/usr.bin/xlint/lint1/mem1.c Mon Jan 4 22:29:00 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mem1.c,v 1.21 2020/12/30 10:46:11 rillig Exp $ */ +/* $NetBSD: mem1.c,v 1.22 2021/01/04 22:29:00 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: mem1.c,v 1.21 2020/12/30 10:46:11 rillig Exp $"); +__RCSID("$NetBSD: mem1.c,v 1.22 2021/01/04 22:29:00 rillig Exp $"); #endif #include @@ -218,14 +218,7 @@ xnewblk(void) return mb; } -/* - * Allocate new memory. If the first block of the list has not enough - * free space, or there is no first block, get a new block. The new - * block is taken from the free list or, if there is no block on the - * free list, is allocated using xnewblk(). If a new block is allocated - * it is initialized with zero. Blocks taken from the free list are - * zero'd in xfreeblk(). - */ +/* Allocate new memory, initialized with zero. */ static void * xgetblk(mbl_t **mbp, size_t s) { @@ -233,6 +226,16 @@ xgetblk(mbl_t **mbp, size_t s) void *p; size_t t = 0; + /* + * If the first block of the list has not enough free space, + * or there is no first block, get a new block. The new block + * is taken from the free list or, if there is no block on the + * free list, is allocated using xnewblk(). + * + * If a new block is allocated it is initialized with zero. + * Blocks taken from the free list are zero'd in xfreeblk(). + */ + s = WORST_ALIGN(s); if ((mb = *mbp) == NULL || mb->nfree < s) { if ((mb = frmblks) == NULL || mb->size < s) {
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Mon Jan 4 22:26:51 UTC 2021 Modified Files: src/usr.bin/xlint/common: tyname.c src/usr.bin/xlint/lint1: decl.c emit1.c func.c lint1.h main1.c scan.l tree.c src/usr.bin/xlint/lint2: chk.c main2.c read.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: fix typos and other minor stylistic issues To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/xlint/common/tyname.c cvs rdiff -u -r1.110 -r1.111 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.33 -r1.34 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.49 -r1.50 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.52 -r1.53 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.31 -r1.32 src/usr.bin/xlint/lint1/main1.c cvs rdiff -u -r1.111 -r1.112 src/usr.bin/xlint/lint1/scan.l cvs rdiff -u -r1.126 -r1.127 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.31 -r1.32 src/usr.bin/xlint/lint2/chk.c cvs rdiff -u -r1.9 -r1.10 src/usr.bin/xlint/lint2/main2.c cvs rdiff -u -r1.35 -r1.36 src/usr.bin/xlint/lint2/read.c cvs rdiff -u -r1.51 -r1.52 src/usr.bin/xlint/xlint/xlint.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/xlint/common/tyname.c diff -u src/usr.bin/xlint/common/tyname.c:1.21 src/usr.bin/xlint/common/tyname.c:1.22 --- src/usr.bin/xlint/common/tyname.c:1.21 Sun Jan 3 15:55:18 2021 +++ src/usr.bin/xlint/common/tyname.c Mon Jan 4 22:26:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tyname.c,v 1.21 2021/01/03 15:55:18 rillig Exp $ */ +/* $NetBSD: tyname.c,v 1.22 2021/01/04 22:26:50 rillig Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tyname.c,v 1.21 2021/01/03 15:55:18 rillig Exp $"); +__RCSID("$NetBSD: tyname.c,v 1.22 2021/01/04 22:26:50 rillig Exp $"); #endif #include @@ -280,7 +280,7 @@ type_name_of_function(buffer *buf, const #endif } if (tp->t_vararg) { - buf_add(buf, sep), sep = ", "; + buf_add(buf, sep); buf_add(buf, "..."); } buf_add(buf, ") returning "); Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.110 src/usr.bin/xlint/lint1/decl.c:1.111 --- src/usr.bin/xlint/lint1/decl.c:1.110 Sun Jan 3 20:14:38 2021 +++ src/usr.bin/xlint/lint1/decl.c Mon Jan 4 22:26:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.110 2021/01/03 20:14:38 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.111 2021/01/04 22:26:50 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.110 2021/01/03 20:14:38 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.111 2021/01/04 22:26:50 rillig Exp $"); #endif #include @@ -50,7 +50,7 @@ __RCSID("$NetBSD: decl.c,v 1.110 2021/01 const char *unnamed = ""; -/* shared type structures for arithmtic types and void */ +/* shared type structures for arithmetic types and void */ static type_t *typetab; /* value of next enumerator during declaration of enum types */ @@ -672,7 +672,7 @@ popdecl(void) * * This is used to mark compound statements which have, possibly in * nested compound statements, asm statements. For these compound - * statements no warnings about unused or unitialized variables are + * statements no warnings about unused or uninitialized variables are * printed. * * There is no need to clear d_asm in dinfo structs with context AUTO, @@ -877,7 +877,7 @@ merge_type_specifiers(tspec_t t, tspec_t /* * Return the length of a type in bits. * - * Printing a message if the outhermost dimension of an array is 0 must + * Printing a message if the outermost dimension of an array is 0 must * be done by the caller. All other problems are reported by length() * if name is not NULL. */ @@ -977,7 +977,7 @@ lnklst(sym_t *l1, sym_t *l2) * message if it is not. * * Invalid types are: - * - arrays of incomlete types or functions + * - arrays of incomplete types or functions * - functions returning arrays or functions * - void types other than type of function or pointer */ @@ -1898,7 +1898,7 @@ decl1ext(sym_t *dsym, int initflg) if (plibflg && llibflg && dsym->s_type->t_tspec == FUNC && dsym->s_type->t_proto) { /* - * With both LINTLIBRARY and PROTOLIB the prototyp is + * With both LINTLIBRARY and PROTOLIB the prototype is * written as a function definition to the output file. */ rval = dsym->s_type->t_subt->t_tspec != VOID; Index: src/usr.bin/xlint/lint1/emit1.c diff -u src/usr.bin/xlint/lint1/emit1.c:1.33 src/usr.bin/xlint/lint1/emit1.c:1.34 --- src/usr.bin/xlint/lint1/emit1.c:1.33 Sun Jan 3 20:14:38 2021 +++ src/usr.bin/xlint/lint1/emit1.c Mon Jan 4 22:26:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: emit1.c,v 1.33 2021/01/03 20:14:38 rillig Exp $ */ +/* $NetBSD: emit1.c,v 1.34 2021/01/04 2
CVS commit: src/sys/dev/i2c
Module Name:src Committed By: thorpej Date: Mon Jan 4 22:09:35 UTC 2021 Modified Files: src/sys/dev/i2c: files.i2c Added Files: src/sys/dev/i2c: tsllux.c Removed Files: src/sys/dev/i2c: tsl256x.c Log Message: Rename tsl256x.c -> tsllux.c. No other changes are made by this commit. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/sys/dev/i2c/files.i2c cvs rdiff -u -r1.9 -r0 src/sys/dev/i2c/tsl256x.c cvs rdiff -u -r0 -r1.1 src/sys/dev/i2c/tsllux.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/i2c/files.i2c diff -u src/sys/dev/i2c/files.i2c:1.114 src/sys/dev/i2c/files.i2c:1.115 --- src/sys/dev/i2c/files.i2c:1.114 Tue Dec 29 01:47:51 2020 +++ src/sys/dev/i2c/files.i2c Mon Jan 4 22:09:35 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files.i2c,v 1.114 2020/12/29 01:47:51 thorpej Exp $ +# $NetBSD: files.i2c,v 1.115 2021/01/04 22:09:35 thorpej Exp $ obsolete defflag opt_i2cbus.h I2C_SCAN define i2cbus { } @@ -342,7 +342,7 @@ file dev/i2c/imt.cimt # Taos TSL256x ambient light sensor device tsllux: sysmon_envsys attach tsllux at iic -file dev/i2c/tsl256x.c tsllux +file dev/i2c/tsllux.c tsllux # Philips/NXP TEA5767 device tea5767radio : radiodev Added files: Index: src/sys/dev/i2c/tsllux.c diff -u /dev/null src/sys/dev/i2c/tsllux.c:1.1 --- /dev/null Mon Jan 4 22:09:36 2021 +++ src/sys/dev/i2c/tsllux.c Mon Jan 4 22:09:35 2021 @@ -0,0 +1,1049 @@ +/* $NetBSD: tsllux.c,v 1.1 2021/01/04 22:09:35 thorpej Exp $ */ + +/*- + * Copyright (c) 2018 Jason R. Thorpe + * All rights reserved. + * + * 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. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: tsllux.c,v 1.1 2021/01/04 22:09:35 thorpej Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +struct tsllux_softc { + device_t sc_dev; + i2c_tag_t sc_i2c; + i2c_addr_t sc_addr; + + uint32_t sc_poweron; + + /* + * Locking order is: + * tsllux mutex -> i2c bus + */ + kmutex_t sc_lock; + + uint8_t sc_itime; + uint8_t sc_gain; + bool sc_cs_package; + bool sc_auto_gain; + + struct sysmon_envsys *sc_sme; + envsys_data_t sc_sensor; + + struct sysctllog *sc_sysctllog; +}; + +#define TSLLUX_F_CS_PACKAGE 0x01 + +static int tsllux_match(device_t, cfdata_t, void *); +static void tsllux_attach(device_t, device_t, void *); + +CFATTACH_DECL_NEW(tsllux, sizeof(struct tsllux_softc), +tsllux_match, tsllux_attach, NULL, NULL); + +static const struct device_compatible_entry tsllux_compat_data[] = { + { "amstaos,tsl2560", 0 }, + { "amstaos,tsl2561", 0 }, + { NULL,0 } +}; + +static int tsllux_read1(struct tsllux_softc *, uint8_t, uint8_t *); +static int tsllux_read2(struct tsllux_softc *, uint8_t, uint16_t *); +static int tsllux_write1(struct tsllux_softc *, uint8_t, uint8_t); +#if 0 +static int tsllux_write2(struct tsllux_softc *, uint8_t, uint16_t); +#endif + +static void tsllux_sysctl_attach(struct tsllux_softc *); + +static int tsllux_poweron(struct tsllux_softc *); +static int tsllux_poweroff(struct tsllux_softc *); + +static int tsllux_set_integration_time(struct tsllux_softc *, uint8_t); +static int tsllux_set_gain(struct tsllux_softc *, uint8_t); +static int tsllux_set_autogain(struct tsllux_softc *, bool); + +static int tsllux_get_lux(struct tsllux_softc *, uint32_t *, + uint16_t *, uint16_t *); + +static void tsllux_sensors_refresh(struct sysmon_envsys *, envsys_data_t *); + +static int +tsllux_match(device_t parent, cfdata_t match, void *aux) +{ + struct i2c_attach_args *ia = aux; + uint8_t id_re
CVS commit: src/sys/dev/i2c
Module Name:src Committed By: thorpej Date: Mon Jan 4 21:59:49 UTC 2021 Modified Files: src/sys/dev/i2c: tsl256x.c tsl256xreg.h Log Message: Tweak register bit names, in preparation for supporting younger siblings of this chip. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/i2c/tsl256x.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/tsl256xreg.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/i2c/tsl256x.c diff -u src/sys/dev/i2c/tsl256x.c:1.8 src/sys/dev/i2c/tsl256x.c:1.9 --- src/sys/dev/i2c/tsl256x.c:1.8 Wed Jan 15 05:56:57 2020 +++ src/sys/dev/i2c/tsl256x.c Mon Jan 4 21:59:48 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tsl256x.c,v 1.8 2020/01/15 05:56:57 thorpej Exp $ */ +/* $NetBSD: tsl256x.c,v 1.9 2021/01/04 21:59:48 thorpej Exp $ */ /*- * Copyright (c) 2018 Jason R. Thorpe @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tsl256x.c,v 1.8 2020/01/15 05:56:57 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tsl256x.c,v 1.9 2021/01/04 21:59:48 thorpej Exp $"); #include #include @@ -127,7 +127,7 @@ tsllux_match(device_t parent, cfdata_t m if (iic_acquire_bus(ia->ia_tag, 0) != 0) return (0); error = iic_smbus_read_byte(ia->ia_tag, ia->ia_addr, - TSL256x_REG_ID | COMMAND_CMD, &id_reg, 0); + TSL256x_REG_ID | COMMAND6x_CMD, &id_reg, 0); iic_release_bus(ia->ia_tag, 0); if (error) @@ -165,15 +165,15 @@ tsllux_attach(device_t parent, device_t have_i2c = true; /* Power on the device and clear any pending interrupts. */ - if (tsllux_write1(sc, TSL256x_REG_CONTROL | COMMAND_CLEAR, - CONTROL_POWER_ON)) { + if (tsllux_write1(sc, TSL256x_REG_CONTROL | COMMAND6x_CLEAR, + CONTROL6x_POWER_ON)) { aprint_error_dev(self, ": unable to power on device\n"); goto out; } sc->sc_poweron = 1; /* Make sure interrupts are disabled. */ - if (tsllux_write1(sc, TSL256x_REG_INTERRUPT | COMMAND_CLEAR, 0)) { + if (tsllux_write1(sc, TSL256x_REG_INTERRUPT | COMMAND6x_CLEAR, 0)) { aprint_error_dev(self, ": unable to disable interrupts\n"); goto out; } @@ -184,8 +184,8 @@ tsllux_attach(device_t parent, device_t /* Inititalize timing to reasonable defaults. */ sc->sc_auto_gain = true; - sc->sc_gain = TIMING_GAIN_16X; - if (tsllux_set_integration_time(sc, TIMING_INTEG_101ms)) { + sc->sc_gain = TIMING6x_GAIN_16X; + if (tsllux_set_integration_time(sc, TIMING6x_INTEG_101ms)) { aprint_error_dev(self, ": unable to set integration time\n"); goto out; } @@ -289,11 +289,11 @@ tsllux_sysctl_gain(SYSCTLFN_ARGS) mutex_enter(&sc->sc_lock); switch (sc->sc_gain) { - case TIMING_GAIN_1X: + case TIMING6x_GAIN_1X: val = 1; break; - case TIMING_GAIN_16X: + case TIMING6x_GAIN_16X: val = 16; break; @@ -310,11 +310,11 @@ tsllux_sysctl_gain(SYSCTLFN_ARGS) switch (val) { case 1: - new_gain = TIMING_GAIN_1X; + new_gain = TIMING6x_GAIN_1X; break; case 16: - new_gain = TIMING_GAIN_16X; + new_gain = TIMING6x_GAIN_16X; break; default: @@ -349,15 +349,15 @@ tsllux_sysctl_itime(SYSCTLFN_ARGS) mutex_enter(&sc->sc_lock); switch (sc->sc_itime) { - case TIMING_INTEG_13_7ms: + case TIMING6x_INTEG_13_7ms: val = 13; break; - case TIMING_INTEG_101ms: + case TIMING6x_INTEG_101ms: val = 101; break; - case TIMING_INTEG_402ms: + case TIMING6x_INTEG_402ms: default: val = 402; break; @@ -372,15 +372,15 @@ tsllux_sysctl_itime(SYSCTLFN_ARGS) switch (val) { case 13: case 14: - new_itime = TIMING_INTEG_13_7ms; + new_itime = TIMING6x_INTEG_13_7ms; break; case 101: - new_itime = TIMING_INTEG_101ms; + new_itime = TIMING6x_INTEG_101ms; break; case 402: - new_itime = TIMING_INTEG_402ms; + new_itime = TIMING6x_INTEG_402ms; break; default: @@ -478,26 +478,26 @@ tsllux_sensors_refresh(struct sysmon_env /* * Allow pending interrupts to be cleared as part of another operation. */ -#define REGMASK (COMMAND_REGMASK | COMMAND_CLEAR) +#define REGMASK6x (COMMAND6x_REGMASK | COMMAND6x_CLEAR) static int tsllux_read1(struct tsllux_softc *sc, uint8_t reg, uint8_t *valp) { - reg = (reg & REGMASK) | COMMAND_CMD; + reg = (reg & REGMASK6x) | COMMAND6x_CMD; return (iic_smbus_read_byte(sc->sc_i2c, sc->sc_addr, reg, valp, 0)); } static int tsllux_read2(struct tsllux_softc *sc, uint8_t reg, uint16_t *valp) { - reg = (reg & REGMASK) | COMMAND_CMD | COMMAND_WORD; + reg = (reg & REGMASK6x) | COMMAND6x_CMD | COMMAND6x_WORD; return (iic_smbus_read_word(sc->sc_i2c, sc->sc_addr, reg, valp, 0)); } static int tsllux_write1(struct tsllux_softc *sc, uint8_t reg, uint8_t val) { - reg = (reg & REGMASK) | COMMAND_CMD; + reg = (reg & REGMASK6x) | COMMAND6x_CMD; return (iic_smbus_write_byte(sc->sc_i2c, sc->sc_addr, reg, val, 0)); } @@ -505,7 +505,7 @@ tsllux_write1(struct tsllux_softc *sc, u static int tsllux_write2(struct tsllux_softc *sc, uint8_t r
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Mon Jan 4 21:30:07 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: fix bugs in dprint_node in debug mode (since today) The node was dereferenced before the null check. GCC 5.5 didn't warn about this obvious bug, not even with -Wall -Wextra -O2. Such a case didn't occur though in the few tests that this function was used in. The indentation for the nested nodes only needs to be set for a few lines of code, make this region as small as possible. There are nodes that use both tn_left and tn_right, even though they are not defined as binary operators. An example is CALL, for which tn_left is the address of the function name and tn_right, which are the arguments, linked via PUSH nodes. CALL is not a binary operator since it doesn't do any calculations with its arguments. To generate a diff of this commit: cvs rdiff -u -r1.125 -r1.126 src/usr.bin/xlint/lint1/tree.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/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.125 src/usr.bin/xlint/lint1/tree.c:1.126 --- src/usr.bin/xlint/lint1/tree.c:1.125 Mon Jan 4 21:17:31 2021 +++ src/usr.bin/xlint/lint1/tree.c Mon Jan 4 21:30:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.125 2021/01/04 21:17:31 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.126 2021/01/04 21:30:06 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.125 2021/01/04 21:17:31 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.126 2021/01/04 21:30:06 rillig Exp $"); #endif #include @@ -91,64 +91,27 @@ static void check_precedence_confusion(t extern sig_atomic_t fpe; -#if 0 -static char * -dumpnode(char *buf, size_t len, tnode_t *tn) { - const char *n = getopname(tn->tn_op); - const char *s; - - switch (tn->tn_op) { - case NAME: - s = tn->tn_sym->s_name; - break; - case CON: - case STRING: - s = "*"; /* todo */ - break; - default: - s = NULL; - break; - } - char lb[1024]; - char rb[1024]; - - if (s == NULL && tn->tn_left != NULL) - dumpnode(lb, sizeof(lb), tn->tn_left); - else - strcpy(lb, "(null)"); - - if (s == NULL && tn->tn_right != NULL) - dumpnode(rb, sizeof(rb), tn->tn_right); - else - strcpy(rb, "(null)"); - - - snprintf(buf, len, "%s: (%s) = %s [%s, %s]", n, - type_name(tn->tn_type), s, lb, rb); - return buf; -} -#endif - #ifdef DEBUG static void dprint_node(const tnode_t *tn) { static int indent = 0; - op_t op = tn->tn_op; + op_t op; if (tn == NULL) { printf("%*s" "null\n", indent, ""); return; } + op = tn->tn_op; printf("%*s%s: %s%s%s", indent, "", op == CVT && !tn->tn_cast ? "convert" : op == NAME ? "name" : getopname(op), type_name(tn->tn_type), tn->tn_lvalue ? " lvalue" : "", tn->tn_parenthesized ? " ()" : ""); - indent += 2; + if (op == NAME) printf(" %s\n", tn->tn_sym->s_name); else if (op == CON) @@ -157,11 +120,13 @@ dprint_node(const tnode_t *tn) printf(" length=%zu\n", tn->tn_string->st_len); else { printf("\n"); + + indent += 2; dprint_node(tn->tn_left); - if (modtab[op].m_binary) + if (modtab[op].m_binary || tn->tn_right != NULL) dprint_node(tn->tn_right); + indent -= 2; } - indent -= 2; } #else /*ARGSUSED*/
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Mon Jan 4 21:17:31 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: move dprint_node to the top of the file It now resides right below dumpnode, which implements the same idea but uses a fixed-size output buffer and prints everything in a single line, which quickly gets hard to read. Maybe that's the reason why it had been commented out since it got added in 2014. To generate a diff of this commit: cvs rdiff -u -r1.124 -r1.125 src/usr.bin/xlint/lint1/tree.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/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.124 src/usr.bin/xlint/lint1/tree.c:1.125 --- src/usr.bin/xlint/lint1/tree.c:1.124 Mon Jan 4 17:06:20 2021 +++ src/usr.bin/xlint/lint1/tree.c Mon Jan 4 21:17:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.124 2021/01/04 17:06:20 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.125 2021/01/04 21:17:31 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.124 2021/01/04 17:06:20 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.125 2021/01/04 21:17:31 rillig Exp $"); #endif #include @@ -129,6 +129,48 @@ dumpnode(char *buf, size_t len, tnode_t } #endif +#ifdef DEBUG +static void +dprint_node(const tnode_t *tn) +{ + static int indent = 0; + + op_t op = tn->tn_op; + + if (tn == NULL) { + printf("%*s" "null\n", indent, ""); + return; + } + + printf("%*s%s: %s%s%s", + indent, "", + op == CVT && !tn->tn_cast ? "convert" : + op == NAME ? "name" : getopname(op), + type_name(tn->tn_type), tn->tn_lvalue ? " lvalue" : "", + tn->tn_parenthesized ? " ()" : ""); + indent += 2; + if (op == NAME) + printf(" %s\n", tn->tn_sym->s_name); + else if (op == CON) + printf(" value=?\n"); + else if (op == STRING) + printf(" length=%zu\n", tn->tn_string->st_len); + else { + printf("\n"); + dprint_node(tn->tn_left); + if (modtab[op].m_binary) + dprint_node(tn->tn_right); + } + indent -= 2; +} +#else +/*ARGSUSED*/ +static void +dprint_node(const tnode_t *tn) +{ +} +#endif + /* * Increase degree of reference. * This is most often used to change type "T" in type "pointer to T". @@ -3972,48 +4014,6 @@ cat_strings(strg_t *strg1, strg_t *strg2 return strg1; } -#ifdef DEBUG -static void -dprint_node(const tnode_t *tn) -{ - static int indent = 0; - - op_t op = tn->tn_op; - - if (tn == NULL) { - printf("%*s" "null\n", indent, ""); - return; - } - - printf("%*s%s: %s%s%s", - indent, "", - op == CVT && !tn->tn_cast ? "convert" : - op == NAME ? "name" : getopname(op), - type_name(tn->tn_type), tn->tn_lvalue ? " lvalue" : "", - tn->tn_parenthesized ? " ()" : ""); - indent += 2; - if (op == NAME) - printf(" %s\n", tn->tn_sym->s_name); - else if (op == CON) - printf(" value=?\n"); - else if (op == STRING) - printf(" length=%zu\n", tn->tn_string->st_len); - else { - printf("\n"); - dprint_node(tn->tn_left); - if (modtab[op].m_binary) - dprint_node(tn->tn_right); - } - indent -= 2; -} -#else -/*ARGSUSED*/ -static void -dprint_node(const tnode_t *tn) -{ -} -#endif - /* * Print a warning if the given node has operands which should be * parenthesized.
CVS commit: src/share/man/man9
Module Name:src Committed By: pgoyette Date: Mon Jan 4 18:27:47 UTC 2021 Modified Files: src/share/man/man9: malloc.9 Log Message: Better grammar. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/share/man/man9/malloc.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/malloc.9 diff -u src/share/man/man9/malloc.9:1.58 src/share/man/man9/malloc.9:1.59 --- src/share/man/man9/malloc.9:1.58 Thu Jun 4 13:45:19 2020 +++ src/share/man/man9/malloc.9 Mon Jan 4 18:27:46 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: malloc.9,v 1.58 2020/06/04 13:45:19 wiz Exp $ +.\" $NetBSD: malloc.9,v 1.59 2021/01/04 18:27:46 pgoyette Exp $ .\" .\" Copyright (c) 1996, 2003 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd May 30, 2020 +.Dd January 4, 2021 .Dt MALLOC 9 .Os .Sh NAME @@ -227,7 +227,7 @@ Misc temporary data buffers. .El .Pp Other malloc types are defined by the corresponding subsystem; see the -documentation for that subsystem for information its available malloc +documentation for that subsystem for information about its available malloc types. .Sh NOTES The malloc type argument is actually unused on
CVS commit: src/sys/dev/ic
Module Name:src Committed By: riastradh Date: Mon Jan 4 18:27:00 UTC 2021 Modified Files: src/sys/dev/ic: tpm.c tpmreg.h tpmvar.h Log Message: dev/ic/tpm: Take advantage of entropy source if available. If the tpm is deactivated, though, detach the entropy source so we don't continue to try polling it -- it can't be activated without a reboot anyway. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/ic/tpm.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/tpmreg.h cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ic/tpmvar.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/ic/tpm.c diff -u src/sys/dev/ic/tpm.c:1.18 src/sys/dev/ic/tpm.c:1.19 --- src/sys/dev/ic/tpm.c:1.18 Mon Jan 4 18:26:08 2021 +++ src/sys/dev/ic/tpm.c Mon Jan 4 18:26:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tpm.c,v 1.18 2021/01/04 18:26:08 riastradh Exp $ */ +/* $NetBSD: tpm.c,v 1.19 2021/01/04 18:26:59 riastradh Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -48,11 +48,12 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.18 2021/01/04 18:26:08 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.19 2021/01/04 18:26:59 riastradh Exp $"); #include #include +#include #include #include #include @@ -61,6 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.18 #include #include #include +#include #include #include @@ -325,6 +327,179 @@ tpm_tis12_probe(bus_space_tag_t bt, bus_ return 0; } +static void +tpm_tis12_rng_work(struct work *wk, void *cookie) +{ + struct tpm_softc *sc = cookie; + /* + * TPM Specification Version 1.2, Main Part 3: Commands, + * Sec. 13.6 TPM_GetRandom + */ + struct { + struct tpm_header hdr; + uint32_t bytesRequested; + } __packed command; + struct response { + struct tpm_header hdr; + uint32_t randomBytesSize; + uint8_t bytes[64]; + } __packed response; + bool busy, endwrite = false, endread = false; + size_t nread; + uint16_t tag; + uint32_t pktlen, code, nbytes; + int rv; + + /* Acknowledge the request. */ + sc->sc_rndpending = 0; + + /* Lock userland out of the tpm, or fail if it's already open. */ + mutex_enter(&sc->sc_lock); + busy = sc->sc_busy; + sc->sc_busy = true; + mutex_exit(&sc->sc_lock); + if (busy) { /* tough */ + aprint_debug_dev(sc->sc_dev, "%s: device in use\n", __func__); + return; + } + + /* Encode the command. */ + memset(&command, 0, sizeof(command)); + command.hdr.tag = htobe16(TPM_TAG_RQU_COMMAND); + command.hdr.length = htobe32(sizeof(command)); + command.hdr.code = htobe32(TPM_ORD_GetRandom); + command.bytesRequested = htobe32(sizeof(response.bytes)); + + /* Write the command. */ + if ((rv = (*sc->sc_intf->start)(sc, UIO_WRITE)) != 0) { + device_printf(sc->sc_dev, "start write failed, error=%d\n", + rv); + goto out; + } + endwrite = true; + if ((rv = (*sc->sc_intf->write)(sc, &command, sizeof(command))) != 0) { + device_printf(sc->sc_dev, "write failed, error=%d\n", rv); + goto out; + } + rv = (*sc->sc_intf->end)(sc, UIO_WRITE, 0); + endwrite = false; + if (rv) { + device_printf(sc->sc_dev, "end write failed, error=%d\n", rv); + goto out; + } + + /* Read the response header. */ + if ((rv = (*sc->sc_intf->start)(sc, UIO_READ)) != 0) { + device_printf(sc->sc_dev, "start write failed, error=%d\n", + rv); + goto out; + } + endread = true; + if ((rv = (*sc->sc_intf->read)(sc, &response.hdr, sizeof(response.hdr), + &nread, 0)) != 0) { + device_printf(sc->sc_dev, "read failed, error=%d\n", rv); + goto out; + } + + /* Verify the response header looks sensible. */ + if (nread != sizeof(response.hdr)) { + device_printf(sc->sc_dev, "read %zu bytes, expected %zu", + nread, sizeof(response.hdr)); + goto out; + } + tag = be16toh(response.hdr.tag); + pktlen = be32toh(response.hdr.length); + code = be32toh(response.hdr.code); + if (tag != TPM_TAG_RSP_COMMAND || + pktlen < offsetof(struct response, bytes) || + pktlen > sizeof(response) || + code != 0) { + /* + * If the tpm itself is busy (e.g., it has yet to run a + * self-test, or it's in a timeout period to defend + * against brute force attacks), then we can try again + * later. Otherwise, give up. + */ + if (code & TPM_NON_FATAL) { + aprint_debug_dev(sc->sc_dev, "%s: tpm busy, code=%u\n", + __func__, code & ~TPM_NON_FATAL); + rv = 0; + } else if (code == TPM_DEACTIVATED) { + device_printf(sc->sc_dev, "tpm is deactivated\n"); + rv = ENXIO; + } else { + device_printf(sc->sc_dev, "bad tpm response:" + " tag=%u len=%u code=%u\n", tag, pktlen, code); + hexdump(aprint_debug, "tpm response header", + (const void *)&response.hdr, + sizeof(response.hdr)); + rv = EIO; + } + goto out; + } + + /* Read the response payload. */ + if ((rv = (*sc->sc_intf->read)(sc, + (char *)&response + nread, pktlen - nread, + NULL, TPM_PARAM_SIZE)) != 0) { + device_print
CVS commit: src/sys/dev/ic
Module Name:src Committed By: riastradh Date: Mon Jan 4 18:26:08 UTC 2021 Modified Files: src/sys/dev/ic: tpm.c Log Message: dev/ic/tpm: Add missing line break in attach output. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/ic/tpm.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/ic/tpm.c diff -u src/sys/dev/ic/tpm.c:1.17 src/sys/dev/ic/tpm.c:1.18 --- src/sys/dev/ic/tpm.c:1.17 Mon Jan 4 18:22:19 2021 +++ src/sys/dev/ic/tpm.c Mon Jan 4 18:26:08 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tpm.c,v 1.17 2021/01/04 18:22:19 riastradh Exp $ */ +/* $NetBSD: tpm.c,v 1.18 2021/01/04 18:26:08 riastradh Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.17 2021/01/04 18:22:19 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.18 2021/01/04 18:26:08 riastradh Exp $"); #include #include @@ -330,6 +330,9 @@ tpm_tis12_init(struct tpm_softc *sc) { int rv; + aprint_naive("\n"); + aprint_normal("\n"); + sc->sc_caps = bus_space_read_4(sc->sc_bt, sc->sc_bh, TPM_INTF_CAPABILITY); sc->sc_devid = bus_space_read_4(sc->sc_bt, sc->sc_bh, TPM_ID);
CVS commit: src/sys/arch/atari/isa
Module Name:src Committed By: thorpej Date: Mon Jan 4 18:23:10 UTC 2021 Modified Files: src/sys/arch/atari/isa: isa_dma.c Log Message: malloc(9) -> kmem(9) To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/atari/isa/isa_dma.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/arch/atari/isa/isa_dma.c diff -u src/sys/arch/atari/isa/isa_dma.c:1.12 src/sys/arch/atari/isa/isa_dma.c:1.13 --- src/sys/arch/atari/isa/isa_dma.c:1.12 Fri Feb 26 18:16:51 2016 +++ src/sys/arch/atari/isa/isa_dma.c Mon Jan 4 18:23:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: isa_dma.c,v 1.12 2016/02/26 18:16:51 christos Exp $ */ +/* $NetBSD: isa_dma.c,v 1.13 2021/01/04 18:23:10 thorpej Exp $ */ #define ISA_DMA_STATS @@ -33,14 +33,14 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: isa_dma.c,v 1.12 2016/02/26 18:16:51 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: isa_dma.c,v 1.13 2021/01/04 18:23:10 thorpej Exp $"); #include #include #include #include #include -#include +#include #include #include @@ -150,28 +150,11 @@ u_long isa_dma_stats_nbouncebufs; #define STAT_DECR(v) #endif -/* - * Create an ISA DMA map. - */ -int -_isa_bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments, bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamp) +static int +isadma_bounce_cookieflags(bus_dma_tag_t const t, bus_dmamap_t const map, +int const flags) { - struct atari_isa_dma_cookie *cookie; - bus_dmamap_t map; - int error, cookieflags; - void *cookiestore; - size_t cookiesize; - - /* Call common function to create the basic map. */ - error = _bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, - flags, dmamp); - if (error) - return (error); - - map = *dmamp; - map->_dm_cookie = NULL; - - cookiesize = sizeof(struct atari_isa_dma_cookie); + int cookieflags = 0; /* * ISA only has 24-bits of address space. This means @@ -200,41 +183,94 @@ _isa_bus_dmamap_create(bus_dma_tag_t t, /* Bouncing not necessary due to memory size. */ map->_dm_bounce_thresh = 0; } - cookieflags = 0; if (map->_dm_bounce_thresh != 0 || ((map->_dm_size / PAGE_SIZE) + 1) > map->_dm_segcnt) { cookieflags |= ID_MIGHT_NEED_BOUNCE; + } + return cookieflags; +} + +static size_t +isadma_bounce_cookiesize(bus_dmamap_t const map, int cookieflags) +{ + size_t cookiesize = sizeof(struct atari_isa_dma_cookie); + + if (cookieflags & ID_MIGHT_NEED_BOUNCE) { cookiesize += (sizeof(bus_dma_segment_t) * map->_dm_segcnt); } + return cookiesize; +} + +static int +isadma_bounce_cookie_alloc(bus_dma_tag_t const t, bus_dmamap_t const map, +int const flags) +{ + struct atari_isa_dma_cookie *cookie; + int cookieflags = isadma_bounce_cookieflags(t, map, flags); + + if ((cookie = kmem_zalloc(isadma_bounce_cookiesize(map, cookieflags), + (flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP)) == NULL) { + return ENOMEM; + } + + cookie->id_flags = cookieflags; + map->_dm_cookie = cookie; + + return 0; +} + +static void +isadma_bounce_cookie_free(bus_dmamap_t const map) +{ + struct atari_isa_dma_cookie *cookie = map->_dm_cookie; + + if (cookie != NULL) { + kmem_free(map->_dm_cookie, + isadma_bounce_cookiesize(map, cookie->id_flags)); + map->_dm_cookie = NULL; + } +} + +/* + * Create an ISA DMA map. + */ +int +_isa_bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments, bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamp) +{ + struct atari_isa_dma_cookie *cookie; + bus_dmamap_t map; + int error; + + /* Call common function to create the basic map. */ + error = _bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, + flags, dmamp); + if (error) + return (error); + + map = *dmamp; + map->_dm_cookie = NULL; /* * Allocate our cookie. */ - if ((cookiestore = malloc(cookiesize, M_DMAMAP, - (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL) { - error = ENOMEM; + if ((error = isadma_bounce_cookie_alloc(t, map, flags)) != 0) { goto out; } - memset(cookiestore, 0, cookiesize); - cookie = (struct atari_isa_dma_cookie *)cookiestore; - cookie->id_flags = cookieflags; - map->_dm_cookie = cookie; + cookie = map->_dm_cookie; - if (cookieflags & ID_MIGHT_NEED_BOUNCE) { + if (cookie->id_flags & ID_MIGHT_NEED_BOUNCE) { /* * Allocate the bounce pages now if the caller * wishes us to do so. */ - if ((flags & BUS_DMA_ALLOCNOW) == 0) - goto out; - - error = _isa_dma_alloc_bouncebuf(t, map, size, flags); + if (flags & BUS_DMA_ALLOCNOW) { + error = _isa_dma_alloc_bouncebuf(t, map, size, flags); + } } out: if (error) { - if (map->_dm_cookie != NULL) - free(map->_dm_cookie, M_DMAMAP); + isadma_bounce_cookie_free(map); _bus_dmamap_destroy(t, map); } return (error); @@ -254,7 +290,7 @@ _isa_bus_dmamap_destroy(bus_dma_tag_t t, if (cookie->id_flags & ID_HAS_BOUNCE) _isa_
CVS commit: src/sys/dev/ic
Module Name:src Committed By: riastradh Date: Mon Jan 4 18:22:19 UTC 2021 Modified Files: src/sys/dev/ic: tpm.c tpmreg.h tpmvar.h Log Message: dev/ic/tpm: Tidy up headers. - Add include guards. - Add necessary includes. - Sort includes. - Use _BYTE_ORDER, not BYTE_ORDER, for public header. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/ic/tpm.c cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/tpmreg.h cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/tpmvar.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/ic/tpm.c diff -u src/sys/dev/ic/tpm.c:1.16 src/sys/dev/ic/tpm.c:1.17 --- src/sys/dev/ic/tpm.c:1.16 Wed Oct 9 14:03:58 2019 +++ src/sys/dev/ic/tpm.c Mon Jan 4 18:22:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tpm.c,v 1.16 2019/10/09 14:03:58 maxv Exp $ */ +/* $NetBSD: tpm.c,v 1.17 2021/01/04 18:22:19 riastradh Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -48,17 +48,19 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.16 2019/10/09 14:03:58 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.17 2021/01/04 18:22:19 riastradh Exp $"); #include -#include +#include + +#include +#include +#include #include #include -#include -#include -#include -#include #include +#include +#include #include #include Index: src/sys/dev/ic/tpmreg.h diff -u src/sys/dev/ic/tpmreg.h:1.6 src/sys/dev/ic/tpmreg.h:1.7 --- src/sys/dev/ic/tpmreg.h:1.6 Wed Oct 9 07:30:58 2019 +++ src/sys/dev/ic/tpmreg.h Mon Jan 4 18:22:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tpmreg.h,v 1.6 2019/10/09 07:30:58 maxv Exp $ */ +/* $NetBSD: tpmreg.h,v 1.7 2021/01/04 18:22:19 riastradh Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -29,7 +29,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if (BYTE_ORDER == LITTLE_ENDIAN) +#ifndef DEV_IC_TPMREG_H +#define DEV_IC_TPMREG_H + +#include + +#include +#include + +#if (_BYTE_ORDER == _LITTLE_ENDIAN) #define TPM_BE16(a) bswap16(a) #define TPM_BE32(a) bswap32(a) #else @@ -105,3 +113,5 @@ struct tpm_header { * Five localities, 4K per locality. */ #define TPM_SPACE_SIZE 0x5000 + +#endif /* DEV_IC_TPMREG_H */ Index: src/sys/dev/ic/tpmvar.h diff -u src/sys/dev/ic/tpmvar.h:1.7 src/sys/dev/ic/tpmvar.h:1.8 --- src/sys/dev/ic/tpmvar.h:1.7 Wed Oct 9 14:03:58 2019 +++ src/sys/dev/ic/tpmvar.h Mon Jan 4 18:22:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tpmvar.h,v 1.7 2019/10/09 14:03:58 maxv Exp $ */ +/* $NetBSD: tpmvar.h,v 1.8 2021/01/04 18:22:19 riastradh Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -29,6 +29,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#ifndef DEV_IC_TPMVAR_H +#define DEV_IC_TPMVAR_H + +#include + #define TPM_API_VERSION 1 enum tpm_version { @@ -54,6 +59,10 @@ struct tpm_ioc_getinfo { #ifdef _KERNEL +#include +#include +#include + struct tpm_softc; struct tpm_intf { @@ -88,3 +97,5 @@ bool tpm_suspend(device_t, const pmf_qua bool tpm_resume(device_t, const pmf_qual_t *); #endif + +#endif /* DEV_IC_TPMVAR_H */
CVS commit: src/sys/arch/mips/sibyte/dev
Module Name:src Committed By: thorpej Date: Mon Jan 4 18:19:53 UTC 2021 Modified Files: src/sys/arch/mips/sibyte/dev: sbjcn.c sbscn.c Log Message: malloc(9) -> kmem(9) To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/arch/mips/sibyte/dev/sbjcn.c cvs rdiff -u -r1.44 -r1.45 src/sys/arch/mips/sibyte/dev/sbscn.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/arch/mips/sibyte/dev/sbjcn.c diff -u src/sys/arch/mips/sibyte/dev/sbjcn.c:1.31 src/sys/arch/mips/sibyte/dev/sbjcn.c:1.32 --- src/sys/arch/mips/sibyte/dev/sbjcn.c:1.31 Sun Nov 10 21:16:30 2019 +++ src/sys/arch/mips/sibyte/dev/sbjcn.c Mon Jan 4 18:19:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sbjcn.c,v 1.31 2019/11/10 21:16:30 chs Exp $ */ +/* $NetBSD: sbjcn.c,v 1.32 2021/01/04 18:19:53 thorpej Exp $ */ /* * Copyright 2000, 2001 @@ -103,7 +103,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sbjcn.c,v 1.31 2019/11/10 21:16:30 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbjcn.c,v 1.32 2021/01/04 18:19:53 thorpej Exp $"); #define SBJCN_DEBUG @@ -123,7 +123,7 @@ __KERNEL_RCSID(0, "$NetBSD: sbjcn.c,v 1. #include #include #include -#include +#include #include #include @@ -322,7 +322,7 @@ sbjcn_attach_channel(struct sbjcn_softc tp->t_hwiflow = sbjcn_hwiflow; ch->ch_tty = tp; - ch->ch_rbuf = malloc(sbjcn_rbuf_size << 1, M_DEVBUF, M_WAITOK); + ch->ch_rbuf = kmem_alloc(sbjcn_rbuf_size << 1, KM_SLEEP); ch->ch_ebuf = ch->ch_rbuf + (sbjcn_rbuf_size << 1); tty_attach(tp); Index: src/sys/arch/mips/sibyte/dev/sbscn.c diff -u src/sys/arch/mips/sibyte/dev/sbscn.c:1.44 src/sys/arch/mips/sibyte/dev/sbscn.c:1.45 --- src/sys/arch/mips/sibyte/dev/sbscn.c:1.44 Sun Nov 10 21:16:30 2019 +++ src/sys/arch/mips/sibyte/dev/sbscn.c Mon Jan 4 18:19:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sbscn.c,v 1.44 2019/11/10 21:16:30 chs Exp $ */ +/* $NetBSD: sbscn.c,v 1.45 2021/01/04 18:19:53 thorpej Exp $ */ /* * Copyright 2000, 2001 @@ -109,7 +109,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sbscn.c,v 1.44 2019/11/10 21:16:30 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbscn.c,v 1.45 2021/01/04 18:19:53 thorpej Exp $"); #define SBSCN_DEBUG @@ -133,7 +133,7 @@ __KERNEL_RCSID(0, "$NetBSD: sbscn.c,v 1. #include #include #include -#include +#include #include #include #include @@ -352,7 +352,7 @@ sbscn_attach_channel(struct sbscn_softc tp->t_hwiflow = sbscn_hwiflow; ch->ch_tty = tp; - ch->ch_rbuf = malloc(sbscn_rbuf_size << 1, M_DEVBUF, M_WAITOK); + ch->ch_rbuf = kmem_alloc(sbscn_rbuf_size << 1, KM_SLEEP); ch->ch_ebuf = ch->ch_rbuf + (sbscn_rbuf_size << 1); tty_attach(tp);
CVS commit: src/sys/arch/mips/ralink
Module Name:src Committed By: thorpej Date: Mon Jan 4 18:14:38 UTC 2021 Modified Files: src/sys/arch/mips/ralink: ralink_intr.c Log Message: malloc(9) -> kmem(9) To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/mips/ralink/ralink_intr.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/arch/mips/ralink/ralink_intr.c diff -u src/sys/arch/mips/ralink/ralink_intr.c:1.6 src/sys/arch/mips/ralink/ralink_intr.c:1.7 --- src/sys/arch/mips/ralink/ralink_intr.c:1.6 Sun Nov 10 21:16:30 2019 +++ src/sys/arch/mips/ralink/ralink_intr.c Mon Jan 4 18:14:38 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ralink_intr.c,v 1.6 2019/11/10 21:16:30 chs Exp $ */ +/* $NetBSD: ralink_intr.c,v 1.7 2021/01/04 18:14:38 thorpej Exp $ */ /*- * Copyright (c) 2011 CradlePoint Technology, Inc. * All rights reserved. @@ -29,14 +29,14 @@ #define __INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: ralink_intr.c,v 1.6 2019/11/10 21:16:30 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ralink_intr.c,v 1.7 2021/01/04 18:14:38 thorpej Exp $"); #include #include #include #include #include -#include +#include #include #include @@ -267,7 +267,7 @@ ra_intr_establish(int intr, int (*func)( { struct evbmips_intrhand *ih; - ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK); + ih = kmem_alloc(sizeof(*ih), KM_SLEEP); ih->ih_func = func; ih->ih_arg = arg; ih->ih_irq = intr; @@ -310,7 +310,7 @@ ra_intr_disestablish(void *arg) splx(s); - free(ih, M_DEVBUF); + kmem_free(ih, sizeof(*ih)); } /*
CVS commit: src/sys/arch/mips/adm5120
Module Name:src Committed By: thorpej Date: Mon Jan 4 18:11:26 UTC 2021 Modified Files: src/sys/arch/mips/adm5120: adm5120_intr.c Log Message: malloc(9) -> kmem(9) To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/mips/adm5120/adm5120_intr.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/arch/mips/adm5120/adm5120_intr.c diff -u src/sys/arch/mips/adm5120/adm5120_intr.c:1.8 src/sys/arch/mips/adm5120/adm5120_intr.c:1.9 --- src/sys/arch/mips/adm5120/adm5120_intr.c:1.8 Sun Nov 10 21:16:29 2019 +++ src/sys/arch/mips/adm5120/adm5120_intr.c Mon Jan 4 18:11:26 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: adm5120_intr.c,v 1.8 2019/11/10 21:16:29 chs Exp $ */ +/* $NetBSD: adm5120_intr.c,v 1.9 2021/01/04 18:11:26 thorpej Exp $ */ /*- * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko. @@ -67,14 +67,14 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: adm5120_intr.c,v 1.8 2019/11/10 21:16:29 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: adm5120_intr.c,v 1.9 2021/01/04 18:11:26 thorpej Exp $"); #include "opt_ddb.h" #define __INTR_PRIVATE #include #include -#include +#include #include #include @@ -191,7 +191,7 @@ adm5120_intr_establish(int irq, int prio if (irq < 0 || irq >= NIRQS) panic("adm5120_intr_establish: bogus IRQ %d", irq); - ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK); + ih = kmem_alloc(sizeof(*ih), KM_SLEEP); ih->ih_func = func; ih->ih_arg = arg; ih->ih_irq = irq; @@ -259,7 +259,7 @@ adm5120_intr_disestablish(void *cookie) splx(s); - free(ih, M_DEVBUF); + kmem_free(ih, sizeof(*ih)); } void evbmips_iointr(int ipl, uint32_t ipending, struct clockframe *cf)
CVS commit: src/sys/arch/mips/mips
Module Name:src Committed By: thorpej Date: Mon Jan 4 18:09:01 UTC 2021 Modified Files: src/sys/arch/mips/mips: bus_dma.c Log Message: malloc(9) -> kmem(9) To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/arch/mips/mips/bus_dma.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/arch/mips/mips/bus_dma.c diff -u src/sys/arch/mips/mips/bus_dma.c:1.42 src/sys/arch/mips/mips/bus_dma.c:1.43 --- src/sys/arch/mips/mips/bus_dma.c:1.42 Thu Jul 16 13:32:05 2020 +++ src/sys/arch/mips/mips/bus_dma.c Mon Jan 4 18:09:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_dma.c,v 1.42 2020/07/16 13:32:05 simonb Exp $ */ +/* $NetBSD: bus_dma.c,v 1.43 2021/01/04 18:09:01 thorpej Exp $ */ /*- * Copyright (c) 1997, 1998, 2001, 2020 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.42 2020/07/16 13:32:05 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.43 2021/01/04 18:09:01 thorpej Exp $"); #define _MIPS_BUS_DMA_PRIVATE @@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v #include #include #include -#include +#include #include #include #include @@ -285,6 +285,22 @@ _bus_dma_load_bouncebuf(bus_dma_tag_t t, } #endif /* _MIPS_NEED_BUS_DMA_BOUNCE */ +static size_t +_bus_dmamap_mapsize(int const nsegments) +{ + KASSERT(nsegments > 0); + return sizeof(struct mips_bus_dmamap) + + (sizeof(bus_dma_segment_t) * (nsegments - 1)); +} + +static size_t +_bus_dmamap_cookiesize(int const nsegments) +{ + KASSERT(nsegments > 0); + return sizeof(struct mips_bus_dma_cookie) + + (sizeof(bus_dma_segment_t) * nsegments); +} + /* * Common function for DMA map creation. May be called by bus-specific * DMA map creation functions. @@ -295,9 +311,8 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_ { struct mips_bus_dmamap *map; void *mapstore; - size_t mapsize; - const int mallocflags = M_ZERO | - ((flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK); + const int allocflags = + ((flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP); int error = 0; @@ -313,9 +328,8 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_ * The bus_dmamap_t includes one bus_dma_segment_t, hence * the (nsegments - 1). */ - mapsize = sizeof(struct mips_bus_dmamap) + - (sizeof(bus_dma_segment_t) * (nsegments - 1)); - if ((mapstore = malloc(mapsize, M_DMAMAP, mallocflags)) == NULL) + if ((mapstore = kmem_zalloc(_bus_dmamap_mapsize(nsegments), + allocflags)) == NULL) return (ENOMEM); map = mapstore; @@ -336,7 +350,6 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_ struct mips_bus_dma_cookie *cookie; int cookieflags; void *cookiestore; - size_t cookiesize; if (t->_bounce_thresh == 0 || _BUS_AVAIL_END <= t->_bounce_thresh) map->_dm_bounce_thresh = 0; @@ -356,13 +369,11 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_ return 0; } - cookiesize = sizeof(struct mips_bus_dma_cookie) + - (sizeof(bus_dma_segment_t) * map->_dm_segcnt); - /* * Allocate our cookie. */ - if ((cookiestore = malloc(cookiesize, M_DMAMAP, mallocflags)) == NULL) { + if ((cookiestore = kmem_zalloc(_bus_dmamap_cookiesize(nsegments), + allocflags)) == NULL) { error = ENOMEM; goto out; } @@ -403,13 +414,13 @@ _bus_dmamap_destroy(bus_dma_tag_t t, bus if (cookie->id_flags & _BUS_DMA_HAS_BOUNCE) _bus_dma_free_bouncebuf(t, map); STAT_INCR(bounced_destroys); - free(cookie, M_DMAMAP); + kmem_free(cookie, _bus_dmamap_cookiesize(map->_dm_segcnt)); } else #endif STAT_INCR(destroys); if (map->dm_nsegs > 0) STAT_INCR(unloads); - free(map, M_DMAMAP); + kmem_free(map, _bus_dmamap_mapsize(map->_dm_segcnt)); } /* @@ -1325,8 +1336,8 @@ _bus_dmatag_subregion(bus_dma_tag_t tag, return 0; } - if ((*newtag = malloc(sizeof(struct mips_bus_dma_tag), M_DMAMAP, - (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL) + if ((*newtag = kmem_alloc(sizeof(struct mips_bus_dma_tag), + (flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP)) == NULL) return ENOMEM; **newtag = *tag; @@ -1354,7 +1365,7 @@ _bus_dmatag_destroy(bus_dma_tag_t tag) case 0: break;/* not allocated with malloc */ case 1: - free(tag, M_DMAMAP); /* last reference to tag */ + kmem_free(tag, sizeof(*tag)); /* last reference to tag */ break; default: (tag->_tag_needs_free)--; /* one less reference */
CVS commit: src/sys/arch/mips/atheros
Module Name:src Committed By: thorpej Date: Mon Jan 4 17:42:29 UTC 2021 Modified Files: src/sys/arch/mips/atheros: ar_intr.c src/sys/arch/mips/atheros/dev: arspi.c athflash.c Log Message: malloc(9) -> kmem(9) To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/mips/atheros/ar_intr.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/mips/atheros/dev/arspi.c cvs rdiff -u -r1.11 -r1.12 src/sys/arch/mips/atheros/dev/athflash.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/arch/mips/atheros/ar_intr.c diff -u src/sys/arch/mips/atheros/ar_intr.c:1.6 src/sys/arch/mips/atheros/ar_intr.c:1.7 --- src/sys/arch/mips/atheros/ar_intr.c:1.6 Sun Nov 10 21:16:29 2019 +++ src/sys/arch/mips/atheros/ar_intr.c Mon Jan 4 17:42:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ar_intr.c,v 1.6 2019/11/10 21:16:29 chs Exp $ */ +/* $NetBSD: ar_intr.c,v 1.7 2021/01/04 17:42:29 thorpej Exp $ */ /* * Copyright (c) 2006 Urbana-Champaign Independent Media Center. * Copyright (c) 2006 Garrett D'Amore. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ar_intr.c,v 1.6 2019/11/10 21:16:29 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ar_intr.c,v 1.7 2021/01/04 17:42:29 thorpej Exp $"); #define __INTR_PRIVATE @@ -49,7 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: ar_intr.c,v #include #include #include -#include +#include #include #include @@ -110,7 +110,7 @@ genath_cpu_intr_establish(int intr, int { struct atheros_intrhand *ih; - ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK); + ih = kmem_alloc(sizeof(*ih), KM_SLEEP); ih->ih_func = func; ih->ih_arg = arg; ih->ih_irq = intr; @@ -138,7 +138,7 @@ genath_cpu_intr_disestablish(void *arg) LIST_REMOVE(ih, ih_q); splx(s); - free(ih, M_DEVBUF); + kmem_free(ih, sizeof(*ih)); } static void * @@ -150,7 +150,7 @@ genath_misc_intr_establish(int irq, int int s; - ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK); + ih = kmem_alloc(sizeof(*ih), KM_SLEEP); ih->ih_func = func; ih->ih_arg = arg; ih->ih_irq = irq; @@ -188,7 +188,7 @@ genath_misc_intr_disestablish(void *arg) } splx(s); - free(ih, M_DEVBUF); + kmem_free(ih, sizeof(*ih)); } Index: src/sys/arch/mips/atheros/dev/arspi.c diff -u src/sys/arch/mips/atheros/dev/arspi.c:1.12 src/sys/arch/mips/atheros/dev/arspi.c:1.13 --- src/sys/arch/mips/atheros/dev/arspi.c:1.12 Tue Aug 13 17:03:11 2019 +++ src/sys/arch/mips/atheros/dev/arspi.c Mon Jan 4 17:42:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: arspi.c,v 1.12 2019/08/13 17:03:11 tnn Exp $ */ +/* $NetBSD: arspi.c,v 1.13 2021/01/04 17:42:29 thorpej Exp $ */ /*- * Copyright (c) 2006 Urbana-Champaign Independent Media Center. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: arspi.c,v 1.12 2019/08/13 17:03:11 tnn Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arspi.c,v 1.13 2021/01/04 17:42:29 thorpej Exp $"); #include "locators.h" @@ -52,7 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: arspi.c,v 1. #include #include #include -#include +#include #include #include @@ -260,8 +260,9 @@ arspi_transfer(void *cookie, struct spi_ st->st_busprivate = NULL; if ((rv = arspi_make_job(st)) != 0) { if (st->st_busprivate) { - free(st->st_busprivate, M_DEVBUF); + struct arspi_job *job = st->st_busprivate; st->st_busprivate = NULL; + kmem_free(job, sizeof(*job)); } spi_done(st, rv); return rv; @@ -382,7 +383,7 @@ arspi_done(struct arspi_softc *sc, int e sc->sc_transfer = NULL; st->st_busprivate = NULL; spi_done(st, err); - free(job, M_DEVBUF); + kmem_free(job, sizeof(*job)); } } done: @@ -470,10 +471,7 @@ arspi_make_job(struct spi_transfer *st) uint8_t byte; int i, rv; - job = malloc(sizeof (struct arspi_job), M_DEVBUF, M_ZERO); - if (job == NULL) { - return ENOMEM; - } + job = kmem_zalloc(sizeof (struct arspi_job), KM_SLEEP); st->st_busprivate = job; Index: src/sys/arch/mips/atheros/dev/athflash.c diff -u src/sys/arch/mips/atheros/dev/athflash.c:1.11 src/sys/arch/mips/atheros/dev/athflash.c:1.12 --- src/sys/arch/mips/atheros/dev/athflash.c:1.11 Sun Nov 10 21:16:30 2019 +++ src/sys/arch/mips/atheros/dev/athflash.c Mon Jan 4 17:42:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: athflash.c,v 1.11 2019/11/10 21:16:30 chs Exp $ */ +/* $NetBSD: athflash.c,v 1.12 2021/01/04 17:42:29 thorpej Exp $ */ /* * Copyright (c) 2006 Urbana-Champaign Independent Media Center. @@ -82,13 +82,13 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: athflash.c,v 1.11 2019/11/10 21:16:30 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: athflash.c,v 1.12 2021/01/04 17:42:29 thorpej Exp $"); #include #include #include #include -#include +#include #include #include @@ -251,7 +251,7 @@ flash_attach(device_t parent, device_t s sc->sc_size = flash_ids[i].flash_size; sc->sc_sector_size = flash_ids[i].sector_size; - sc->sc_buf = malloc(sc->sc_sector_size, M_DEVBUF, M_WAITOK); + sc
CVS commit: src/sys/arch/mips/alchemy
Module Name:src Committed By: thorpej Date: Mon Jan 4 17:35:12 UTC 2021 Modified Files: src/sys/arch/mips/alchemy: au_himem_space.c au_icu.c au_wired_space.c Log Message: malloc(9) -> kmem(9) To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/mips/alchemy/au_himem_space.c cvs rdiff -u -r1.30 -r1.31 src/sys/arch/mips/alchemy/au_icu.c cvs rdiff -u -r1.10 -r1.11 src/sys/arch/mips/alchemy/au_wired_space.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/arch/mips/alchemy/au_himem_space.c diff -u src/sys/arch/mips/alchemy/au_himem_space.c:1.15 src/sys/arch/mips/alchemy/au_himem_space.c:1.16 --- src/sys/arch/mips/alchemy/au_himem_space.c:1.15 Sun Nov 10 21:16:29 2019 +++ src/sys/arch/mips/alchemy/au_himem_space.c Mon Jan 4 17:35:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: au_himem_space.c,v 1.15 2019/11/10 21:16:29 chs Exp $ */ +/* $NetBSD: au_himem_space.c,v 1.16 2021/01/04 17:35:12 thorpej Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: au_himem_space.c,v 1.15 2019/11/10 21:16:29 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: au_himem_space.c,v 1.16 2021/01/04 17:35:12 thorpej Exp $"); /* * This provides mappings for the upper I/O regions used on some @@ -73,7 +73,7 @@ __KERNEL_RCSID(0, "$NetBSD: au_himem_spa #include #include #include -#include +#include #include #include @@ -692,8 +692,7 @@ au_himem_space_init(bus_space_tag_t bst, { au_himem_cookie_t *c; - c = malloc(sizeof (struct au_himem_cookie), M_DEVBUF, - M_WAITOK | M_ZERO); + c = kmem_zalloc(sizeof (struct au_himem_cookie), KM_SLEEP); c->c_name = name; c->c_start = start; c->c_end = end; Index: src/sys/arch/mips/alchemy/au_icu.c diff -u src/sys/arch/mips/alchemy/au_icu.c:1.30 src/sys/arch/mips/alchemy/au_icu.c:1.31 --- src/sys/arch/mips/alchemy/au_icu.c:1.30 Sun Nov 10 21:16:29 2019 +++ src/sys/arch/mips/alchemy/au_icu.c Mon Jan 4 17:35:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: au_icu.c,v 1.30 2019/11/10 21:16:29 chs Exp $ */ +/* $NetBSD: au_icu.c,v 1.31 2021/01/04 17:35:12 thorpej Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: au_icu.c,v 1.30 2019/11/10 21:16:29 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: au_icu.c,v 1.31 2021/01/04 17:35:12 thorpej Exp $"); #include "opt_ddb.h" #define __INTR_PRIVATE @@ -78,7 +78,7 @@ __KERNEL_RCSID(0, "$NetBSD: au_icu.c,v 1 #include #include #include -#include +#include #include #include @@ -199,7 +199,7 @@ au_intr_establish(int irq, int req, int if (req > 1) panic("au_intr_establish: bogus request %d", req); - ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK); + ih = kmem_alloc(sizeof(*ih), KM_SLEEP); ih->ih_func = func; ih->ih_arg = arg; ih->ih_irq = irq; @@ -305,7 +305,7 @@ au_intr_disestablish(void *cookie) splx(s); - free(ih, M_DEVBUF); + kmem_free(ih, sizeof(*ih)); } void Index: src/sys/arch/mips/alchemy/au_wired_space.c diff -u src/sys/arch/mips/alchemy/au_wired_space.c:1.10 src/sys/arch/mips/alchemy/au_wired_space.c:1.11 --- src/sys/arch/mips/alchemy/au_wired_space.c:1.10 Sun Nov 10 21:16:29 2019 +++ src/sys/arch/mips/alchemy/au_wired_space.c Mon Jan 4 17:35:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: au_wired_space.c,v 1.10 2019/11/10 21:16:29 chs Exp $ */ +/* $NetBSD: au_wired_space.c,v 1.11 2021/01/04 17:35:12 thorpej Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: au_wired_space.c,v 1.10 2019/11/10 21:16:29 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: au_wired_space.c,v 1.11 2021/01/04 17:35:12 thorpej Exp $"); /* * This provides mappings for the upper I/O regions used on some @@ -72,7 +72,7 @@ __KERNEL_RCSID(0, "$NetBSD: au_wired_spa #include #include #include -#include +#include #include #include @@ -632,8 +632,7 @@ au_wired_space_init(bus_space_tag_t bst, { au_wired_cookie_t *c; - c = malloc(sizeof (struct au_wired_cookie), M_DEVBUF, - M_WAITOK | M_ZERO); + c = kmem_zalloc(sizeof (struct au_wired_cookie), KM_SLEEP); c->c_pbase = paddr; c->c_name = name; c->c_start = start;
CVS commit: src/sys/arch/mips/cavium/dev
Module Name:src Committed By: thorpej Date: Mon Jan 4 17:22:59 UTC 2021 Modified Files: src/sys/arch/mips/cavium/dev: octeon_asx.c octeon_fpa.c octeon_gmx.c octeon_ipd.c octeon_pip.c octeon_pko.c Log Message: malloc(9) -> kmem(9) To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/mips/cavium/dev/octeon_asx.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/mips/cavium/dev/octeon_fpa.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/mips/cavium/dev/octeon_gmx.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/mips/cavium/dev/octeon_ipd.c cvs rdiff -u -r1.9 -r1.10 src/sys/arch/mips/cavium/dev/octeon_pip.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/mips/cavium/dev/octeon_pko.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/arch/mips/cavium/dev/octeon_asx.c diff -u src/sys/arch/mips/cavium/dev/octeon_asx.c:1.4 src/sys/arch/mips/cavium/dev/octeon_asx.c:1.5 --- src/sys/arch/mips/cavium/dev/octeon_asx.c:1.4 Tue Jun 23 05:14:18 2020 +++ src/sys/arch/mips/cavium/dev/octeon_asx.c Mon Jan 4 17:22:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: octeon_asx.c,v 1.4 2020/06/23 05:14:18 simonb Exp $ */ +/* $NetBSD: octeon_asx.c,v 1.5 2021/01/04 17:22:59 thorpej Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -27,11 +27,11 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: octeon_asx.c,v 1.4 2020/06/23 05:14:18 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: octeon_asx.c,v 1.5 2021/01/04 17:22:59 thorpej Exp $"); #include #include -#include +#include #include #include #include @@ -43,7 +43,7 @@ octasx_init(struct octasx_attach_args *a struct octasx_softc *sc; int status; - sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); + sc = kmem_zalloc(sizeof(*sc), KM_SLEEP); if (sc == NULL) panic("can't allocate memory: %s", __func__); Index: src/sys/arch/mips/cavium/dev/octeon_fpa.c diff -u src/sys/arch/mips/cavium/dev/octeon_fpa.c:1.8 src/sys/arch/mips/cavium/dev/octeon_fpa.c:1.9 --- src/sys/arch/mips/cavium/dev/octeon_fpa.c:1.8 Tue Jun 23 05:14:18 2020 +++ src/sys/arch/mips/cavium/dev/octeon_fpa.c Mon Jan 4 17:22:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: octeon_fpa.c,v 1.8 2020/06/23 05:14:18 simonb Exp $ */ +/* $NetBSD: octeon_fpa.c,v 1.9 2021/01/04 17:22:59 thorpej Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -29,12 +29,12 @@ #undef FPADEBUG #include -__KERNEL_RCSID(0, "$NetBSD: octeon_fpa.c,v 1.8 2020/06/23 05:14:18 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: octeon_fpa.c,v 1.9 2021/01/04 17:22:59 thorpej Exp $"); #include #include #include -#include +#include #include #include @@ -113,10 +113,8 @@ octfpa_buf_init(int poolno, size_t size, paddr_t paddr; nsegs = 1/* XXX */; - fb = malloc(sizeof(*fb) + sizeof(*fb->fb_dma_segs) * nsegs, M_DEVBUF, - M_WAITOK | M_ZERO); - if (fb == NULL) - return 1; + fb = kmem_zalloc(sizeof(*fb) + sizeof(*fb->fb_dma_segs) * nsegs, + KM_SLEEP); fb->fb_poolno = poolno; fb->fb_size = size; fb->fb_nelems = nelems; Index: src/sys/arch/mips/cavium/dev/octeon_gmx.c diff -u src/sys/arch/mips/cavium/dev/octeon_gmx.c:1.15 src/sys/arch/mips/cavium/dev/octeon_gmx.c:1.16 --- src/sys/arch/mips/cavium/dev/octeon_gmx.c:1.15 Tue Jun 23 05:17:13 2020 +++ src/sys/arch/mips/cavium/dev/octeon_gmx.c Mon Jan 4 17:22:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: octeon_gmx.c,v 1.15 2020/06/23 05:17:13 simonb Exp $ */ +/* $NetBSD: octeon_gmx.c,v 1.16 2021/01/04 17:22:59 thorpej Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: octeon_gmx.c,v 1.15 2020/06/23 05:17:13 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: octeon_gmx.c,v 1.16 2021/01/04 17:22:59 thorpej Exp $"); #include #include @@ -36,7 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: octeon_gmx.c #include #include #include -#include +#include #include #include @@ -218,8 +218,8 @@ octgmx_attach(device_t parent, device_t octgmx_init(sc); - sc->sc_ports = malloc(sizeof(*sc->sc_ports) * sc->sc_nports, M_DEVBUF, - M_WAITOK | M_ZERO); + sc->sc_ports = kmem_zalloc(sizeof(*sc->sc_ports) * sc->sc_nports, + KM_SLEEP); for (i = 0; i < sc->sc_nports; i++) { port = GMX_PORT_NUM(sc->sc_unitno, i); Index: src/sys/arch/mips/cavium/dev/octeon_ipd.c diff -u src/sys/arch/mips/cavium/dev/octeon_ipd.c:1.7 src/sys/arch/mips/cavium/dev/octeon_ipd.c:1.8 --- src/sys/arch/mips/cavium/dev/octeon_ipd.c:1.7 Tue Jun 23 05:15:33 2020 +++ src/sys/arch/mips/cavium/dev/octeon_ipd.c Mon Jan 4 17:22:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: octeon_ipd.c,v 1.7 2020/06/23 05:15:33 simonb Exp $ */ +/* $NetBSD: octeon_ipd.c,v 1.8 2021/01/04 17:22:59 thorpej Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -27,11 +27,11 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: octeon_ipd.c,v 1.7 2020/06/23 05:15:33 simonb Exp $"); +__KERNEL_RCSID(0, "$Net
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Mon Jan 4 17:06:21 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: in debug mode, print node tree for precedence >From the code alone, it is too difficult to see how the various internal operators are combined and what properties they have. A simple tree visualization helps to see all the details. This is used to track down the typo in check_precedence_confusion, to see whether it could have possibly had any influence at all. To generate a diff of this commit: cvs rdiff -u -r1.123 -r1.124 src/usr.bin/xlint/lint1/tree.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/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.123 src/usr.bin/xlint/lint1/tree.c:1.124 --- src/usr.bin/xlint/lint1/tree.c:1.123 Mon Jan 4 15:52:51 2021 +++ src/usr.bin/xlint/lint1/tree.c Mon Jan 4 17:06:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.123 2021/01/04 15:52:51 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.124 2021/01/04 17:06:20 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.123 2021/01/04 15:52:51 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.124 2021/01/04 17:06:20 rillig Exp $"); #endif #include @@ -3972,6 +3972,48 @@ cat_strings(strg_t *strg1, strg_t *strg2 return strg1; } +#ifdef DEBUG +static void +dprint_node(const tnode_t *tn) +{ + static int indent = 0; + + op_t op = tn->tn_op; + + if (tn == NULL) { + printf("%*s" "null\n", indent, ""); + return; + } + + printf("%*s%s: %s%s%s", + indent, "", + op == CVT && !tn->tn_cast ? "convert" : + op == NAME ? "name" : getopname(op), + type_name(tn->tn_type), tn->tn_lvalue ? " lvalue" : "", + tn->tn_parenthesized ? " ()" : ""); + indent += 2; + if (op == NAME) + printf(" %s\n", tn->tn_sym->s_name); + else if (op == CON) + printf(" value=?\n"); + else if (op == STRING) + printf(" length=%zu\n", tn->tn_string->st_len); + else { + printf("\n"); + dprint_node(tn->tn_left); + if (modtab[op].m_binary) + dprint_node(tn->tn_right); + } + indent -= 2; +} +#else +/*ARGSUSED*/ +static void +dprint_node(const tnode_t *tn) +{ +} +#endif + /* * Print a warning if the given node has operands which should be * parenthesized. @@ -3999,6 +4041,8 @@ check_precedence_confusion(tnode_t *tn) lparn |= ln->tn_parenthesized; lop = ln->tn_op; + dprint_node(tn); + if (mp->m_binary) { rparn = 0; /*
CVS commit: src/sys/dev
Module Name:src Committed By: mlelstv Date: Mon Jan 4 16:17:26 UTC 2021 Modified Files: src/sys/dev: vnd.c Log Message: Fix calculation of cylinder count from medium size. Pullups needed. To generate a diff of this commit: cvs rdiff -u -r1.277 -r1.278 src/sys/dev/vnd.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/vnd.c diff -u src/sys/dev/vnd.c:1.277 src/sys/dev/vnd.c:1.278 --- src/sys/dev/vnd.c:1.277 Thu Apr 23 09:40:08 2020 +++ src/sys/dev/vnd.c Mon Jan 4 16:17:26 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.277 2020/04/23 09:40:08 jdolecek Exp $ */ +/* $NetBSD: vnd.c,v 1.278 2021/01/04 16:17:26 mlelstv Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008, 2020 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.277 2020/04/23 09:40:08 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.278 2021/01/04 16:17:26 mlelstv Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -1456,8 +1456,9 @@ vndioctl(dev_t dev, u_long cmd, void *da * Compute missing cylinder count from size */ if (vnd->sc_geom.vng_ncylinders == 0) -vnd->sc_geom.vng_ncylinders = vnd->sc_size / - (vnd->sc_geom.vng_ntracks * +vnd->sc_geom.vng_ncylinders = vnd->sc_size / ( + (vnd->sc_geom.vng_secsize / DEV_BSIZE) * + vnd->sc_geom.vng_ntracks * vnd->sc_geom.vng_nsectors); /*
CVS commit: src/sys/arch/ibmnws/ibmnws
Module Name:src Committed By: thorpej Date: Mon Jan 4 15:56:24 UTC 2021 Modified Files: src/sys/arch/ibmnws/ibmnws: mainbus.c Log Message: malloc(9) -> kmem(9) To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/ibmnws/ibmnws/mainbus.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/arch/ibmnws/ibmnws/mainbus.c diff -u src/sys/arch/ibmnws/ibmnws/mainbus.c:1.14 src/sys/arch/ibmnws/ibmnws/mainbus.c:1.15 --- src/sys/arch/ibmnws/ibmnws/mainbus.c:1.14 Tue Jul 7 03:38:47 2020 +++ src/sys/arch/ibmnws/ibmnws/mainbus.c Mon Jan 4 15:56:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.14 2020/07/07 03:38:47 thorpej Exp $ */ +/* $NetBSD: mainbus.c,v 1.15 2021/01/04 15:56:24 thorpej Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include @@ -120,8 +120,7 @@ mainbus_attach(device_t parent, device_t * XXX that's not currently possible. */ #if NPCI > 0 - genppc_pct = malloc(sizeof(struct genppc_pci_chipset), M_DEVBUF, - M_WAITOK); + genppc_pct = kmem_alloc(sizeof(struct genppc_pci_chipset), KM_SLEEP); ibmnws_pci_get_chipset_tag_indirect (genppc_pct); #ifdef PCI_NETBSD_CONFIGURE
CVS commit: src
Module Name:src Committed By: rillig Date: Mon Jan 4 15:52:51 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_169.c msg_169.exp src/usr.bin/xlint/lint1: tree.c Log Message: lint: add test for "precedence confusion possible [169]" To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_169.c \ src/tests/usr.bin/xlint/lint1/msg_169.exp cvs rdiff -u -r1.122 -r1.123 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_169.c diff -u src/tests/usr.bin/xlint/lint1/msg_169.c:1.1 src/tests/usr.bin/xlint/lint1/msg_169.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_169.c:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_169.c Mon Jan 4 15:52:51 2021 @@ -1,7 +1,150 @@ -/* $NetBSD: msg_169.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ +/* $NetBSD: msg_169.c,v 1.2 2021/01/04 15:52:51 rillig Exp $ */ # 3 "msg_169.c" // Test for message: precedence confusion possible: parenthesize! [169] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +/* lint1-flags: -g -h -S -w */ + +typedef _Bool bool; + +void +confusing_shift_arith(unsigned a, unsigned b, unsigned c, unsigned char ch) +{ + unsigned con, okl, okr; + + con = a + b << c; + okl = (a + b) << c; + okr = a + (b << c); + + con = a << b + c; + okl = (a << b) + c; + okr = a << (b + c); + + con = a - b >> c; + okl = (a - b) >> c; + okr = a - (b >> c); + + con = a >> b - c; + okl = (a >> b) - c; + okr = a >> (b - c); + + // Parenthesizing the inner operands has no effect on the warning. + con = (a) + b << c; + con = a + (b) << c; + con = a + b << (c); + + // The usual arithmetic promotions have no effect on the warning. + con = ch + b << c; + con = a + ch << c; + con = a + b << ch; +} + +void +confusing_logical(bool a, bool b, bool c) +{ + bool con, okl, okr, eql; + + eql = a && b && c; + eql = a || b || c; + + con = a && b || c; + okl = (a && b) || c; + okr = a && (b || c); + + con = a || b && c; + okl = (a || b) && c; + okr = a || (b && c); +} + +void +confusing_bitwise(unsigned a, unsigned b, unsigned c) +{ + bool con, okl, okr, eql; + + eql = a & b & c; + eql = a | b | c; + eql = a ^ b ^ c; + + con = a | b ^ c; + okl = (a | b) ^ c; + okr = a | (b ^ c); + + con = a | b & c; + okl = (a | b) & c; + okr = a | (b & c); + + con = a ^ b | c; + okl = (a ^ b) | c; + okr = a ^ (b | c); + + con = a ^ b & c; + okl = (a ^ b) & c; + okr = a ^ (b & c); + + con = a & b | c; + okl = (a & b) ^ c; + okr = a & (b ^ c); + + con = a & b ^ c; + okl = (a & b) ^ c; + okr = a & (b ^ c); + + con = a & b + c; + okl = (a & b) + c; + okr = a & (b + c); + + con = a - b | c; + okl = (a - b) | c; + okr = a - (b | c); + + // This looks like a binomial formula but isn't. + con = a ^ 2 - 2 * a * b + b ^ 2; + + // This isn't a binomial formula either since '^' means xor. + con = (a ^ 2) - 2 * a * b + (b ^ 2); +} + +void +constant_expressions(void) +{ + unsigned con; + + // The check for confusing precedence happens after constant folding. + // Therefore the following lines do not generate warnings. + con = 1 & 2 | 3; + con = 4 << 5 + 6; + con = 7 ^ 8 & 9; +} + +void +cast_expressions(char a, char b, char c) +{ + unsigned con; + + // Adding casts to the leaf nodes doesn't change anything about the + // confusing precedence. + con = (unsigned)a | (unsigned)b & (unsigned)c; + con = (unsigned)a & (unsigned)b | (unsigned)c; + + // Adding a cast around the whole calculation doesn't change the + // precedence as well. + con = (unsigned)(a | b & c); + + // Adding a cast around an intermediate result groups the operands + // of the main node, which prevents any confusion about precedence. + con = (unsigned)a | (unsigned)(b & c); + con = a | (unsigned)(b & c); + con = (unsigned)(a | b) & (unsigned)c; + con = (unsigned)(a | b) & c; +} + +void +expected_precedence(int a, int b, int c) +{ + int ok; + + ok = a + b * c; +} + +// TODO: add a test with unsigned long instead of unsigned, to demonstrate +// that the typo in Index: src/tests/usr.bin/xlint/lint1/msg_169.exp diff -u src/tests/usr.bin/xlint/lint1/msg_169.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_169.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_169.exp:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_169.exp Mon Jan 4 15:52:51 2021 @@ -1 +1,24 @@ -msg_169.c(6): syntax error ':' [249] +msg_169.c(15): warning: precedence confusion possible: parenthesize! [169] +msg_169.c(19): warning: precedence confusion possible: parenthesize! [169] +msg_169.c(23): warning: precedence confusion possible: parenthesize! [169] +msg_169.c(27): warning: precedence confusion possible: parenthesize! [169] +msg_169.c(32): warning: precedence confusion possible: parenthesize! [169] +msg_169.c(33): warning: precedence confusion possible: parenth
CVS commit: src/sys/arch/sandpoint/sandpoint
Module Name:src Committed By: thorpej Date: Mon Jan 4 15:36:22 UTC 2021 Modified Files: src/sys/arch/sandpoint/sandpoint: satmgr.c Log Message: Use sel{record,remove}_knote(). To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sandpoint/sandpoint/satmgr.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/arch/sandpoint/sandpoint/satmgr.c diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.28 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.29 --- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.28 Mon Sep 3 16:29:27 2018 +++ src/sys/arch/sandpoint/sandpoint/satmgr.c Mon Jan 4 15:36:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: satmgr.c,v 1.28 2018/09/03 16:29:27 riastradh Exp $ */ +/* $NetBSD: satmgr.c,v 1.29 2021/01/04 15:36:22 thorpej Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -589,7 +589,7 @@ filt_rdetach(struct knote *kn) struct satmgr_softc *sc = kn->kn_hook; mutex_enter(&sc->sc_lock); - SLIST_REMOVE(&sc->sc_rsel.sel_klist, kn, knote, kn_selnext); + selremove_knote(&sc->sc_rsel, kn); mutex_exit(&sc->sc_lock); } @@ -613,11 +613,9 @@ static int satkqfilter(dev_t dev, struct knote *kn) { struct satmgr_softc *sc = device_lookup_private(&satmgr_cd, 0); - struct klist *klist; switch (kn->kn_filter) { case EVFILT_READ: - klist = &sc->sc_rsel.sel_klist; kn->kn_fop = &read_filtops; break; @@ -628,7 +626,7 @@ satkqfilter(dev_t dev, struct knote *kn) kn->kn_hook = sc; mutex_enter(&sc->sc_lock); - SLIST_INSERT_HEAD(klist, kn, kn_selnext); + selrecord_knote(&sc->sc_rsel, kn); mutex_exit(&sc->sc_lock); return 0;
CVS commit: src/sys/arch/sparc/dev
Module Name:src Committed By: thorpej Date: Mon Jan 4 15:29:34 UTC 2021 Modified Files: src/sys/arch/sparc/dev: tctrl.c Log Message: Use sel{record,remove}_knote(). To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/arch/sparc/dev/tctrl.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/arch/sparc/dev/tctrl.c diff -u src/sys/arch/sparc/dev/tctrl.c:1.62 src/sys/arch/sparc/dev/tctrl.c:1.63 --- src/sys/arch/sparc/dev/tctrl.c:1.62 Sat Jun 13 05:31:28 2020 +++ src/sys/arch/sparc/dev/tctrl.c Mon Jan 4 15:29:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tctrl.c,v 1.62 2020/06/13 05:31:28 jdc Exp $ */ +/* $NetBSD: tctrl.c,v 1.63 2021/01/04 15:29:34 thorpej Exp $ */ /*- * Copyright (c) 1998, 2005, 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tctrl.c,v 1.62 2020/06/13 05:31:28 jdc Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tctrl.c,v 1.63 2021/01/04 15:29:34 thorpej Exp $"); #include #include @@ -1218,7 +1218,7 @@ filt_tctrlrdetach(struct knote *kn) int s; s = splts102(); - SLIST_REMOVE(&sc->sc_rsel.sel_klist, kn, knote, kn_selnext); + selremove_knote(&sc->sc_rsel, kn); splx(s); } @@ -1243,12 +1243,10 @@ tctrlkqfilter(dev_t dev, struct knote *k { struct tctrl_softc *sc = device_lookup_private(&tctrl_cd, TCTRL_STD_DEV); - struct klist *klist; int s; switch (kn->kn_filter) { case EVFILT_READ: - klist = &sc->sc_rsel.sel_klist; kn->kn_fop = &tctrlread_filtops; break; @@ -1259,7 +1257,7 @@ tctrlkqfilter(dev_t dev, struct knote *k kn->kn_hook = sc; s = splts102(); - SLIST_INSERT_HEAD(klist, kn, kn_selnext); + selrecord_knote(&sc->sc_rsel, kn); splx(s); return (0);
CVS commit: src/sys/dev/ic
Module Name:src Committed By: skrll Date: Mon Jan 4 15:14:32 UTC 2021 Modified Files: src/sys/dev/ic: wdc.c Log Message: KNF To generate a diff of this commit: cvs rdiff -u -r1.305 -r1.306 src/sys/dev/ic/wdc.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/ic/wdc.c diff -u src/sys/dev/ic/wdc.c:1.305 src/sys/dev/ic/wdc.c:1.306 --- src/sys/dev/ic/wdc.c:1.305 Mon Jan 4 15:13:50 2021 +++ src/sys/dev/ic/wdc.c Mon Jan 4 15:14:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: wdc.c,v 1.305 2021/01/04 15:13:50 skrll Exp $ */ +/* $NetBSD: wdc.c,v 1.306 2021/01/04 15:14:32 skrll Exp $ */ /* * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.305 2021/01/04 15:13:50 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.306 2021/01/04 15:14:32 skrll Exp $"); #include "opt_ata.h" #include "opt_wdc.h" @@ -372,7 +372,7 @@ wdc_drvprobe(struct ata_channel *chp) * Init error counter so that an error within the first xfers * will trigger a downgrade */ - chp->ch_drive[i].n_dmaerrs = NERRS_MAX-1; + chp->ch_drive[i].n_dmaerrs = NERRS_MAX - 1; #endif /* If controller can't do 16bit flag the drives as 32bit */
CVS commit: src/sys
Module Name:src Committed By: skrll Date: Mon Jan 4 15:13:50 UTC 2021 Modified Files: src/sys/arch/arm/xscale: pxa2x0_intr.c src/sys/arch/sparc64/doc: TODO src/sys/dev/ic: wdc.c Log Message: Trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/xscale/pxa2x0_intr.c cvs rdiff -u -r1.30 -r1.31 src/sys/arch/sparc64/doc/TODO cvs rdiff -u -r1.304 -r1.305 src/sys/dev/ic/wdc.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/arch/arm/xscale/pxa2x0_intr.c diff -u src/sys/arch/arm/xscale/pxa2x0_intr.c:1.22 src/sys/arch/arm/xscale/pxa2x0_intr.c:1.23 --- src/sys/arch/arm/xscale/pxa2x0_intr.c:1.22 Mon Jan 4 15:13:06 2021 +++ src/sys/arch/arm/xscale/pxa2x0_intr.c Mon Jan 4 15:13:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pxa2x0_intr.c,v 1.22 2021/01/04 15:13:06 skrll Exp $ */ +/* $NetBSD: pxa2x0_intr.c,v 1.23 2021/01/04 15:13:50 skrll Exp $ */ /* * Copyright (c) 2002 Genetec Corporation. All rights reserved. @@ -16,7 +16,7 @@ *must display the following acknowledgement: * This product includes software developed for the NetBSD Project by * Genetec Corporation. - * 4. The name of Genetec Corporation may not be used to endorse or + * 4. The name of Genetec Corporation may not be used to endorse or *promote products derived from this software without specific prior *written permission. * @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pxa2x0_intr.c,v 1.22 2021/01/04 15:13:06 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pxa2x0_intr.c,v 1.23 2021/01/04 15:13:50 skrll Exp $"); #include #include @@ -70,7 +70,7 @@ static int stray_interrupt(void *); static void init_interrupt_masks(void); /* - * interrupt dispatch table. + * interrupt dispatch table. */ #ifdef MULTIPLE_HANDLERS_ON_ONE_IRQ struct intrhand { @@ -173,14 +173,14 @@ pxa2x0_irq_handler(void *arg) /* Enable interrupt */ #endif #ifndef MULTIPLE_HANDLERS_ON_ONE_IRQ - (* handler[irqno].func)( + (* handler[irqno].func)( handler[irqno].cookie == 0 ? frame : handler[irqno].cookie ); #else /* process all handlers for this interrupt. XXX not yet */ #endif - + #ifdef notyet /* Disable interrupt */ #endif Index: src/sys/arch/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.30 src/sys/arch/sparc64/doc/TODO:1.31 --- src/sys/arch/sparc64/doc/TODO:1.30 Mon Jan 4 15:13:06 2021 +++ src/sys/arch/sparc64/doc/TODO Mon Jan 4 15:13:50 2021 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.30 2021/01/04 15:13:06 skrll Exp $ */ +/* $NetBSD: TODO,v 1.31 2021/01/04 15:13:50 skrll Exp $ */ Things to be done: @@ -11,7 +11,7 @@ sun4u: - GENERIC.UP kernel hangs on v445 (missing interrupt?) sun4v: - - current status: The kernel boots and starts the init process. + - current status: The kernel boots and starts the init process. The following processes seem to crash on and on so more debugging to be done... - 64-bit kernel support Index: src/sys/dev/ic/wdc.c diff -u src/sys/dev/ic/wdc.c:1.304 src/sys/dev/ic/wdc.c:1.305 --- src/sys/dev/ic/wdc.c:1.304 Mon Jan 4 15:13:06 2021 +++ src/sys/dev/ic/wdc.c Mon Jan 4 15:13:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: wdc.c,v 1.304 2021/01/04 15:13:06 skrll Exp $ */ +/* $NetBSD: wdc.c,v 1.305 2021/01/04 15:13:50 skrll Exp $ */ /* * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.304 2021/01/04 15:13:06 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.305 2021/01/04 15:13:50 skrll Exp $"); #include "opt_ata.h" #include "opt_wdc.h" @@ -718,8 +718,8 @@ wdcprobe1(struct ata_channel *chp, int p DELAY(2000); (void) bus_space_read_1(wdr->cmd_iot, wdr->cmd_iohs[wd_error], 0); - if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) - bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, + if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) + bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, WDCTL_4BIT); #ifdef WDC_NO_IDS @@ -1038,7 +1038,7 @@ wdcreset(struct ata_channel *chp, int po drv_mask1 = (chp->ch_drive[0].drive_type != ATA_DRIVET_NONE) ? 0x01 : 0x00; - if (chp->ch_ndrives > 1) + if (chp->ch_ndrives > 1) drv_mask1 |= (chp->ch_drive[1].drive_type != ATA_DRIVET_NONE) ? 0x02 : 0x00; drv_mask2 = __wdcwait_reset(chp, drv_mask1, @@ -1052,8 +1052,8 @@ wdcreset(struct ata_channel *chp, int po aprint_normal(" drive 1"); aprint_normal("\n"); } - if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) - bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, + if (! (wdc->cap & WDC_CAPABILITY_NO_AUXCTL)) + bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, WDCTL_4BIT); return (drv_mask1 != drv_mask2) ? 1 : 0; @@ -1080,7 +1080,7 @@ wdc_do_reset(struct ata_channel *chp, in delay(2000); } (void) bus_space_read_
CVS commit: src/sys
Module Name:src Committed By: skrll Date: Mon Jan 4 15:13:06 UTC 2021 Modified Files: src/sys/arch/arm/xscale: pxa2x0_intr.c src/sys/arch/sparc64/doc: TODO src/sys/dev/ic: wdc.c Log Message: Spell interrupts correctly To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/xscale/pxa2x0_intr.c cvs rdiff -u -r1.29 -r1.30 src/sys/arch/sparc64/doc/TODO cvs rdiff -u -r1.303 -r1.304 src/sys/dev/ic/wdc.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/arch/arm/xscale/pxa2x0_intr.c diff -u src/sys/arch/arm/xscale/pxa2x0_intr.c:1.21 src/sys/arch/arm/xscale/pxa2x0_intr.c:1.22 --- src/sys/arch/arm/xscale/pxa2x0_intr.c:1.21 Tue Dec 17 01:28:04 2013 +++ src/sys/arch/arm/xscale/pxa2x0_intr.c Mon Jan 4 15:13:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pxa2x0_intr.c,v 1.21 2013/12/17 01:28:04 joerg Exp $ */ +/* $NetBSD: pxa2x0_intr.c,v 1.22 2021/01/04 15:13:06 skrll Exp $ */ /* * Copyright (c) 2002 Genetec Corporation. All rights reserved. @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pxa2x0_intr.c,v 1.21 2013/12/17 01:28:04 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pxa2x0_intr.c,v 1.22 2021/01/04 15:13:06 skrll Exp $"); #include #include @@ -252,7 +252,7 @@ init_interrupt_masks(void) { /* - * disable all interrups until handlers are installed. + * disable all interrupts until handlers are installed. */ memset(pxa2x0_imask, 0, sizeof(pxa2x0_imask)); Index: src/sys/arch/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.29 src/sys/arch/sparc64/doc/TODO:1.30 --- src/sys/arch/sparc64/doc/TODO:1.29 Fri Feb 8 19:55:40 2019 +++ src/sys/arch/sparc64/doc/TODO Mon Jan 4 15:13:06 2021 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.29 2019/02/08 19:55:40 palle Exp $ */ + /* $NetBSD: TODO,v 1.30 2021/01/04 15:13:06 skrll Exp $ */ Things to be done: @@ -28,7 +28,7 @@ sun4v: - ci_tsb_desc->td_ctxidx: -1 or 1? - MP support - currently bypassed in pmap_bootstrap() for sun4v - vpci.c/vpcivar.h: cleanup FIXMEs -- interrups not handled properly (com at ebus only...) +- interrupts not handled properly (com at ebus only...) - mpt(4) complains: mpt0: Phy 0: Link Status Unknown - man pages for drivers imported from OpenBSD lke vpci, vbus, cbus, vdsk, ldc etc. - vdsk and ldc drivers: code maked with OPENBSD_BUSDMA - make the bus_dma stuff work properly Index: src/sys/dev/ic/wdc.c diff -u src/sys/dev/ic/wdc.c:1.303 src/sys/dev/ic/wdc.c:1.304 --- src/sys/dev/ic/wdc.c:1.303 Wed Jun 3 18:25:26 2020 +++ src/sys/dev/ic/wdc.c Mon Jan 4 15:13:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: wdc.c,v 1.303 2020/06/03 18:25:26 bouyer Exp $ */ +/* $NetBSD: wdc.c,v 1.304 2021/01/04 15:13:06 skrll Exp $ */ /* * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.303 2020/06/03 18:25:26 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.304 2021/01/04 15:13:06 skrll Exp $"); #include "opt_ata.h" #include "opt_wdc.h" @@ -343,7 +343,7 @@ wdc_drvprobe(struct ata_channel *chp) (st1 & WDCS_DRDY))) break; #ifdef WDC_NO_IDS - /* cannot kpause here (can't enable IPL_BIO interrups), + /* cannot kpause here (can't enable IPL_BIO interrupts), * delay instead */ delay(100 / hz);
CVS commit: src/sys/arch/sparc64
Module Name:src Committed By: thorpej Date: Mon Jan 4 14:48:52 UTC 2021 Modified Files: src/sys/arch/sparc64/dev: cbus.c central.c ebus.c ebus_mainbus.c fdc.c fhc.c pckbc_ebus.c psycho.c pyro.c sbus.c upa.c vbus.c vpci.c vrtc.c src/sys/arch/sparc64/sparc64: machdep.c Log Message: malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc64/dev/cbus.c \ src/sys/arch/sparc64/dev/pckbc_ebus.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/dev/central.c \ src/sys/arch/sparc64/dev/vbus.c cvs rdiff -u -r1.64 -r1.65 src/sys/arch/sparc64/dev/ebus.c cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sparc64/dev/ebus_mainbus.c cvs rdiff -u -r1.48 -r1.49 src/sys/arch/sparc64/dev/fdc.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/dev/fhc.c cvs rdiff -u -r1.128 -r1.129 src/sys/arch/sparc64/dev/psycho.c cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sparc64/dev/pyro.c cvs rdiff -u -r1.99 -r1.100 src/sys/arch/sparc64/dev/sbus.c cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc64/dev/upa.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sparc64/dev/vpci.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/dev/vrtc.c cvs rdiff -u -r1.298 -r1.299 src/sys/arch/sparc64/sparc64/machdep.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/arch/sparc64/dev/cbus.c diff -u src/sys/arch/sparc64/dev/cbus.c:1.3 src/sys/arch/sparc64/dev/cbus.c:1.4 --- src/sys/arch/sparc64/dev/cbus.c:1.3 Sun Nov 10 21:16:33 2019 +++ src/sys/arch/sparc64/dev/cbus.c Mon Jan 4 14:48:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cbus.c,v 1.3 2019/11/10 21:16:33 chs Exp $ */ +/* $NetBSD: cbus.c,v 1.4 2021/01/04 14:48:51 thorpej Exp $ */ /* $OpenBSD: cbus.c,v 1.15 2015/09/27 11:29:20 kettenis Exp $ */ /* * Copyright (c) 2008 Mark Kettenis @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include @@ -238,7 +238,7 @@ cbus_alloc_bus_tag(struct cbus_softc *sc { struct sparc_bus_space_tag *bt; - bt = malloc(sizeof(*bt), M_DEVBUF, M_WAITOK | M_ZERO); + bt = kmem_zalloc(sizeof(*bt), KM_SLEEP); bt->cookie = sc; bt->parent = parent; bt->sparc_bus_map = parent->sparc_bus_map; Index: src/sys/arch/sparc64/dev/pckbc_ebus.c diff -u src/sys/arch/sparc64/dev/pckbc_ebus.c:1.3 src/sys/arch/sparc64/dev/pckbc_ebus.c:1.4 --- src/sys/arch/sparc64/dev/pckbc_ebus.c:1.3 Sat Oct 13 20:11:48 2018 +++ src/sys/arch/sparc64/dev/pckbc_ebus.c Mon Jan 4 14:48:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pckbc_ebus.c,v 1.3 2018/10/13 20:11:48 macallan Exp $ */ +/* $NetBSD: pckbc_ebus.c,v 1.4 2021/01/04 14:48:51 thorpej Exp $ */ /* * Copyright (c) 2002 Valeriy E. Ushakov @@ -28,13 +28,13 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pckbc_ebus.c,v 1.3 2018/10/13 20:11:48 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pckbc_ebus.c,v 1.4 2021/01/04 14:48:51 thorpej Exp $"); #include #include #include #include -#include +#include #include #include @@ -154,8 +154,7 @@ pckbc_ebus_attach(device_t parent, devic return; } - t = malloc(sizeof(struct pckbc_internal), M_DEVBUF, M_WAITOK); - memset(t, 0, sizeof(struct pckbc_internal)); + t = kmem_zalloc(sizeof(struct pckbc_internal), KM_SLEEP); t->t_iot = iot; t->t_ioh_d = ioh_d; t->t_ioh_c = ioh_c; Index: src/sys/arch/sparc64/dev/central.c diff -u src/sys/arch/sparc64/dev/central.c:1.4 src/sys/arch/sparc64/dev/central.c:1.5 --- src/sys/arch/sparc64/dev/central.c:1.4 Sun Nov 10 21:16:33 2019 +++ src/sys/arch/sparc64/dev/central.c Mon Jan 4 14:48:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: central.c,v 1.4 2019/11/10 21:16:33 chs Exp $ */ +/* $NetBSD: central.c,v 1.5 2021/01/04 14:48:51 thorpej Exp $ */ /* $OpenBSD: central.c,v 1.7 2010/11/11 17:58:23 miod Exp $ */ /* @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: central.c,v 1.4 2019/11/10 21:16:33 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: central.c,v 1.5 2021/01/04 14:48:51 thorpej Exp $"); #include #include @@ -37,6 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: central.c,v #include #include #include +#include #include #include @@ -153,7 +154,7 @@ central_alloc_bus_tag(struct central_sof { struct sparc_bus_space_tag *bt; - bt = malloc(sizeof(*bt), M_DEVBUF, M_WAITOK | M_ZERO); + bt = kmem_zalloc(sizeof(*bt), KM_SLEEP); bt->cookie = sc; bt->parent = sc->sc_bt; #if 0 Index: src/sys/arch/sparc64/dev/vbus.c diff -u src/sys/arch/sparc64/dev/vbus.c:1.4 src/sys/arch/sparc64/dev/vbus.c:1.5 --- src/sys/arch/sparc64/dev/vbus.c:1.4 Sun Nov 10 21:16:33 2019 +++ src/sys/arch/sparc64/dev/vbus.c Mon Jan 4 14:48:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: vbus.c,v 1.4 2019/11/10 21:16:33 chs Exp $ */ +/* $NetBSD: vbus.c,v 1.5 2021/01/04 14:48:52 thorpej Exp $ */ /* $OpenBSD: vbus.c,v 1.8 2015/09/27 11:29:20 kettenis Exp $ */ /* * Copyright (c) 2008 Mark Kettenis @@ -19,6 +19,7 @@ #includ