CVS commit: src/sys/ddb
Module Name:src Committed By: simonb Date: Mon Jan 11 07:49:05 UTC 2021 Modified Files: src/sys/ddb: db_proc.c Log Message: For "ps/a" print all of p_comm instead of just the first 10 chars, add a space after PID, left justify the command name. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/ddb/db_proc.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/ddb/db_proc.c diff -u src/sys/ddb/db_proc.c:1.13 src/sys/ddb/db_proc.c:1.14 --- src/sys/ddb/db_proc.c:1.13 Fri Oct 30 06:57:08 2020 +++ src/sys/ddb/db_proc.c Mon Jan 11 07:49:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: db_proc.c,v 1.13 2020/10/30 06:57:08 skrll Exp $ */ +/* $NetBSD: db_proc.c,v 1.14 2021/01/11 07:49:04 simonb Exp $ */ /*- * Copyright (c) 2009, 2020 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_proc.c,v 1.13 2020/10/30 06:57:08 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_proc.c,v 1.14 2021/01/11 07:49:04 simonb Exp $"); #ifndef _KERNEL #include @@ -149,7 +149,7 @@ db_show_all_procs(db_expr_t addr, bool h switch (*mode) { case 'a': - db_printf("PID %10s %18s %18s %18s\n", + db_printf("PID %-16s %18s %18s %18s\n", "COMMAND", "STRUCT PROC *", "UAREA *", "VMSPACE/VM_MAP"); break; case 'l': @@ -180,7 +180,7 @@ db_show_all_procs(db_expr_t addr, bool h switch (*mode) { case 'a': - db_printf("%10.10s %18lx %18lx %18lx\n", + db_printf(" %-16.16s %18lx %18lx %18lx\n", p.p_comm, (long)pp, (long)(lp != NULL ? l.l_addr : 0), (long)p.p_vmspace);
CVS commit: src/tests/lib/libc/gen
Module Name:src Committed By: skrll Date: Mon Jan 11 07:17:49 UTC 2021 Modified Files: src/tests/lib/libc/gen: t_siginfo.c Log Message: PR/55715: pmax testbed panics with "assertion "asid == curcpu()->ci_pmap_asid_cur" failed" It's GXemul that has the bug! Unfortunately, there's no way (currently) to detect if we're running under GXemul emulation, so disable for all mips for now. Hopefully, GXemul will get fixed soon. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/tests/lib/libc/gen/t_siginfo.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/lib/libc/gen/t_siginfo.c diff -u src/tests/lib/libc/gen/t_siginfo.c:1.43 src/tests/lib/libc/gen/t_siginfo.c:1.44 --- src/tests/lib/libc/gen/t_siginfo.c:1.43 Sun Jan 10 20:46:14 2021 +++ src/tests/lib/libc/gen/t_siginfo.c Mon Jan 11 07:17:49 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_siginfo.c,v 1.43 2021/01/10 20:46:14 skrll Exp $ */ +/* $NetBSD: t_siginfo.c,v 1.44 2021/01/11 07:17:49 skrll Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -482,9 +482,9 @@ ATF_TC_BODY(sigbus_adraln, tc) #endif #if defined(__mips__) - if (isQEMU()) - atf_tc_expect_fail("QEMU fails to trap unaligned accesses with " - "correct ENTRYHI"); + /* no way of detecting if on GXemul, so disable everywhere for now */ + atf_tc_expect_fail("GXemul fails to trap unaligned accesses with " + "correct ENTRYHI"); #endif sa.sa_flags = SA_SIGINFO;
CVS commit: src/sys/arch/sparc/sparc
Module Name:src Committed By: chs Date: Mon Jan 11 06:12:43 UTC 2021 Modified Files: src/sys/arch/sparc/sparc: pmap.c Log Message: in pgt_page_alloc(), wait and retry the page allocation if PR_WAITOK. fixes PR 55895. To generate a diff of this commit: cvs rdiff -u -r1.369 -r1.370 src/sys/arch/sparc/sparc/pmap.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/sparc/pmap.c diff -u src/sys/arch/sparc/sparc/pmap.c:1.369 src/sys/arch/sparc/sparc/pmap.c:1.370 --- src/sys/arch/sparc/sparc/pmap.c:1.369 Wed Dec 9 11:35:44 2020 +++ src/sys/arch/sparc/sparc/pmap.c Mon Jan 11 06:12:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.369 2020/12/09 11:35:44 uwe Exp $ */ +/* $NetBSD: pmap.c,v 1.370 2021/01/11 06:12:43 chs Exp $ */ /* * Copyright (c) 1996 @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.369 2020/12/09 11:35:44 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.370 2021/01/11 06:12:43 chs Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -907,13 +907,20 @@ pgt_page_alloc(struct pool *pp, int flag paddr_t pa; /* Allocate a page of physical memory */ - if ((pg = uvm_pagealloc(NULL, 0, NULL, 0)) == NULL) - return (NULL); + while ((pg = uvm_pagealloc(NULL, 0, NULL, 0)) == NULL && + (flags & PR_WAITOK) != 0) { + uvm_wait("pgtpg"); + } + if (pg == NULL) { + KASSERT((flags & PR_WAITOK) == 0); + return NULL; + } /* Allocate virtual memory */ va = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_VAONLY | ((flags & PR_WAITOK) ? 0 : UVM_KMF_NOWAIT | UVM_KMF_TRYLOCK)); if (va == 0) { + KASSERT((flags & PR_WAITOK) == 0); uvm_pagefree(pg); return (NULL); }
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Mon Jan 11 02:18:40 UTC 2021 Modified Files: src/sys/kern: kern_entropy.c Log Message: entropy: Downgrade consolidation warning from printf to LOG_DEBUG. Candidate fix for PR kern/55458. This message is rather technical, and so is unlikely to be acted on by anyone not debugging the kernel anyway. Most likely, on any system where it is a real problem, there will be another (less technical) entropy warning anyway. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/kern/kern_entropy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_entropy.c diff -u src/sys/kern/kern_entropy.c:1.25 src/sys/kern/kern_entropy.c:1.26 --- src/sys/kern/kern_entropy.c:1.25 Fri Dec 11 03:00:09 2020 +++ src/sys/kern/kern_entropy.c Mon Jan 11 02:18:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_entropy.c,v 1.25 2020/12/11 03:00:09 thorpej Exp $ */ +/* $NetBSD: kern_entropy.c,v 1.26 2021/01/11 02:18:40 riastradh Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -75,7 +75,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.25 2020/12/11 03:00:09 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.26 2021/01/11 02:18:40 riastradh Exp $"); #include #include @@ -106,6 +106,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_entropy #include /* for boot seed checksum */ #include #include +#include #include #include #include @@ -1026,7 +1027,7 @@ entropy_do_consolidate(void) E->pending -= diff; if (__predict_false(E->needed > 0)) { if (ratecheck(, )) - printf("entropy: WARNING:" + log(LOG_DEBUG, "entropy: WARNING:" " consolidating less than full entropy\n"); }
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Mon Jan 11 00:28:28 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: d_c99_bool_strict.c d_c99_bool_strict.exp Log Message: lint: extend test for strict _Bool handling There is no danger in allowing (flags & FLAG) as a controlling expression, provided that it is immediately compared to zero, such as in an if statement or as the operand of a logical operator. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp 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/d_c99_bool_strict.c diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.2 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.3 --- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.2 Sun Jan 10 21:45:50 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c Mon Jan 11 00:28:28 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: d_c99_bool_strict.c,v 1.2 2021/01/10 21:45:50 rillig Exp $ */ +/* $NetBSD: d_c99_bool_strict.c,v 1.3 2021/01/11 00:28:28 rillig Exp $ */ # 3 "d_c99_bool_strict.c" /* @@ -21,6 +21,15 @@ * SB006: A constant integer expression is compatible with type _Bool if * it is an integer constant with value 0 or 1, or if the result type of * its main operator is _Bool. + * + * SB007: Expressions like "flags & FLAG" are compatible with _Bool if + * they appear in a context where they are immediately compared to zero. + * Assigning to a _Bool variable does not count as such a context, to + * allow programs to be compiled without silent changes on a compiler that + * is lacking the special _Bool type. + * + * SB008: Bit fields in struct may be based on _Bool. These bit fields + * typically have type _Bool:1 and can be converted to _Bool and back. */ // Not yet implemented: /* lint1-extra-flags: -T */ @@ -251,33 +260,157 @@ enum SB006_bool_constant_expression { LOGAND = 0 && 1, /* ok */ }; -enum BitSet { - ONE = 1 << 0, - TWO = 1 << 1, - FOUR = 1 << 2 +/* + * An efficient implementation technique for a collection of boolean flags + * is an enum. The enum declaration groups the available constants, and as + * of 2020, compilers such as GCC and Clang have basic support for detecting + * type mismatches on enums. + */ + +enum Flags { + FLAG0 = 1 << 0, + FLAG1 = 1 << 1, + FLAG28 = 1 << 28 }; /* - * It is debatable whether it is a good idea to allow expressions like these - * for _Bool. The strict rules above ensure that the code works in the same - * way whether or not the special rule C99 6.3.1.2 is active or not. - * - * If the code were to switch away from the C99 bool type to an ordinary - * unsigned integer type, the behavior might silently change. Because the - * rule C99 6.3.1.2 is no longer active in that case, high bits of the enum - * constant may get lost, thus evaluating to false even though a bit is set. + * The usual way to query one of the flags is demonstrated below. + */ + +extern void println(const char *); + +void +query_flag_from_enum_bit_set(enum Flags flags) +{ + + if (flags & FLAG0) + println("FLAG0 is set"); + + if ((flags & FLAG1) != 0) + println("FLAG1 is set"); + + if ((flags & (FLAG0 | FLAG1)) == (FLAG0 | FLAG1)) + println("FLAG0 and FLAG1 are both set"); + if (flags & FLAG0 && flags & FLAG1) + println("FLAG0 and FLAG1 are both set"); + + if ((flags & (FLAG0 | FLAG1)) != 0) + println("At least one of FLAG0 and FLAG1 is set"); + + if (flags & FLAG28) + println("FLAG28 is set"); +} + +/* + * In all the above conditions (or controlling expressions, as the C standard + * calls them), the result of the operator '&' is compared against 0. This + * makes this pattern work, no matter whether the bits are in the low-value + * range or in the high-value range (such as FLAG28, which has the value + * 1073741824, which is more than what fits into an unsigned char). Even + * if an enum could be extended to larger types than int, this pattern + * would work. + */ + +/* + * There is a crucial difference between a _Bool variable and an ordinary + * integer variable though. C99 6.3.1.2 defines a conversion from an + * arbitrary scalar type to _Bool as (value != 0 ? 1 : 0). This means that + * even if _Bool is implemented as an 8-bit unsigned integer, assigning 256 + * to it would still result in the value 1 being stored. Storing 256 in an + * ordinary 8-bit unsigned integer would result in the value 0 being stored. + * See the test d_c99_bool.c for more details. * - * It's probably better to not allow this kind of expressions, even though - * it may be popular, especially in usr.bin/make. + * Because of this, expressions like (flags & FLAG28) are only allowed in + * bool context if they are guaranteed not to be truncated, even if the + * result were to be stored
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Jan 10 23:59:53 UTC 2021 Modified Files: src/usr.bin/make: job.c main.c str.c targ.c var.c src/usr.bin/make/filemon: filemon_ktrace.c Log Message: make(1): make a few more bool expressions more precise The previous version of lint(1) from a few hours ago didn't catch all occurrences. And even the current one doesn't catch everything. Function arguments and return types still need some work. The "return quietly" from shouldDieQuietly still implicitly converts from int to _Bool. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.396 -r1.397 src/usr.bin/make/job.c cvs rdiff -u -r1.511 -r1.512 src/usr.bin/make/main.c cvs rdiff -u -r1.77 -r1.78 src/usr.bin/make/str.c cvs rdiff -u -r1.159 -r1.160 src/usr.bin/make/targ.c cvs rdiff -u -r1.780 -r1.781 src/usr.bin/make/var.c cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/filemon/filemon_ktrace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.396 src/usr.bin/make/job.c:1.397 --- src/usr.bin/make/job.c:1.396 Sun Jan 10 21:20:46 2021 +++ src/usr.bin/make/job.c Sun Jan 10 23:59:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.396 2021/01/10 21:20:46 rillig Exp $ */ +/* $NetBSD: job.c,v 1.397 2021/01/10 23:59:53 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -143,7 +143,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.396 2021/01/10 21:20:46 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.397 2021/01/10 23:59:53 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -1539,7 +1539,7 @@ JobMakeArgv(Job *job, char **argv) (!job->echo ? "" : (shell->echoFlag != NULL ? shell->echoFlag : ""))); - if (args[1]) { + if (args[1] != '\0') { argv[argc] = args; argc++; } @@ -2286,7 +2286,7 @@ Job_Init(void) static void DelSig(int sig) { - if (sigismember(_signals, sig)) + if (sigismember(_signals, sig) != 0) (void)bmake_signal(sig, SIG_DFL); } @@ -2557,7 +2557,7 @@ JobInterrupt(Boolean runINTERRUPT, int s gn = job->node; JobDeleteTarget(gn); - if (job->pid) { + if (job->pid != 0) { DEBUG2(JOB, "JobInterrupt passing signal %d to child %d.\n", signo, job->pid); @@ -2728,7 +2728,7 @@ clearfd(Job *job) * pollfd number should be even. */ assert(nfds_per_job() == 2); - if (i % 2) + if (i % 2 != 0) Punt("odd-numbered fd with meta"); nJobs--; } Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.511 src/usr.bin/make/main.c:1.512 --- src/usr.bin/make/main.c:1.511 Sun Jan 10 21:20:46 2021 +++ src/usr.bin/make/main.c Sun Jan 10 23:59:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.511 2021/01/10 21:20:46 rillig Exp $ */ +/* $NetBSD: main.c,v 1.512 2021/01/10 23:59:53 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -110,7 +110,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.511 2021/01/10 21:20:46 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.512 2021/01/10 23:59:53 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -159,7 +159,7 @@ explode(const char *flags) if (flags == NULL) return NULL; - for (f = flags; *f; f++) + for (f = flags; *f != '\0'; f++) if (!ch_isalpha(*f)) break; @@ -243,7 +243,7 @@ parse_debug_options(const char *argvalue const char *modules; DebugFlags debug = opts.debug; - for (modules = argvalue; *modules; ++modules) { + for (modules = argvalue; *modules != '\0'; ++modules) { switch (*modules) { case '0': /* undocumented, only intended for tests */ debug = DEBUG_NONE; @@ -790,7 +790,7 @@ str2Lst_Append(StringList *lp, char *str const char *sep = " \t"; - for (n = 0, cp = strtok(str, sep); cp; cp = strtok(NULL, sep)) { + for (n = 0, cp = strtok(str, sep); cp != NULL; cp = strtok(NULL, sep)) { Lst_Append(lp, cp); n++; } @@ -2093,7 +2093,7 @@ shouldDieQuietly(GNode *gn, int bf) else if (bf >= 0) quietly = bf; else - quietly = gn != NULL && (gn->type & OP_MAKE); + quietly = (gn != NULL && (gn->type & OP_MAKE)) ? 1 : 0; } return quietly; } Index: src/usr.bin/make/str.c diff -u src/usr.bin/make/str.c:1.77 src/usr.bin/make/str.c:1.78 --- src/usr.bin/make/str.c:1.77 Sun Jan 10 21:20:46 2021 +++ src/usr.bin/make/str.c Sun Jan 10 23:59:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: str.c,v 1.77 2021/01/10 21:20:46 rillig Exp $ */ +/* $NetBSD: str.c,v 1.78 2021/01/10 23:59:53 rillig Exp $ */ /*- * Copyright (c) 1988, 1989, 1990, 1993 @@ -71,7 +71,7 @@ #include "make.h" /* "@(#)str.c 5.8 (Berkeley) 6/1/90" */
CVS commit: src
Module Name:src Committed By: riastradh Date: Sun Jan 10 23:24:26 UTC 2021 Modified Files: src/distrib/sets/lists/etc: mi src/distrib/sets/lists/man: mi src/etc: security src/etc/defaults: rc.conf security.conf src/etc/rc.d: Makefile src/share/man/man4: rnd.4 src/share/man/man5: rc.conf.5 security.conf.5 src/share/man/man7: Makefile security.7 src/share/man/man8: afterboot.8 Added Files: src/etc/rc.d: entropy src/share/man/man7: entropy.7 Log Message: Various entropy integration improvements. - New /etc/security check for entropy in daily security report. - New /etc/rc.d/entropy script runs (after random_seed and rndctl) to check for entropy at boot -- in rc.conf, you can: . set `entropy=check' to halt multiuser boot and enter single-user mode if not enough entropy . set `entropy=wait' to make multiuser boot wait until enough entropy Default is to always boot without waiting -- and rely on other channels like security report to alert the operator if there's a problem. - New man page entropy(7) discussing the higher-level concepts and system integration with cross-references. - New paragraph in afterboot(8) about entropy citing entropy(7) for more details. This change addresses many of the issues discussed in security/55659. This is a first draft; happy to take improvements to the man pages and scripted messages to improve clarity. I considered changing motd to include an entropy warning with a reference to the entropy(7) man page, but it's a little trickier: - Not sure it's appropriate for all users to see at login rather than users who have power to affect the entropy estimate (maybe it is, just haven't decided). - We only have a mechanism for changing once at boot; the message would remain until next boot even if an operator adds enough entropy. - The mechanism isn't really conducive to making a message appear conditionally from boot to boot. To generate a diff of this commit: cvs rdiff -u -r1.263 -r1.264 src/distrib/sets/lists/etc/mi cvs rdiff -u -r1.1712 -r1.1713 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.127 -r1.128 src/etc/security cvs rdiff -u -r1.160 -r1.161 src/etc/defaults/rc.conf cvs rdiff -u -r1.27 -r1.28 src/etc/defaults/security.conf cvs rdiff -u -r1.109 -r1.110 src/etc/rc.d/Makefile cvs rdiff -u -r0 -r1.1 src/etc/rc.d/entropy cvs rdiff -u -r1.35 -r1.36 src/share/man/man4/rnd.4 cvs rdiff -u -r1.187 -r1.188 src/share/man/man5/rc.conf.5 cvs rdiff -u -r1.42 -r1.43 src/share/man/man5/security.conf.5 cvs rdiff -u -r1.35 -r1.36 src/share/man/man7/Makefile cvs rdiff -u -r0 -r1.1 src/share/man/man7/entropy.7 cvs rdiff -u -r1.15 -r1.16 src/share/man/man7/security.7 cvs rdiff -u -r1.75 -r1.76 src/share/man/man8/afterboot.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/etc/mi diff -u src/distrib/sets/lists/etc/mi:1.263 src/distrib/sets/lists/etc/mi:1.264 --- src/distrib/sets/lists/etc/mi:1.263 Tue Sep 8 12:52:44 2020 +++ src/distrib/sets/lists/etc/mi Sun Jan 10 23:24:25 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.263 2020/09/08 12:52:44 martin Exp $ +# $NetBSD: mi,v 1.264 2021/01/10 23:24:25 riastradh Exp $ # # Note: end-user configuration files that are moved to another location # should not be marked "obsolete"; they should just be removed from @@ -214,6 +214,7 @@ ./etc/rc.d/dhcrelayetc-dhcpd-rc ./etc/rc.d/dmesgetc-sys-rc ./etc/rc.d/downinterfaces etc-sys-rc +./etc/rc.d/entropyetc-sys-rc ./etc/rc.d/envsysetc-sys-rc ./etc/rc.d/fixsbetc-obsolete obsolete ./etc/rc.d/fsck etc-sys-rc Index: src/distrib/sets/lists/man/mi diff -u src/distrib/sets/lists/man/mi:1.1712 src/distrib/sets/lists/man/mi:1.1713 --- src/distrib/sets/lists/man/mi:1.1712 Sun Dec 27 21:13:18 2020 +++ src/distrib/sets/lists/man/mi Sun Jan 10 23:24:25 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1712 2020/12/27 21:13:18 reinoud Exp $ +# $NetBSD: mi,v 1.1713 2021/01/10 23:24:25 riastradh Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -2340,6 +2340,7 @@ ./usr/share/man/cat7/c99.0 man-reference-catman .cat ./usr/share/man/cat7/des_modes.0 man-reference-catman .cat ./usr/share/man/cat7/editline.0 man-sys-catman .cat +./usr/share/man/cat7/entropy.0 man-reference-catman .cat ./usr/share/man/cat7/environ.0 man-reference-catman .cat ./usr/share/man/cat7/glob.0 man-reference-catman .cat ./usr/share/man/cat7/groups.0 man-reference-catman .cat @@ -2367,6 +2368,7 @@ ./usr/share/man/cat7/pcap-linktype.0 man-netutil-catman .cat ./usr/share/man/cat7/pcap-tstamp.0 man-netutil-catman .cat ./usr/share/man/cat7/pkgsrc.0 man-reference-catman .cat +./usr/share/man/cat7/random.0 man-reference-catman .cat ./usr/share/man/cat7/re_format.0 man-reference-catman .cat ./usr/share/man/cat7/release.0
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jan 10 21:45:50 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: d_c99_bool_strict.c Log Message: lint: add enum flags to the test about strict boolean mode To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.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/d_c99_bool_strict.c diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.1 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.2 --- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.1 Sun Jan 10 17:43:46 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c Sun Jan 10 21:45:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: d_c99_bool_strict.c,v 1.1 2021/01/10 17:43:46 rillig Exp $ */ +/* $NetBSD: d_c99_bool_strict.c,v 1.2 2021/01/10 21:45:50 rillig Exp $ */ # 3 "d_c99_bool_strict.c" /* @@ -23,7 +23,7 @@ * its main operator is _Bool. */ -// Not yet implemented: /* lint1-extra-flags: -B */ +// Not yet implemented: /* lint1-extra-flags: -T */ /* * The header defines the macros bool = _Bool, false = 0 and @@ -250,3 +250,34 @@ enum SB006_bool_constant_expression { LOGAND = 0 && 1, /* ok */ }; + +enum BitSet { + ONE = 1 << 0, + TWO = 1 << 1, + FOUR = 1 << 2 +}; + +/* + * It is debatable whether it is a good idea to allow expressions like these + * for _Bool. The strict rules above ensure that the code works in the same + * way whether or not the special rule C99 6.3.1.2 is active or not. + * + * If the code were to switch away from the C99 bool type to an ordinary + * unsigned integer type, the behavior might silently change. Because the + * rule C99 6.3.1.2 is no longer active in that case, high bits of the enum + * constant may get lost, thus evaluating to false even though a bit is set. + * + * It's probably better to not allow this kind of expressions, even though + * it may be popular, especially in usr.bin/make. + */ +int +S007_allow_flag_test_on_bit_set_enums(enum BitSet bs) +{ + if (bs & ONE) + return 1; + if (!(bs & TWO)) + return 2; + if (bs & FOUR) + return 2; + return 4; +}
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jan 10 21:26:12 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: t_integration.sh Log Message: lint: allow custom flags to be specified in all unit tests Previously, only the tests called msg_*.c could use this feature. Since it is useful for other tests as well, enable it everywhere. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/tests/usr.bin/xlint/lint1/t_integration.sh 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/t_integration.sh diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.24 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.25 --- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.24 Sun Jan 10 18:06:38 2021 +++ src/tests/usr.bin/xlint/lint1/t_integration.sh Sun Jan 10 21:26:12 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_integration.sh,v 1.24 2021/01/10 18:06:38 rillig Exp $ +# $NetBSD: t_integration.sh,v 1.25 2021/01/10 21:26:12 rillig Exp $ # # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. # All rights reserved. @@ -29,17 +29,44 @@ LINT1=/usr/libexec/lint1 Names= +extract_flags() +{ + local extract_flags_awk + + # shellcheck disable=SC2016 + extract_flags_awk=' + BEGIN { + flags = "-g -S -w" + } + /^\/\* (lint1-flags|lint1-extra-flags): .*\*\/$/ { + if ($2 == "lint1-flags:") +flags = "" + for (i = 3; i < NF; i++) +flags = flags " " $i + } + END { + print flags + } + ' + + awk "$extract_flags_awk" "$@" +} + +# shellcheck disable=SC2155 check_lint1() { local src="$(atf_get_srcdir)/$1" local exp="${src%.c}.exp" + local flags="$(extract_flags "${src}")" if [ -f "${exp}" ]; then + # shellcheck disable=SC2086 atf_check -s not-exit:0 -o "file:${exp}" -e empty \ - ${LINT1} -g -S -w "${src}" /dev/null + ${LINT1} ${flags} "${src}" /dev/null else + # shellcheck disable=SC2086 atf_check -s exit:0 \ - ${LINT1} -g -S -w "${src}" /dev/null + ${LINT1} ${flags} "${src}" /dev/null fi } @@ -155,25 +182,9 @@ all_messages_body() { srcdir="$(atf_get_srcdir)" ok="true" - # shellcheck disable=SC2016 - extract_flags_awk=' - BEGIN { - flags = "-g -S -w" - } - /^\/\* (lint1-flags|lint1-extra-flags): .*\*\/$/ { - if ($2 == "lint1-flags:") -flags = "" - for (i = 3; i < NF; i++) -flags = flags " " $i - } - END { - print flags - } - ' - for msg in $(seq 0 329); do base="$(printf '%s/msg_%03d' "${srcdir}" "${msg}")" - flags="$(awk "$extract_flags_awk" "${base}.c")" + flags="$(extract_flags "${base}.c")" # shellcheck disable=SC2154 disable=SC2086 ${Atf_Check} -s not-exit:0 -o "file:${base}.exp" -e empty \
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Jan 10 21:20:47 UTC 2021 Modified Files: src/usr.bin/make: compat.c cond.c dir.c for.c job.c main.c make.c make.h meta.c metachar.h parse.c str.c suff.c var.c src/usr.bin/make/filemon: filemon_ktrace.c Log Message: make(1): consistently use boolean expressions in conditions Most of the make code already followed the style of explicitly writing (ptr != NULL) instead of the shorter (ptr) in conditions. The remaining 50 instances have been found by an experimental, unpublished check in lint(1) that treats bool expressions as incompatible to any other scalar type, just as in Java, C#, Pascal and several other languages. The only unsafe operation on Boolean that is left over is (flags & FLAG), for an enum implementing a bit set. If Boolean is an ordinary integer type (the default), some high bits may get lost. But if Boolean is the same as _Bool (by compiling with -DUSE_C99_BOOLEAN), C99 6.3.1.2 defines that a conversion from any scalar to the type _Bool acts as a comparison to 0, which cannot lose any bits. To generate a diff of this commit: cvs rdiff -u -r1.218 -r1.219 src/usr.bin/make/compat.c cvs rdiff -u -r1.234 -r1.235 src/usr.bin/make/cond.c cvs rdiff -u -r1.254 -r1.255 src/usr.bin/make/dir.c cvs rdiff -u -r1.133 -r1.134 src/usr.bin/make/for.c cvs rdiff -u -r1.395 -r1.396 src/usr.bin/make/job.c cvs rdiff -u -r1.510 -r1.511 src/usr.bin/make/main.c cvs rdiff -u -r1.233 -r1.234 src/usr.bin/make/make.c cvs rdiff -u -r1.241 -r1.242 src/usr.bin/make/make.h cvs rdiff -u -r1.167 -r1.168 src/usr.bin/make/meta.c cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/metachar.h cvs rdiff -u -r1.525 -r1.526 src/usr.bin/make/parse.c cvs rdiff -u -r1.76 -r1.77 src/usr.bin/make/str.c cvs rdiff -u -r1.334 -r1.335 src/usr.bin/make/suff.c cvs rdiff -u -r1.779 -r1.780 src/usr.bin/make/var.c cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/filemon/filemon_ktrace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/compat.c diff -u src/usr.bin/make/compat.c:1.218 src/usr.bin/make/compat.c:1.219 --- src/usr.bin/make/compat.c:1.218 Wed Dec 30 10:03:16 2020 +++ src/usr.bin/make/compat.c Sun Jan 10 21:20:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.218 2020/12/30 10:03:16 rillig Exp $ */ +/* $NetBSD: compat.c,v 1.219 2021/01/10 21:20:46 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -96,7 +96,7 @@ #include "pathnames.h" /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: compat.c,v 1.218 2020/12/30 10:03:16 rillig Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.219 2021/01/10 21:20:46 rillig Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; @@ -281,7 +281,7 @@ Compat_RunCommand(const char *cmdp, GNod errCheck = FALSE; else if (*cmd == '+') { doIt = TRUE; - if (!shellName) /* we came here from jobs */ + if (shellName == NULL) /* we came here from jobs */ Shell_Init(); } else break; @@ -326,7 +326,7 @@ Compat_RunCommand(const char *cmdp, GNod /* The following work for any of the builtin shell specs. */ int shargc = 0; shargv[shargc++] = shellPath; - if (errCheck && shellErrFlag) + if (errCheck && shellErrFlag != NULL) shargv[shargc++] = shellErrFlag; shargv[shargc++] = DEBUG(SHELL) ? "-xc" : "-c"; shargv[shargc++] = cmd; @@ -707,7 +707,7 @@ Compat_Run(GNodeList *targs) { GNode *errorNode = NULL; - if (!shellName) + if (shellName == NULL) Shell_Init(); InitSignals(); Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.234 src/usr.bin/make/cond.c:1.235 --- src/usr.bin/make/cond.c:1.234 Sat Jan 9 16:06:09 2021 +++ src/usr.bin/make/cond.c Sun Jan 10 21:20:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.234 2021/01/09 16:06:09 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.235 2021/01/10 21:20:46 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.234 2021/01/09 16:06:09 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.235 2021/01/10 21:20:46 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -171,7 +171,7 @@ static unsigned int cond_min_depth = 0; */ static Boolean lhsStrict; -static int +static Boolean is_token(const char *str, const char *tok, size_t len) { return strncmp(str, tok, len) == 0 && !ch_isalpha(str[len]); Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.254 src/usr.bin/make/dir.c:1.255 --- src/usr.bin/make/dir.c:1.254 Wed Dec 30 10:03:16 2020 +++ src/usr.bin/make/dir.c Sun Jan 10 21:20:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.254 2020/12/30 10:03:16 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.255 2021/01/10 21:20:46 rillig Exp $ */ /* *
CVS commit: src/tests/lib/libc/gen
Module Name:src Committed By: skrll Date: Sun Jan 10 20:46:14 UTC 2021 Modified Files: src/tests/lib/libc/gen: t_siginfo.c Log Message: PR/55715: pmax testbed panics with "assertion "asid == curcpu()->ci_pmap_asid_cur" failed" disable the sigbus_adraln test on qemu for now To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/tests/lib/libc/gen/t_siginfo.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/lib/libc/gen/t_siginfo.c diff -u src/tests/lib/libc/gen/t_siginfo.c:1.42 src/tests/lib/libc/gen/t_siginfo.c:1.43 --- src/tests/lib/libc/gen/t_siginfo.c:1.42 Tue Oct 13 06:55:25 2020 +++ src/tests/lib/libc/gen/t_siginfo.c Sun Jan 10 20:46:14 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_siginfo.c,v 1.42 2020/10/13 06:55:25 rin Exp $ */ +/* $NetBSD: t_siginfo.c,v 1.43 2021/01/10 20:46:14 skrll Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -481,6 +481,12 @@ ATF_TC_BODY(sigbus_adraln, tc) atf_tc_skip("No SIGBUS signal for unaligned accesses"); #endif +#if defined(__mips__) + if (isQEMU()) + atf_tc_expect_fail("QEMU fails to trap unaligned accesses with " + "correct ENTRYHI"); +#endif + sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = sigbus_action; sigemptyset(_mask);
CVS commit: src/share/man/man8
Module Name:src Committed By: riastradh Date: Sun Jan 10 19:26:32 UTC 2021 Modified Files: src/share/man/man8: rc.subr.8 Log Message: rc.subr(8): Fix markup -- use .It to set off a new item. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/share/man/man8/rc.subr.8 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/man8/rc.subr.8 diff -u src/share/man/man8/rc.subr.8:1.31 src/share/man/man8/rc.subr.8:1.32 --- src/share/man/man8/rc.subr.8:1.31 Tue Dec 18 13:14:34 2012 +++ src/share/man/man8/rc.subr.8 Sun Jan 10 19:26:31 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: rc.subr.8,v 1.31 2012/12/18 13:14:34 wiz Exp $ +.\" $NetBSD: rc.subr.8,v 1.32 2021/01/10 19:26:31 riastradh Exp $ .\" .\" Copyright (c) 2002-2011 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -161,7 +161,7 @@ otherwise is moved to .Ar backup . .El -.Ic basename Ar file Op Ar suffix +.It Ic basename Ar file Op Ar suffix Just like .Xr basename 1 , except implemented using shell built-in commands, and usable before the
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Sun Jan 10 19:20:16 UTC 2021 Modified Files: src/sys/arch/evbarm/conf: GENERIC64 Log Message: Disable nouveau for now. It can cause long pauses at boot and sometimes fails to initialize the display at all. To generate a diff of this commit: cvs rdiff -u -r1.170 -r1.171 src/sys/arch/evbarm/conf/GENERIC64 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/conf/GENERIC64 diff -u src/sys/arch/evbarm/conf/GENERIC64:1.170 src/sys/arch/evbarm/conf/GENERIC64:1.171 --- src/sys/arch/evbarm/conf/GENERIC64:1.170 Fri Jan 1 07:21:58 2021 +++ src/sys/arch/evbarm/conf/GENERIC64 Sun Jan 10 19:20:16 2021 @@ -1,5 +1,5 @@ # -# $NetBSD: GENERIC64,v 1.170 2021/01/01 07:21:58 ryo Exp $ +# $NetBSD: GENERIC64,v 1.171 2021/01/10 19:20:16 jmcneill Exp $ # # GENERIC ARM (aarch64) kernel # @@ -444,8 +444,8 @@ options FONT_BOLD16x32 # GPU #nouveau* at fdt? # NVIDIA GPU -nouveau* at pci? dev ? function ? -nouveaufb* at nouveaufbbus? +#nouveau* at pci? dev ? function ? +#nouveaufb* at nouveaufbbus? radeon* at pci? dev ? function ? # AMD Radeon radeondrmkmsfb* at radeonfbbus?
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jan 10 18:22:52 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c Log Message: lint: split check_global_variable into several functions This reduces the indentation and allows the messages in the comments to contain the complete text instead of only an abbreviated prefix. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.119 -r1.120 src/usr.bin/xlint/lint1/decl.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/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.119 src/usr.bin/xlint/lint1/decl.c:1.120 --- src/usr.bin/xlint/lint1/decl.c:1.119 Sun Jan 10 18:13:42 2021 +++ src/usr.bin/xlint/lint1/decl.c Sun Jan 10 18:22:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.119 2021/01/10 18:13:42 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.120 2021/01/10 18:22:52 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.119 2021/01/10 18:13:42 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.120 2021/01/10 18:22:52 rillig Exp $"); #endif #include @@ -79,8 +79,8 @@ static void check_argument_usage(int, sy static void check_variable_usage(int, sym_t *); static void check_label_usage(sym_t *); static void check_tag_usage(sym_t *); -static void check_global_variable(sym_t *); -static void check_global_variable_size(sym_t *); +static void check_global_variable(const sym_t *); +static void check_global_variable_size(const sym_t *); /* * initializes all global vars used in declarations @@ -3126,7 +3126,48 @@ check_global_symbols(void) } static void -check_global_variable(sym_t *sym) +check_unused_static_global_variable(const sym_t *sym) +{ + curr_pos = sym->s_def_pos; + if (sym->s_type->t_tspec == FUNC) { + if (sym->s_def == DEF) { + if (!sym->s_inline) +/* static function %s unused */ +warning(236, sym->s_name); + } else { + /* static function %s declared but not defined */ + warning(290, sym->s_name); + } + } else if (!sym->s_set) { + /* static variable %s unused */ + warning(226, sym->s_name); + } else { + /* static variable %s set but not used */ + warning(307, sym->s_name); + } +} + +static void +check_static_global_variable(const sym_t *sym) +{ + if (sym->s_type->t_tspec == FUNC && sym->s_used && sym->s_def != DEF) { + curr_pos = sym->s_use_pos; + /* static function called but not defined: %s() */ + error(225, sym->s_name); + } + + if (!sym->s_used) + check_unused_static_global_variable(sym); + + if (!tflag && sym->s_def == TDEF && sym->s_type->t_const) { + curr_pos = sym->s_def_pos; + /* const object %s should have initializer */ + warning(227, sym->s_name); + } +} + +static void +check_global_variable(const sym_t *sym) { if (sym->s_scl == TYPEDEF || sym->s_scl == ENUMCON) @@ -3139,43 +3180,12 @@ check_global_variable(sym_t *sym) check_global_variable_size(sym); - if (sym->s_scl == STATIC) { - if (sym->s_type->t_tspec == FUNC) { - if (sym->s_used && sym->s_def != DEF) { -curr_pos = sym->s_use_pos; -/* static func. called but not def... */ -error(225, sym->s_name); - } - } - if (!sym->s_used) { - curr_pos = sym->s_def_pos; - if (sym->s_type->t_tspec == FUNC) { -if (sym->s_def == DEF) { - if (!sym->s_inline) - /* static function %s unused */ - warning(236, sym->s_name); -} else { - /* static function %s declared but... */ - warning(290, sym->s_name); -} - } else if (!sym->s_set) { -/* static variable %s unused */ -warning(226, sym->s_name); - } else { -/* static variable %s set but not used */ -warning(307, sym->s_name); - } - } - if (!tflag && sym->s_def == TDEF && sym->s_type->t_const) { - curr_pos = sym->s_def_pos; - /* const object %s should have initializer */ - warning(227, sym->s_name); - } - } + if (sym->s_scl == STATIC) + check_static_global_variable(sym); } static void -check_global_variable_size(sym_t *sym) +check_global_variable_size(const sym_t *sym) { if (sym->s_def == TDEF) {
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Jan 10 18:13:43 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: d_lint_assert.c d_lint_assert.exp src/usr.bin/xlint/lint1: decl.c Log Message: lint: fix assertion failure for syntax error in enum declaration To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/d_lint_assert.c \ src/tests/usr.bin/xlint/lint1/d_lint_assert.exp cvs rdiff -u -r1.118 -r1.119 src/usr.bin/xlint/lint1/decl.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/d_lint_assert.c diff -u src/tests/usr.bin/xlint/lint1/d_lint_assert.c:1.1 src/tests/usr.bin/xlint/lint1/d_lint_assert.c:1.2 --- src/tests/usr.bin/xlint/lint1/d_lint_assert.c:1.1 Sun Jan 10 18:06:38 2021 +++ src/tests/usr.bin/xlint/lint1/d_lint_assert.c Sun Jan 10 18:13:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: d_lint_assert.c,v 1.1 2021/01/10 18:06:38 rillig Exp $ */ +/* $NetBSD: d_lint_assert.c,v 1.2 2021/01/10 18:13:43 rillig Exp $ */ # 3 "d_lint_assert.c" /* @@ -6,14 +6,10 @@ * just hard to trigger, but not impossible. */ -/* lint1-extra-flags: -p */ - enum { + // Before decl.c 1.118 from 2021-01-10: // lint: assertion "sym->s_scl == EXTERN || sym->s_scl == STATIC" // failed in check_global_variable at decl.c:3135 // near d_lint_assert.c:14 - //A = +++ - DUMMY = 0 + A = +++ }; - -"syntax error to keep the .exp file." Index: src/tests/usr.bin/xlint/lint1/d_lint_assert.exp diff -u src/tests/usr.bin/xlint/lint1/d_lint_assert.exp:1.1 src/tests/usr.bin/xlint/lint1/d_lint_assert.exp:1.2 --- src/tests/usr.bin/xlint/lint1/d_lint_assert.exp:1.1 Sun Jan 10 18:06:38 2021 +++ src/tests/usr.bin/xlint/lint1/d_lint_assert.exp Sun Jan 10 18:13:43 2021 @@ -1 +1 @@ -d_lint_assert.c(19): syntax error '"' [249] +d_lint_assert.c(15): syntax error '}' [249] Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.118 src/usr.bin/xlint/lint1/decl.c:1.119 --- src/usr.bin/xlint/lint1/decl.c:1.118 Sun Jan 10 14:12:48 2021 +++ src/usr.bin/xlint/lint1/decl.c Sun Jan 10 18:13:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.118 2021/01/10 14:12:48 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.119 2021/01/10 18:13:42 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.118 2021/01/10 14:12:48 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.119 2021/01/10 18:13:42 rillig Exp $"); #endif #include @@ -3132,6 +3132,9 @@ check_global_variable(sym_t *sym) if (sym->s_scl == TYPEDEF || sym->s_scl == ENUMCON) return; + if (sym->s_scl == NOSCL) + return; /* May be caused by a syntax error. */ + lint_assert(sym->s_scl == EXTERN || sym->s_scl == STATIC); check_global_variable_size(sym);
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Jan 10 18:06:39 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/xlint/lint1: Makefile t_integration.sh Added Files: src/tests/usr.bin/xlint/lint1: d_lint_assert.c d_lint_assert.exp Log Message: lint: add test for triggering assertion failures in lint1 To generate a diff of this commit: cvs rdiff -u -r1.1009 -r1.1010 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.27 -r1.28 src/tests/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/d_lint_assert.c \ src/tests/usr.bin/xlint/lint1/d_lint_assert.exp cvs rdiff -u -r1.23 -r1.24 src/tests/usr.bin/xlint/lint1/t_integration.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1009 src/distrib/sets/lists/tests/mi:1.1010 --- src/distrib/sets/lists/tests/mi:1.1009 Sun Jan 10 17:43:46 2021 +++ src/distrib/sets/lists/tests/mi Sun Jan 10 18:06:38 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1009 2021/01/10 17:43:46 rillig Exp $ +# $NetBSD: mi,v 1.1010 2021/01/10 18:06:38 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5799,6 +5799,8 @@ ./usr/tests/usr.bin/xlint/lint1/d_incorrect_array_size.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_init_pop_member.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_init_pop_member.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/d_lint_assert.c tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/d_lint_assert.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_long_double_int.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_long_double_int.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_nested_structs.c tests-usr.bin-tests compattestfile,atf Index: src/tests/usr.bin/xlint/lint1/Makefile diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.27 src/tests/usr.bin/xlint/lint1/Makefile:1.28 --- src/tests/usr.bin/xlint/lint1/Makefile:1.27 Sun Jan 10 17:43:46 2021 +++ src/tests/usr.bin/xlint/lint1/Makefile Sun Jan 10 18:06:38 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.27 2021/01/10 17:43:46 rillig Exp $ +# $NetBSD: Makefile,v 1.28 2021/01/10 18:06:38 rillig Exp $ NOMAN= # defined @@ -67,6 +67,8 @@ FILES+= d_incorrect_array_size.c FILES+= d_incorrect_array_size.exp FILES+= d_init_pop_member.c FILES+= d_init_pop_member.exp +FILES+= d_lint_assert.c +FILES+= d_lint_assert.exp FILES+= d_long_double_int.c FILES+= d_long_double_int.exp FILES+= d_nested_structs.c Index: src/tests/usr.bin/xlint/lint1/t_integration.sh diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.23 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.24 --- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.23 Sun Jan 10 17:43:46 2021 +++ src/tests/usr.bin/xlint/lint1/t_integration.sh Sun Jan 10 18:06:38 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_integration.sh,v 1.23 2021/01/10 17:43:46 rillig Exp $ +# $NetBSD: t_integration.sh,v 1.24 2021/01/10 18:06:38 rillig Exp $ # # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. # All rights reserved. @@ -79,6 +79,7 @@ test_case decl_old_style_arguments test_case fold_test test_case gcc_extension test_case init_pop_member +test_case lint_assert test_case return_type test_case type_question_colon test_case typefun Added files: Index: src/tests/usr.bin/xlint/lint1/d_lint_assert.c diff -u /dev/null src/tests/usr.bin/xlint/lint1/d_lint_assert.c:1.1 --- /dev/null Sun Jan 10 18:06:39 2021 +++ src/tests/usr.bin/xlint/lint1/d_lint_assert.c Sun Jan 10 18:06:38 2021 @@ -0,0 +1,19 @@ +/* $NetBSD: d_lint_assert.c,v 1.1 2021/01/10 18:06:38 rillig Exp $ */ +# 3 "d_lint_assert.c" + +/* + * Trigger the various assertions in the lint1 code. Several of them are + * just hard to trigger, but not impossible. +*/ + +/* lint1-extra-flags: -p */ + +enum { + // lint: assertion "sym->s_scl == EXTERN || sym->s_scl == STATIC" + // failed in check_global_variable at decl.c:3135 + // near d_lint_assert.c:14 + //A = +++ + DUMMY = 0 +}; + +"syntax error to keep the .exp file." Index: src/tests/usr.bin/xlint/lint1/d_lint_assert.exp diff -u /dev/null src/tests/usr.bin/xlint/lint1/d_lint_assert.exp:1.1 --- /dev/null Sun Jan 10 18:06:39 2021 +++ src/tests/usr.bin/xlint/lint1/d_lint_assert.exp Sun Jan 10 18:06:38 2021 @@ -0,0 +1 @@ +d_lint_assert.c(19): syntax error '"' [249]
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Jan 10 17:43:46 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/xlint/lint1: Makefile t_integration.sh Added Files: src/tests/usr.bin/xlint/lint1: d_c99_bool_strict.c d_c99_bool_strict.exp Log Message: lint: add test for treating _Bool as non-scalar type This strict mode is not yet implemented. The plan is to use it for usr.bin/make, to get rid of the many possible variants of defining the Boolean type in make.h. These variants did find some bugs, but not reliably so. Using static analysis seems more promising for this. In an early stage of developing this test, lint1 crashed in the enum definition in line 213, where the node for the '?:' had been NULL. This can happen in other situations as well, such as with syntax errors, but these should be rare, as lint is usually only run if the compiler has accepted the source code. Still, there should not be any assertion failures while running lint1. To generate a diff of this commit: cvs rdiff -u -r1.1008 -r1.1009 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.26 -r1.27 src/tests/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c \ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp cvs rdiff -u -r1.22 -r1.23 src/tests/usr.bin/xlint/lint1/t_integration.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1008 src/distrib/sets/lists/tests/mi:1.1009 --- src/distrib/sets/lists/tests/mi:1.1008 Sun Jan 10 11:24:42 2021 +++ src/distrib/sets/lists/tests/mi Sun Jan 10 17:43:46 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1008 2021/01/10 11:24:42 rillig Exp $ +# $NetBSD: mi,v 1.1009 2021/01/10 17:43:46 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5747,6 +5747,8 @@ ./usr/tests/usr.bin/xlint/lint1/d_c99_anon_union.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_c99_bool.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_c99_bool.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_c99_complex_num.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_c99_complex_split.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_c99_compound_literal_comma.c tests-usr.bin-tests compattestfile,atf Index: src/tests/usr.bin/xlint/lint1/Makefile diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.26 src/tests/usr.bin/xlint/lint1/Makefile:1.27 --- src/tests/usr.bin/xlint/lint1/Makefile:1.26 Sun Jan 10 11:24:42 2021 +++ src/tests/usr.bin/xlint/lint1/Makefile Sun Jan 10 17:43:46 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.26 2021/01/10 11:24:42 rillig Exp $ +# $NetBSD: Makefile,v 1.27 2021/01/10 17:43:46 rillig Exp $ NOMAN= # defined @@ -13,6 +13,8 @@ FILES+= d_alignof.c FILES+= d_bltinoffsetof.c FILES+= d_c99_bool.c FILES+= d_c99_bool.exp +FILES+= d_c99_bool_strict.c +FILES+= d_c99_bool_strict.exp FILES+= d_c99_anon_struct.c FILES+= d_c99_anon_union.c FILES+= d_c99_complex_num.c Index: src/tests/usr.bin/xlint/lint1/t_integration.sh diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.22 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.23 --- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.22 Sun Jan 10 11:24:42 2021 +++ src/tests/usr.bin/xlint/lint1/t_integration.sh Sun Jan 10 17:43:46 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_integration.sh,v 1.22 2021/01/10 11:24:42 rillig Exp $ +# $NetBSD: t_integration.sh,v 1.23 2021/01/10 17:43:46 rillig Exp $ # # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. # All rights reserved. @@ -66,6 +66,7 @@ test_case bltinoffsetof test_case c99_anon_struct test_case c99_anon_union test_case c99_bool +test_case c99_bool_strict test_case c99_compound_literal_comma test_case c99_decls_after_stmt2 test_case c99_flex_array_packed Added files: Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c diff -u /dev/null src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.1 --- /dev/null Sun Jan 10 17:43:46 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c Sun Jan 10 17:43:46 2021 @@ -0,0 +1,252 @@ +/* $NetBSD: d_c99_bool_strict.c,v 1.1 2021/01/10 17:43:46 rillig Exp $ */ +# 3 "d_c99_bool_strict.c" + +/* + * Experimental feature: allow to treat _Bool as incompatible with all + * scalar types. This means: + * + * SB001: Controlling expressions in 'if', 'while', 'for', '?:' must be of + * type _Bool instead of scalar. + * + * SB002: The operators '!', '==', '!=', '<', '<=', '>=', '>', '&&', '||' + * return _Bool
CVS commit: src/sys/dev/usb
Module Name:src Committed By: ryoon Date: Sun Jan 10 15:50:16 UTC 2021 Modified Files: src/sys/dev/usb: uaudio.c Log Message: Add whitespace after comma To generate a diff of this commit: cvs rdiff -u -r1.167 -r1.168 src/sys/dev/usb/uaudio.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/usb/uaudio.c diff -u src/sys/dev/usb/uaudio.c:1.167 src/sys/dev/usb/uaudio.c:1.168 --- src/sys/dev/usb/uaudio.c:1.167 Sun Jan 10 13:17:44 2021 +++ src/sys/dev/usb/uaudio.c Sun Jan 10 15:50:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: uaudio.c,v 1.167 2021/01/10 13:17:44 ryoon Exp $ */ +/* $NetBSD: uaudio.c,v 1.168 2021/01/10 15:50:16 ryoon Exp $ */ /* * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.167 2021/01/10 13:17:44 ryoon Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.168 2021/01/10 15:50:16 ryoon Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1786,7 +1786,7 @@ uaudio_identify_as(struct uaudio_softc * id->bNumEndpoints); break; } - id = uaudio_find_iface(tbuf, size, ,UISUBCLASS_AUDIOSTREAM); + id = uaudio_find_iface(tbuf, size, , UISUBCLASS_AUDIOSTREAM); if (id == NULL) break; }
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jan 10 14:12:48 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c main1.c Log Message: lint: remove redundant parentheses around return value To generate a diff of this commit: cvs rdiff -u -r1.117 -r1.118 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.32 -r1.33 src/usr.bin/xlint/lint1/main1.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/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.117 src/usr.bin/xlint/lint1/decl.c:1.118 --- src/usr.bin/xlint/lint1/decl.c:1.117 Sun Jan 10 14:09:57 2021 +++ src/usr.bin/xlint/lint1/decl.c Sun Jan 10 14:12:48 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.117 2021/01/10 14:09:57 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.118 2021/01/10 14:12:48 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.117 2021/01/10 14:09:57 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.118 2021/01/10 14:12:48 rillig Exp $"); #endif #include @@ -2029,20 +2029,20 @@ check_redeclaration(sym_t *dsym, int *do /* redefinition of %s */ error(28, dsym->s_name); print_previous_declaration(-1, rsym); - return(1); + return 1; } if (!eqtype(rsym->s_type, dsym->s_type, 0, 0, dowarn)) { /* redeclaration of %s */ error(27, dsym->s_name); print_previous_declaration(-1, rsym); - return(1); + return 1; } if (rsym->s_scl == EXTERN && dsym->s_scl == EXTERN) - return(0); + return 0; if (rsym->s_scl == STATIC && dsym->s_scl == STATIC) - return(0); + return 0; if (rsym->s_scl == STATIC && dsym->s_def == DECL) - return(0); + return 0; if (rsym->s_scl == EXTERN && rsym->s_def == DEF) { /* * All cases except "int a = 1; static int a;" are caught @@ -2051,13 +2051,13 @@ check_redeclaration(sym_t *dsym, int *do /* redeclaration of %s */ error(27, dsym->s_name); print_previous_declaration(-1, rsym); - return(1); + return 1; } if (rsym->s_scl == EXTERN) { /* previously declared extern, becomes static: %s */ warning(29, dsym->s_name); print_previous_declaration(-1, rsym); - return(0); + return 0; } /* * Now it's one of: Index: src/usr.bin/xlint/lint1/main1.c diff -u src/usr.bin/xlint/lint1/main1.c:1.32 src/usr.bin/xlint/lint1/main1.c:1.33 --- src/usr.bin/xlint/lint1/main1.c:1.32 Mon Jan 4 22:26:50 2021 +++ src/usr.bin/xlint/lint1/main1.c Sun Jan 10 14:12:48 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main1.c,v 1.32 2021/01/04 22:26:50 rillig Exp $ */ +/* $NetBSD: main1.c,v 1.33 2021/01/10 14:12:48 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: main1.c,v 1.32 2021/01/04 22:26:50 rillig Exp $"); +__RCSID("$NetBSD: main1.c,v 1.33 2021/01/10 14:12:48 rillig Exp $"); #endif #include @@ -200,7 +200,7 @@ main(int argc, char *argv[]) case 'm': msglist(); - return(0); + return 0; case 'R': fnaddreplsrcdir(optarg);
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jan 10 14:09:57 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c externs1.h Log Message: lint: change return type of eqptrtype to bool To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.52 -r1.53 src/usr.bin/xlint/lint1/externs1.h 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/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.116 src/usr.bin/xlint/lint1/decl.c:1.117 --- src/usr.bin/xlint/lint1/decl.c:1.116 Sun Jan 10 14:07:34 2021 +++ src/usr.bin/xlint/lint1/decl.c Sun Jan 10 14:09:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.116 2021/01/10 14:07:34 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.117 2021/01/10 14:09:57 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.116 2021/01/10 14:07:34 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.117 2021/01/10 14:09:57 rillig Exp $"); #endif #include @@ -2073,28 +2073,28 @@ check_redeclaration(sym_t *dsym, int *do return 0; } -static int -qualifiers_correspond(type_t *tp1, type_t *tp2, int ignqual) +static bool +qualifiers_correspond(const type_t *tp1, const type_t *tp2, int ignqual) { if (tp1->t_const != tp2->t_const && !ignqual && !tflag) - return 0; + return false; if (tp1->t_volatile != tp2->t_volatile && !ignqual && !tflag) - return 0; + return false; - return 1; + return true; } -int -eqptrtype(type_t *tp1, type_t *tp2, int ignqual) +bool +eqptrtype(const type_t *tp1, const type_t *tp2, int ignqual) { if (tp1->t_tspec != VOID && tp2->t_tspec != VOID) - return 0; + return false; if (!qualifiers_correspond(tp1, tp2, ignqual)) - return 0; + return false; - return 1; + return true; } Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.52 src/usr.bin/xlint/lint1/externs1.h:1.53 --- src/usr.bin/xlint/lint1/externs1.h:1.52 Sun Jan 10 14:07:34 2021 +++ src/usr.bin/xlint/lint1/externs1.h Sun Jan 10 14:09:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.52 2021/01/10 14:07:34 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.53 2021/01/10 14:09:57 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -174,7 +174,7 @@ extern sym_t *enumeration_constant(sym_t extern void decl1ext(sym_t *, int); extern void copy_usage_info(sym_t *, sym_t *); extern int check_redeclaration(sym_t *, int *); -extern int eqptrtype(type_t *, type_t *, int); +extern bool eqptrtype(const type_t *, const type_t *, int); extern int eqtype(type_t *, type_t *, int, int, int *); extern void complete_type(sym_t *, sym_t *); extern sym_t *declare_argument(sym_t *, int);
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jan 10 14:07:34 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y decl.c externs1.h Log Message: lint: rename functions with short names To generate a diff of this commit: cvs rdiff -u -r1.137 -r1.138 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.115 -r1.116 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.51 -r1.52 src/usr.bin/xlint/lint1/externs1.h 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.137 src/usr.bin/xlint/lint1/cgram.y:1.138 --- src/usr.bin/xlint/lint1/cgram.y:1.137 Sun Jan 10 00:05:46 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Jan 10 14:07:34 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.137 2021/01/10 00:05:46 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.138 2021/01/10 14:07:34 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.137 2021/01/10 00:05:46 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.138 2021/01/10 14:07:34 rillig Exp $"); #endif #include @@ -1281,13 +1281,13 @@ parameter_type_list: parameter_declaration: declmods deftyp { - $$ = decl1arg(abstract_name(), 0); + $$ = declare_argument(abstract_name(), 0); } | declspecs deftyp { - $$ = decl1arg(abstract_name(), 0); + $$ = declare_argument(abstract_name(), 0); } | declmods deftyp notype_param_decl { - $$ = decl1arg($3, 0); + $$ = declare_argument($3, 0); } /* * param_decl is needed because of following conflict: @@ -1297,13 +1297,13 @@ parameter_declaration: * This grammar realizes the second case. */ | declspecs deftyp param_decl { - $$ = decl1arg($3, 0); + $$ = declare_argument($3, 0); } | declmods deftyp abs_decl { - $$ = decl1arg($3, 0); + $$ = declare_argument($3, 0); } | declspecs deftyp abs_decl { - $$ = decl1arg($3, 0); + $$ = declare_argument($3, 0); } ; @@ -2157,7 +2157,7 @@ idecl(sym_t *decl, int initflg, sbuf_t * freeyyv(, T_NAME); break; } - (void)decl1arg(decl, initflg); + (void)declare_argument(decl, initflg); break; case AUTO: if (renaming != NULL) { @@ -2166,7 +2166,7 @@ idecl(sym_t *decl, int initflg, sbuf_t * freeyyv(, T_NAME); break; } - decl1loc(decl, initflg); + declare_local(decl, initflg); break; default: LERROR("idecl(%d)", dcs->d_ctx); Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.115 src/usr.bin/xlint/lint1/decl.c:1.116 --- src/usr.bin/xlint/lint1/decl.c:1.115 Sun Jan 10 13:54:13 2021 +++ src/usr.bin/xlint/lint1/decl.c Sun Jan 10 14:07:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.115 2021/01/10 13:54:13 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.116 2021/01/10 14:07:34 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.115 2021/01/10 13:54:13 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.116 2021/01/10 14:07:34 rillig Exp $"); #endif #include @@ -73,7 +73,7 @@ static int check_old_style_definition(sy static int check_prototype_declaration(sym_t *, sym_t *); static sym_t *new_style_function(sym_t *, sym_t *); static void old_style_function(sym_t *, sym_t *); -static void ledecl(sym_t *); +static void declare_external_in_block(sym_t *); static int check_init(sym_t *); static void check_argument_usage(int, sym_t *); static void check_variable_usage(int, sym_t *); @@ -1549,8 +1549,8 @@ declarator_name(sym_t *sym) /* * XXX somewhat ugly because we dont know whether * this is AUTO or EXTERN (functions). If we are - * wrong it must be corrected in decl1loc(), where - * we have the necessary type information. + * wrong it must be corrected in declare_local(), + * where we have the necessary type information. */ sc = AUTO; sym->s_def = DEF; @@ -2074,7 +2074,7 @@ check_redeclaration(sym_t *dsym, int *do } static int -chkqual(type_t *tp1, type_t *tp2, int ignqual) +qualifiers_correspond(type_t *tp1, type_t *tp2, int ignqual) { if (tp1->t_const != tp2->t_const && !ignqual && !tflag) return 0; @@ -2091,7 +2091,7 @@ eqptrtype(type_t *tp1, type_t *tp2, int if (tp1->t_tspec != VOID && tp2->t_tspec != VOID) return 0; - if (!chkqual(tp1, tp2, ignqual)) + if (!qualifiers_correspond(tp1, tp2, ignqual)) return 0; return 1; @@ -2133,7 +2133,7 @@ eqtype(type_t *tp1, type_t *tp2, int ign if (t != tp2->t_tspec) return 0; - if (!chkqual(tp1, tp2, ignqual)) + if (!qualifiers_correspond(tp1, tp2, ignqual)) return 0; if (t == STRUCT || t == UNION) @@ -2324,7 +2324,7 @@ complete_type(sym_t *dsym, sym_t *ssym) * Completes the declaration of a single argument. */
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Jan 10 13:54:13 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_232.c msg_232.exp src/usr.bin/xlint/lint1: decl.c Log Message: lint: use message 232 for unused label in function This message had been defined but not used before. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_232.c \ src/tests/usr.bin/xlint/lint1/msg_232.exp cvs rdiff -u -r1.114 -r1.115 src/usr.bin/xlint/lint1/decl.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_232.c diff -u src/tests/usr.bin/xlint/lint1/msg_232.c:1.1 src/tests/usr.bin/xlint/lint1/msg_232.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_232.c:1.1 Sat Jan 2 10:22:44 2021 +++ src/tests/usr.bin/xlint/lint1/msg_232.c Sun Jan 10 13:54:13 2021 @@ -1,7 +1,14 @@ -/* $NetBSD: msg_232.c,v 1.1 2021/01/02 10:22:44 rillig Exp $ */ +/* $NetBSD: msg_232.c,v 1.2 2021/01/10 13:54:13 rillig Exp $ */ # 3 "msg_232.c" // Test for message: label %s unused in function %s [232] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +void +example(void) +{ + goto used_label; +unused_label: + return; +used_label: + return; +} Index: src/tests/usr.bin/xlint/lint1/msg_232.exp diff -u src/tests/usr.bin/xlint/lint1/msg_232.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_232.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_232.exp:1.1 Sat Jan 2 10:22:44 2021 +++ src/tests/usr.bin/xlint/lint1/msg_232.exp Sun Jan 10 13:54:13 2021 @@ -1 +1 @@ -msg_232.c(6): syntax error ':' [249] +msg_232.c(10): warning: label unused_label unused in function example [232] Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.114 src/usr.bin/xlint/lint1/decl.c:1.115 --- src/usr.bin/xlint/lint1/decl.c:1.114 Sun Jan 10 00:05:46 2021 +++ src/usr.bin/xlint/lint1/decl.c Sun Jan 10 13:54:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.114 2021/01/10 00:05:46 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.115 2021/01/10 13:54:13 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.114 2021/01/10 00:05:46 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.115 2021/01/10 13:54:13 rillig Exp $"); #endif #include @@ -3051,8 +3051,8 @@ check_label_usage(sym_t *lab) if (lab->s_set && !lab->s_used) { curr_pos = lab->s_set_pos; - /* %s unused in function %s */ - warning(192, lab->s_name, funcsym->s_name); + /* label %s unused in function %s */ + warning(232, lab->s_name, funcsym->s_name); } else if (!lab->s_set) { curr_pos = lab->s_use_pos; /* undefined label %s */
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: martin Date: Sun Jan 10 13:44:57 UTC 2021 Modified Files: src/usr.sbin/fstyp: hammer2.c Log Message: Explicitly cast offset calculation, size_t may be smaller than off_t. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/fstyp/hammer2.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.sbin/fstyp/hammer2.c diff -u src/usr.sbin/fstyp/hammer2.c:1.7 src/usr.sbin/fstyp/hammer2.c:1.8 --- src/usr.sbin/fstyp/hammer2.c:1.7 Sun Jan 10 12:38:40 2021 +++ src/usr.sbin/fstyp/hammer2.c Sun Jan 10 13:44:57 2021 @@ -1,4 +1,4 @@ -/*$NetBSD: hammer2.c,v 1.7 2021/01/10 12:38:40 tkusumi Exp $ */ +/*$NetBSD: hammer2.c,v 1.8 2021/01/10 13:44:57 martin Exp $ */ /*- * Copyright (c) 2017-2019 The DragonFly Project @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.7 2021/01/10 12:38:40 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.8 2021/01/10 13:44:57 martin Exp $"); #include #include @@ -145,7 +145,7 @@ read_media(FILE *fp, const hammer2_block io_off = bref->data_off & ~HAMMER2_OFF_MASK_RADIX; io_base = io_off & ~(hammer2_off_t)(HAMMER2_LBUFSIZE - 1); - boff = io_off - io_base; + boff = (size_t)((hammer2_off_t)io_off - io_base); io_bytes = HAMMER2_LBUFSIZE; while (io_bytes + boff < bytes)
CVS commit: src/sys/dev/usb
Module Name:src Committed By: ryoon Date: Sun Jan 10 13:17:44 UTC 2021 Modified Files: src/sys/dev/usb: uaudio.c Log Message: Fix a typo in debug message To generate a diff of this commit: cvs rdiff -u -r1.166 -r1.167 src/sys/dev/usb/uaudio.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/usb/uaudio.c diff -u src/sys/dev/usb/uaudio.c:1.166 src/sys/dev/usb/uaudio.c:1.167 --- src/sys/dev/usb/uaudio.c:1.166 Tue Dec 29 08:04:59 2020 +++ src/sys/dev/usb/uaudio.c Sun Jan 10 13:17:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: uaudio.c,v 1.166 2020/12/29 08:04:59 jdc Exp $ */ +/* $NetBSD: uaudio.c,v 1.167 2021/01/10 13:17:44 ryoon Exp $ */ /* * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.166 2020/12/29 08:04:59 jdc Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.167 2021/01/10 13:17:44 ryoon Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1546,7 +1546,7 @@ uaudio_process_as(struct uaudio_softc *s if (asid->bDescriptorType != UDESC_CS_INTERFACE || asid->bDescriptorSubtype != AS_GENERAL) return USBD_INVAL; - DPRINTF("asid: bTerminakLink=%d wFormatTag=%d\n", + DPRINTF("asid: bTerminalLink=%d wFormatTag=%d\n", asid->bTerminalLink, UGETW(asid->wFormatTag)); offs += asid->bLength; if (offs > size)
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jan 10 13:17:24 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: d_c99_bool.c d_c99_bool.exp Log Message: lint: explain missing error for _Bool constant expressions To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/d_c99_bool.c \ src/tests/usr.bin/xlint/lint1/d_c99_bool.exp 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/d_c99_bool.c diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool.c:1.4 src/tests/usr.bin/xlint/lint1/d_c99_bool.c:1.5 --- src/tests/usr.bin/xlint/lint1/d_c99_bool.c:1.4 Sun Jan 10 12:46:38 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool.c Sun Jan 10 13:17:24 2021 @@ -1,5 +1,5 @@ -/* $NetBSD: d_c99_bool.c,v 1.4 2021/01/10 12:46:38 rillig Exp $ */ -# 3 "d_bool.c" +/* $NetBSD: d_c99_bool.c,v 1.5 2021/01/10 13:17:24 rillig Exp $ */ +# 3 "d_c99_bool.c" /* * C99 6.3.1.2 says: "When any scalar value is converted to _Bool, the result @@ -9,7 +9,7 @@ * invoke undefined behavior. */ -/* Below, the wrong assertions produce warning 20. */ +/* Below, each wrong assertion produces "negative array dimension" [20]. */ int int_0_converts_to_false[(_Bool)0 ? -1 : 1]; int int_0_converts_to_true_[(_Bool)0 ? 1 : -1]; @@ -26,8 +26,17 @@ int int_256_converts_to_true_[(_Bool)256 int null_pointer_converts_to_false[(_Bool)(void *)0 ? -1 : 1]; int null_pointer_converts_to_true_[(_Bool)(void *)0 ? 1 : -1]; -int nonnull_pointer_converts_to_false[(_Bool)"not null" ? -1 : 1]; -int nonnull_pointer_converts_to_true_[(_Bool)"not null" ? 1 : -1]; +/* + * XXX: lint does not treat the address of a global variable as a constant + * expression. This goes against C99 6.6p7 but is probably not too relevant + * in practice. + * + * The call to constant(tn, 0) defaults to 1, then. This is why neither of + * the following array declarations generates an error message. + */ +char ch; +int nonnull_pointer_converts_to_false[(_Bool) ? -1 : 1]; +int nonnull_pointer_converts_to_true_[(_Bool) ? 1 : -1]; int double_minus_1_0_converts_to_false[(_Bool)-1.0 ? -1 : 1]; int double_minus_1_0_converts_to_true_[(_Bool)-1.0 ? 1 : -1]; Index: src/tests/usr.bin/xlint/lint1/d_c99_bool.exp diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool.exp:1.4 src/tests/usr.bin/xlint/lint1/d_c99_bool.exp:1.5 --- src/tests/usr.bin/xlint/lint1/d_c99_bool.exp:1.4 Sun Jan 10 12:46:38 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool.exp Sun Jan 10 13:17:24 2021 @@ -1,11 +1,11 @@ -d_bool.c(15): negative array dimension (-1) [20] -d_bool.c(17): negative array dimension (-1) [20] -d_bool.c(20): negative array dimension (-1) [20] -d_bool.c(23): negative array dimension (-1) [20] -d_bool.c(27): negative array dimension (-1) [20] -d_bool.c(32): negative array dimension (-1) [20] -d_bool.c(35): negative array dimension (-1) [20] -d_bool.c(39): negative array dimension (-1) [20] -d_bool.c(42): negative array dimension (-1) [20] -d_bool.c(45): negative array dimension (-1) [20] -d_bool.c(48): negative array dimension (-1) [20] +d_c99_bool.c(15): negative array dimension (-1) [20] +d_c99_bool.c(17): negative array dimension (-1) [20] +d_c99_bool.c(20): negative array dimension (-1) [20] +d_c99_bool.c(23): negative array dimension (-1) [20] +d_c99_bool.c(27): negative array dimension (-1) [20] +d_c99_bool.c(41): negative array dimension (-1) [20] +d_c99_bool.c(44): negative array dimension (-1) [20] +d_c99_bool.c(48): negative array dimension (-1) [20] +d_c99_bool.c(51): negative array dimension (-1) [20] +d_c99_bool.c(54): negative array dimension (-1) [20] +d_c99_bool.c(57): negative array dimension (-1) [20]
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Jan 10 12:46:38 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: d_c99_bool.c d_c99_bool.exp src/usr.bin/xlint/lint1: tree.c Log Message: lint: fix conversion of non-constant scalar to _Bool To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/d_c99_bool.c \ src/tests/usr.bin/xlint/lint1/d_c99_bool.exp cvs rdiff -u -r1.147 -r1.148 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/d_c99_bool.c diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool.c:1.3 src/tests/usr.bin/xlint/lint1/d_c99_bool.c:1.4 --- src/tests/usr.bin/xlint/lint1/d_c99_bool.c:1.3 Sun Jan 10 12:34:56 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool.c Sun Jan 10 12:46:38 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: d_c99_bool.c,v 1.3 2021/01/10 12:34:56 rillig Exp $ */ +/* $NetBSD: d_c99_bool.c,v 1.4 2021/01/10 12:46:38 rillig Exp $ */ # 3 "d_bool.c" /* @@ -26,8 +26,8 @@ int int_256_converts_to_true_[(_Bool)256 int null_pointer_converts_to_false[(_Bool)(void *)0 ? -1 : 1]; int null_pointer_converts_to_true_[(_Bool)(void *)0 ? 1 : -1]; -int nonnull_pointer_converts_to_false[(_Bool)"not null" ? -1 : 1]; // FIXME 133 -int nonnull_pointer_converts_to_true_[(_Bool)"not null" ? 1 : -1]; // FIXME 133 +int nonnull_pointer_converts_to_false[(_Bool)"not null" ? -1 : 1]; +int nonnull_pointer_converts_to_true_[(_Bool)"not null" ? 1 : -1]; int double_minus_1_0_converts_to_false[(_Bool)-1.0 ? -1 : 1]; int double_minus_1_0_converts_to_true_[(_Bool)-1.0 ? 1 : -1]; @@ -85,13 +85,13 @@ enum_to_bool(enum color e) _Bool pointer_to_bool(const char *p) { - return p; // FIXME 183 + return p; } _Bool function_pointer_to_bool(void (*f)(void)) { - return f; // FIXME 183 + return f; } _Bool Index: src/tests/usr.bin/xlint/lint1/d_c99_bool.exp diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool.exp:1.3 src/tests/usr.bin/xlint/lint1/d_c99_bool.exp:1.4 --- src/tests/usr.bin/xlint/lint1/d_c99_bool.exp:1.3 Sun Jan 10 12:34:56 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool.exp Sun Jan 10 12:46:38 2021 @@ -3,13 +3,9 @@ d_bool.c(17): negative array dimension ( d_bool.c(20): negative array dimension (-1) [20] d_bool.c(23): negative array dimension (-1) [20] d_bool.c(27): negative array dimension (-1) [20] -d_bool.c(29): warning: conversion of pointer to '_Bool' loses bits [133] -d_bool.c(30): warning: conversion of pointer to '_Bool' loses bits [133] d_bool.c(32): negative array dimension (-1) [20] d_bool.c(35): negative array dimension (-1) [20] d_bool.c(39): negative array dimension (-1) [20] d_bool.c(42): negative array dimension (-1) [20] d_bool.c(45): negative array dimension (-1) [20] d_bool.c(48): negative array dimension (-1) [20] -d_bool.c(88): warning: illegal combination of integer (_Bool) and pointer (pointer to const char) [183] -d_bool.c(94): warning: illegal combination of integer (_Bool) and pointer (pointer to function() returning void) [183] Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.147 src/usr.bin/xlint/lint1/tree.c:1.148 --- src/usr.bin/xlint/lint1/tree.c:1.147 Sun Jan 10 12:34:56 2021 +++ src/usr.bin/xlint/lint1/tree.c Sun Jan 10 12:46:38 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.147 2021/01/10 12:34:56 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.148 2021/01/10 12:46:38 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.147 2021/01/10 12:34:56 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.148 2021/01/10 12:46:38 rillig Exp $"); #endif #include @@ -1296,6 +1296,9 @@ check_assign_types_compatible(op_t op, i rst = (rstp = rtp->t_subt)->t_tspec; mp = [op]; + if (lt == BOOL && is_scalar(rt)) /* C99 6.3.1.2 */ + return 1; + if (is_arithmetic(lt) && is_arithmetic(rt)) return 1; @@ -1787,7 +1790,7 @@ convert(op_t op, int arg, type_t *tp, tn is_integer(ot)) && tn->tn_op == CON && tn->tn_val->v_quad == 0) { /* 0, 0L and (void *)0 may be assigned to any pointer. */ - } else if (is_integer(nt) && ot == PTR) { + } else if (is_integer(nt) && nt != BOOL && ot == PTR) { check_pointer_integer_conversion(op, nt, tp, tn); } else if (nt == PTR && ot == PTR) { check_pointer_conversion(op, tn, tp); @@ -1948,10 +1951,10 @@ check_pointer_integer_conversion(op_t op if (psize(nt) < psize(PTR)) { if (pflag && size(nt) >= size(PTR)) { - /* conv. of pointer to '%s' may lose bits */ + /* conversion of pointer to '%s' may lose bits */ warning(134, type_name(tp)); } else { - /* conv. of pointer to '%s' loses bits */ + /* conversion of pointer to '%s' loses bits */ warning(133, type_name(tp)); } }
CVS commit: src/usr.sbin/fstyp
Module Name:src Committed By: tkusumi Date: Sun Jan 10 12:38:41 UTC 2021 Modified Files: src/usr.sbin/fstyp: fstyp.h hammer.c hammer2.c hammer2_disk.h Log Message: fstyp: Sync HAMMER1/2 with DragonFly BSD taken-from: DragonFly BSD To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/fstyp/fstyp.h cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/fstyp/hammer.c cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/fstyp/hammer2.c cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/fstyp/hammer2_disk.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fstyp/fstyp.h diff -u src/usr.sbin/fstyp/fstyp.h:1.8 src/usr.sbin/fstyp/fstyp.h:1.9 --- src/usr.sbin/fstyp/fstyp.h:1.8 Wed Jan 1 09:08:52 2020 +++ src/usr.sbin/fstyp/fstyp.h Sun Jan 10 12:38:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: fstyp.h,v 1.8 2020/01/01 09:08:52 tkusumi Exp $ */ +/* $NetBSD: fstyp.h,v 1.9 2021/01/10 12:38:40 tkusumi Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -74,5 +74,7 @@ int fstyp_zfs(FILE *, char *, size_t); int fsvtyp_hammer(const char *, char *, size_t); int fsvtyp_hammer_partial(const char *, char *, size_t); +int fsvtyp_hammer2(const char *, char *, size_t); +int fsvtyp_hammer2_partial(const char *, char *, size_t); #endif /* !FSTYP_H */ Index: src/usr.sbin/fstyp/hammer.c diff -u src/usr.sbin/fstyp/hammer.c:1.3 src/usr.sbin/fstyp/hammer.c:1.4 --- src/usr.sbin/fstyp/hammer.c:1.3 Wed Jan 15 15:30:46 2020 +++ src/usr.sbin/fstyp/hammer.c Sun Jan 10 12:38:40 2021 @@ -1,4 +1,4 @@ -/*$NetBSD: hammer.c,v 1.3 2020/01/15 15:30:46 tkusumi Exp $ */ +/*$NetBSD: hammer.c,v 1.4 2021/01/10 12:38:40 tkusumi Exp $ */ /*- * Copyright (c) 2016-2019 The DragonFly Project @@ -27,13 +27,13 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: hammer.c,v 1.3 2020/01/15 15:30:46 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hammer.c,v 1.4 2021/01/10 12:38:40 tkusumi Exp $"); #include #include #include #include -#include +#include #include "fstyp.h" #include "hammer_disk.h" @@ -41,13 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: hammer.c,v 1 static hammer_volume_ondisk_t read_ondisk(FILE *fp) { - hammer_volume_ondisk_t ondisk; - - ondisk = read_buf(fp, 0, sizeof(*ondisk)); - if (ondisk == NULL) - err(1, "failed to read ondisk"); - - return (ondisk); + return (read_buf(fp, 0, sizeof(struct hammer_volume_ondisk))); } static int @@ -61,32 +55,49 @@ test_ondisk(const hammer_volume_ondisk_t ondisk->vol_signature != HAMMER_FSBUF_VOLUME_REV) return (1); if (ondisk->vol_rootvol != HAMMER_ROOT_VOLNO) - return (2); + return (1); if (ondisk->vol_no < 0 || ondisk->vol_no > HAMMER_MAX_VOLUMES - 1) - return (3); + return (1); if (ondisk->vol_count < 1 || ondisk->vol_count > HAMMER_MAX_VOLUMES) - return (4); + return (1); if (count == 0) { count = ondisk->vol_count; - assert(count != 0); + if (count == 0) + return (1); memcpy(, >vol_fsid, sizeof(fsid)); memcpy(, >vol_fstype, sizeof(fstype)); strlcpy(label, ondisk->vol_label, sizeof(label)); } else { if (ondisk->vol_count != count) - return (5); - if (memcmp(>vol_fsid, , sizeof(fsid))) - return (6); - if (memcmp(>vol_fstype, , sizeof(fstype))) - return (7); + return (1); + if (!uuid_equal(>vol_fsid, , NULL)) + return (1); + if (!uuid_equal(>vol_fstype, , NULL)) + return (1); if (strcmp(ondisk->vol_label, label)) - return (8); + return (1); } return (0); } +static const char* +extract_device_name(const char *devpath) +{ + const char *p; + + p = strrchr(devpath, '/'); + if (p) { + p++; + if (*p == 0) + p = NULL; + } else { + p = devpath; + } + return (p); +} + int fstyp_hammer(FILE *fp, char *label, size_t size) { @@ -96,6 +107,8 @@ fstyp_hammer(FILE *fp, char *label, size const char *p; #endif ondisk = read_ondisk(fp); + if (!ondisk) + goto fail; if (ondisk->vol_no != HAMMER_ROOT_VOLNO) goto fail; if (ondisk->vol_count != 1) @@ -109,15 +122,11 @@ fstyp_hammer(FILE *fp, char *label, size */ #ifdef HAS_DEVPATH /* Add device name to help support multiple autofs -media mounts. */ - p = strrchr(devpath, '/'); - if (p) { - p++; - if (*p == 0) - strlcpy(label, ondisk->vol_label, size); - else - snprintf(label, size, "%s_%s", ondisk->vol_label, p); - } else - snprintf(label, size, "%s_%s", ondisk->vol_label, devpath); + p = extract_device_name(devpath); + if (p) + snprintf(label, size, "%s_%s", ondisk->vol_label, p); + else + strlcpy(label, ondisk->vol_label, size); #else strlcpy(label, ondisk->vol_label, size); #endif @@ -130,20 +139,23 @@ fail: static int test_volume(const char *volpath) { - hammer_volume_ondisk_t ondisk; + hammer_volume_ondisk_t ondisk = NULL; FILE *fp; int volno = -1; if ((fp = fopen(volpath, "r")) == NULL) - err(1, "failed to open %s", volpath); + goto fail; ondisk = read_ondisk(fp); -
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Jan 10 12:34:56 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: d_c99_bool.c d_c99_bool.exp src/usr.bin/xlint/lint1: tree.c Log Message: lint: fix conversion of constant expressions to _Bool To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/d_c99_bool.c \ src/tests/usr.bin/xlint/lint1/d_c99_bool.exp cvs rdiff -u -r1.146 -r1.147 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/d_c99_bool.c diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool.c:1.2 src/tests/usr.bin/xlint/lint1/d_c99_bool.c:1.3 --- src/tests/usr.bin/xlint/lint1/d_c99_bool.c:1.2 Sun Jan 10 12:29:46 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool.c Sun Jan 10 12:34:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: d_c99_bool.c,v 1.2 2021/01/10 12:29:46 rillig Exp $ */ +/* $NetBSD: d_c99_bool.c,v 1.3 2021/01/10 12:34:56 rillig Exp $ */ # 3 "d_bool.c" /* @@ -20,8 +20,8 @@ int int_1_converts_to_true_[(_Bool)1 ? 1 int int_2_converts_to_false[(_Bool)2 ? -1 : 1]; int int_2_converts_to_true_[(_Bool)2 ? 1 : -1]; -int int_256_converts_to_false[(_Bool)256 ? -1 : 1]; // FIXME -int int_256_converts_to_true_[(_Bool)256 ? 1 : -1]; // FIXME +int int_256_converts_to_false[(_Bool)256 ? -1 : 1]; +int int_256_converts_to_true_[(_Bool)256 ? 1 : -1]; int null_pointer_converts_to_false[(_Bool)(void *)0 ? -1 : 1]; int null_pointer_converts_to_true_[(_Bool)(void *)0 ? 1 : -1]; @@ -29,11 +29,11 @@ int null_pointer_converts_to_true_[(_Boo int nonnull_pointer_converts_to_false[(_Bool)"not null" ? -1 : 1]; // FIXME 133 int nonnull_pointer_converts_to_true_[(_Bool)"not null" ? 1 : -1]; // FIXME 133 -int double_minus_1_0_converts_to_false[(_Bool)-1.0 ? -1 : 1]; // FIXME 119 -int double_minus_1_0_converts_to_true_[(_Bool)-1.0 ? 1 : -1]; // FIXME 20, 119 +int double_minus_1_0_converts_to_false[(_Bool)-1.0 ? -1 : 1]; +int double_minus_1_0_converts_to_true_[(_Bool)-1.0 ? 1 : -1]; -int double_minus_0_5_converts_to_false[(_Bool)-0.5 ? -1 : 1]; // FIXME 119 -int double_minus_0_5_converts_to_true_[(_Bool)-0.5 ? 1 : -1]; // FIXME 20, 119 +int double_minus_0_5_converts_to_false[(_Bool)-0.5 ? -1 : 1]; +int double_minus_0_5_converts_to_true_[(_Bool)-0.5 ? 1 : -1]; int double_minus_0_0_converts_to_false[(_Bool)-0.0 ? -1 : 1]; int double_minus_0_0_converts_to_true_[(_Bool)-0.0 ? 1 : -1]; @@ -42,8 +42,8 @@ int double_0_0_converts_to_false[(_Bool) int double_0_0_converts_to_true_[(_Bool)0.0 ? 1 : -1]; /* The C99 rationale explains in 6.3.1.2 why (_Bool)0.5 is true. */ -int double_0_5_converts_to_false[(_Bool)0.5 ? -1 : 1]; // FIXME 20 -int double_0_5_converts_to_true_[(_Bool)0.5 ? 1 : -1]; // FIXME 20 +int double_0_5_converts_to_false[(_Bool)0.5 ? -1 : 1]; +int double_0_5_converts_to_true_[(_Bool)0.5 ? 1 : -1]; int double_1_0_converts_to_false[(_Bool)1.0 ? -1 : 1]; int double_1_0_converts_to_true_[(_Bool)1.0 ? 1 : -1]; Index: src/tests/usr.bin/xlint/lint1/d_c99_bool.exp diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool.exp:1.2 src/tests/usr.bin/xlint/lint1/d_c99_bool.exp:1.3 --- src/tests/usr.bin/xlint/lint1/d_c99_bool.exp:1.2 Sun Jan 10 12:29:46 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool.exp Sun Jan 10 12:34:56 2021 @@ -1,19 +1,15 @@ d_bool.c(15): negative array dimension (-1) [20] d_bool.c(17): negative array dimension (-1) [20] d_bool.c(20): negative array dimension (-1) [20] -d_bool.c(24): negative array dimension (-1) [20] +d_bool.c(23): negative array dimension (-1) [20] d_bool.c(27): negative array dimension (-1) [20] d_bool.c(29): warning: conversion of pointer to '_Bool' loses bits [133] d_bool.c(30): warning: conversion of pointer to '_Bool' loses bits [133] -d_bool.c(32): warning: conversion of 'double' to '_Bool' is out of range [119] -d_bool.c(33): warning: conversion of 'double' to '_Bool' is out of range [119] -d_bool.c(33): negative array dimension (-1) [20] -d_bool.c(35): warning: conversion of 'double' to '_Bool' is out of range [119] -d_bool.c(36): warning: conversion of 'double' to '_Bool' is out of range [119] -d_bool.c(36): negative array dimension (-1) [20] +d_bool.c(32): negative array dimension (-1) [20] +d_bool.c(35): negative array dimension (-1) [20] d_bool.c(39): negative array dimension (-1) [20] d_bool.c(42): negative array dimension (-1) [20] -d_bool.c(46): negative array dimension (-1) [20] +d_bool.c(45): negative array dimension (-1) [20] d_bool.c(48): negative array dimension (-1) [20] d_bool.c(88): warning: illegal combination of integer (_Bool) and pointer (pointer to const char) [183] d_bool.c(94): warning: illegal combination of integer (_Bool) and pointer (pointer to function() returning void) [183] Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.146 src/usr.bin/xlint/lint1/tree.c:1.147 ---
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jan 10 12:29:46 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: d_c99_bool.c d_c99_bool.exp Log Message: lint: add test for converting non-constant expressions to _Bool To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/d_c99_bool.c \ src/tests/usr.bin/xlint/lint1/d_c99_bool.exp 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/d_c99_bool.c diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool.c:1.1 src/tests/usr.bin/xlint/lint1/d_c99_bool.c:1.2 --- src/tests/usr.bin/xlint/lint1/d_c99_bool.c:1.1 Sun Jan 10 11:24:42 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool.c Sun Jan 10 12:29:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: d_c99_bool.c,v 1.1 2021/01/10 11:24:42 rillig Exp $ */ +/* $NetBSD: d_c99_bool.c,v 1.2 2021/01/10 12:29:46 rillig Exp $ */ # 3 "d_bool.c" /* @@ -47,3 +47,55 @@ int double_0_5_converts_to_true_[(_Bool) int double_1_0_converts_to_false[(_Bool)1.0 ? -1 : 1]; int double_1_0_converts_to_true_[(_Bool)1.0 ? 1 : -1]; + +_Bool +bool_to_bool(_Bool b) +{ + return b; +} + +_Bool +char_to_bool(char c) +{ + return c; +} + +_Bool +int_to_bool(int i) +{ + return i; +} + +_Bool +double_to_bool(double d) +{ + return d; +} + +enum color { + RED +}; + +_Bool +enum_to_bool(enum color e) +{ + return e; +} + +_Bool +pointer_to_bool(const char *p) +{ + return p; // FIXME 183 +} + +_Bool +function_pointer_to_bool(void (*f)(void)) +{ + return f; // FIXME 183 +} + +_Bool +complex_to_bool(double _Complex c) +{ + return c; +} Index: src/tests/usr.bin/xlint/lint1/d_c99_bool.exp diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool.exp:1.1 src/tests/usr.bin/xlint/lint1/d_c99_bool.exp:1.2 --- src/tests/usr.bin/xlint/lint1/d_c99_bool.exp:1.1 Sun Jan 10 11:24:42 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool.exp Sun Jan 10 12:29:46 2021 @@ -15,3 +15,5 @@ d_bool.c(39): negative array dimension ( d_bool.c(42): negative array dimension (-1) [20] d_bool.c(46): negative array dimension (-1) [20] d_bool.c(48): negative array dimension (-1) [20] +d_bool.c(88): warning: illegal combination of integer (_Bool) and pointer (pointer to const char) [183] +d_bool.c(94): warning: illegal combination of integer (_Bool) and pointer (pointer to function() returning void) [183]
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jan 10 12:05:07 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: Makefile Log Message: lint: automate adding a test for lint1 To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/usr.bin/xlint/lint1/Makefile 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/Makefile diff -u src/usr.bin/xlint/lint1/Makefile:1.57 src/usr.bin/xlint/lint1/Makefile:1.58 --- src/usr.bin/xlint/lint1/Makefile:1.57 Sat Jan 9 21:37:44 2021 +++ src/usr.bin/xlint/lint1/Makefile Sun Jan 10 12:05:07 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.57 2021/01/09 21:37:44 rillig Exp $ +# $NetBSD: Makefile,v 1.58 2021/01/10 12:05:07 rillig Exp $ .include @@ -43,4 +43,44 @@ oper.o: ops.def .include "Makefile.err-msgs-h" ${SRCS:Nerr.c}: err-msgs.h +add-test: .PHONY + @set -eu; \ + test=${NAME:Q}; \ + [ "$$test" ] || { \ + echo "usage: ${MAKE} add-test NAME="; \ + exit; \ + }; \ + \ + cd '../../../tests/usr.bin/xlint/lint1'; \ + if [ -f "$$test.c" ]; then \ + echo "error: test $$test already exists in $$PWD."; \ + exit 1; \ + fi; \ + \ + echo "=> Adding test $$test"; \ + printf '%s\n' \ + '/* $$''NetBSD$$ */' \ + "# 3 \"$$test.c\"" \ + '' \ + '/*' \ + ' * TODO: Explain the purpose of the test.' \ + '*/' \ + '' \ + '/* lint1-extra-flags: -p */' \ + '' \ + '// TODO: Add some code that passes.' \ + '// TODO: Add some code that fails.' \ + > "$$test.c"; \ + > "$$test.exp"; \ + cvs add "$$test.c" "$$test.exp"; \ + printf '%s\n' \ + '/^FILES+=/i' \ + "FILES+= $$test.c" \ + "FILES+= $$test.exp" \ + '.' 'w' 'q' \ + | ed Makefile; \ + ${MAKE} sync-mi; \ + printf '%s\n' '/^test_case /i' "test_case $$test" '.' 'w' 'q' \ + | ed t_integration.sh + .include
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Jan 10 11:24:43 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/xlint/lint1: Makefile t_integration.sh Added Files: src/tests/usr.bin/xlint/lint1: d_c99_bool.c d_c99_bool.exp Log Message: lint: demonstrate wrong handling of conversion to _Bool To generate a diff of this commit: cvs rdiff -u -r1.1007 -r1.1008 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.25 -r1.26 src/tests/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/d_c99_bool.c \ src/tests/usr.bin/xlint/lint1/d_c99_bool.exp cvs rdiff -u -r1.21 -r1.22 src/tests/usr.bin/xlint/lint1/t_integration.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1007 src/distrib/sets/lists/tests/mi:1.1008 --- src/distrib/sets/lists/tests/mi:1.1007 Sat Jan 2 10:22:42 2021 +++ src/distrib/sets/lists/tests/mi Sun Jan 10 11:24:42 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1007 2021/01/02 10:22:42 rillig Exp $ +# $NetBSD: mi,v 1.1008 2021/01/10 11:24:42 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5745,6 +5745,8 @@ ./usr/tests/usr.bin/xlint/lint1/d_bltinoffsetof.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_c99_anon_struct.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_c99_anon_union.c tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/d_c99_bool.c tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/d_c99_bool.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_c99_complex_num.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_c99_complex_split.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_c99_compound_literal_comma.c tests-usr.bin-tests compattestfile,atf Index: src/tests/usr.bin/xlint/lint1/Makefile diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.25 src/tests/usr.bin/xlint/lint1/Makefile:1.26 --- src/tests/usr.bin/xlint/lint1/Makefile:1.25 Sat Jan 2 10:22:42 2021 +++ src/tests/usr.bin/xlint/lint1/Makefile Sun Jan 10 11:24:42 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.25 2021/01/02 10:22:42 rillig Exp $ +# $NetBSD: Makefile,v 1.26 2021/01/10 11:24:42 rillig Exp $ NOMAN= # defined @@ -11,6 +11,8 @@ TESTS_SH= t_integration FILESDIR= ${TESTSDIR} FILES+= d_alignof.c FILES+= d_bltinoffsetof.c +FILES+= d_c99_bool.c +FILES+= d_c99_bool.exp FILES+= d_c99_anon_struct.c FILES+= d_c99_anon_union.c FILES+= d_c99_complex_num.c Index: src/tests/usr.bin/xlint/lint1/t_integration.sh diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.21 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.22 --- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.21 Sat Jan 9 14:33:53 2021 +++ src/tests/usr.bin/xlint/lint1/t_integration.sh Sun Jan 10 11:24:42 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_integration.sh,v 1.21 2021/01/09 14:33:53 rillig Exp $ +# $NetBSD: t_integration.sh,v 1.22 2021/01/10 11:24:42 rillig Exp $ # # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. # All rights reserved. @@ -65,6 +65,7 @@ test_case() test_case bltinoffsetof test_case c99_anon_struct test_case c99_anon_union +test_case c99_bool test_case c99_compound_literal_comma test_case c99_decls_after_stmt2 test_case c99_flex_array_packed Added files: Index: src/tests/usr.bin/xlint/lint1/d_c99_bool.c diff -u /dev/null src/tests/usr.bin/xlint/lint1/d_c99_bool.c:1.1 --- /dev/null Sun Jan 10 11:24:43 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool.c Sun Jan 10 11:24:42 2021 @@ -0,0 +1,49 @@ +/* $NetBSD: d_c99_bool.c,v 1.1 2021/01/10 11:24:42 rillig Exp $ */ +# 3 "d_bool.c" + +/* + * C99 6.3.1.2 says: "When any scalar value is converted to _Bool, the result + * is 0 if the value compares equal to 0; otherwise the result is 1." + * + * This is different from the other integer types, which get truncated or + * invoke undefined behavior. + */ + +/* Below, the wrong assertions produce warning 20. */ + +int int_0_converts_to_false[(_Bool)0 ? -1 : 1]; +int int_0_converts_to_true_[(_Bool)0 ? 1 : -1]; + +int int_1_converts_to_false[(_Bool)1 ? -1 : 1]; +int int_1_converts_to_true_[(_Bool)1 ? 1 : -1]; + +int int_2_converts_to_false[(_Bool)2 ? -1 : 1]; +int int_2_converts_to_true_[(_Bool)2 ? 1 : -1]; + +int int_256_converts_to_false[(_Bool)256 ? -1 : 1]; // FIXME +int int_256_converts_to_true_[(_Bool)256 ? 1 : -1]; // FIXME + +int null_pointer_converts_to_false[(_Bool)(void *)0 ? -1 : 1]; +int null_pointer_converts_to_true_[(_Bool)(void *)0 ? 1 : -1]; + +int nonnull_pointer_converts_to_false[(_Bool)"not null" ? -1 : 1]; // FIXME 133 +int nonnull_pointer_converts_to_true_[(_Bool)"not null" ? 1 : -1]; // FIXME 133 + +int
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jan 10 11:17:53 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: externs1.h func.c tree.c Log Message: lint: rename cvtcon to convert_constant No functional change. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.55 -r1.56 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.145 -r1.146 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/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.50 src/usr.bin/xlint/lint1/externs1.h:1.51 --- src/usr.bin/xlint/lint1/externs1.h:1.50 Sat Jan 9 19:13:17 2021 +++ src/usr.bin/xlint/lint1/externs1.h Sun Jan 10 11:17:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.50 2021/01/09 19:13:17 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.51 2021/01/10 11:17:53 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -207,7 +207,7 @@ extern tnode_t *cconv(tnode_t *); extern bool typeok(op_t, int, tnode_t *, tnode_t *); extern tnode_t *promote(op_t, int, tnode_t *); extern tnode_t *convert(op_t, int, type_t *, tnode_t *); -extern void cvtcon(op_t, int, type_t *, val_t *, val_t *); +extern void convert_constant(op_t, int, type_t *, val_t *, val_t *); extern tnode_t *build_sizeof(type_t *); extern tnode_t *build_offsetof(type_t *, sym_t *); extern tnode_t *build_alignof(type_t *); Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.55 src/usr.bin/xlint/lint1/func.c:1.56 --- src/usr.bin/xlint/lint1/func.c:1.55 Sun Jan 10 00:05:46 2021 +++ src/usr.bin/xlint/lint1/func.c Sun Jan 10 11:17:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.55 2021/01/10 00:05:46 rillig Exp $ */ +/* $NetBSD: func.c,v 1.56 2021/01/10 11:17:53 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.55 2021/01/10 00:05:46 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.56 2021/01/10 11:17:53 rillig Exp $"); #endif #include @@ -465,7 +465,7 @@ check_case_label(tnode_t *tn, cstk_t *ci */ v = constant(tn, 1); (void) memset(, 0, sizeof nv); - cvtcon(CASE, 0, ci->c_swtype, , v); + convert_constant(CASE, 0, ci->c_swtype, , v); free(v); /* look if we had this value already */ Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.145 src/usr.bin/xlint/lint1/tree.c:1.146 --- src/usr.bin/xlint/lint1/tree.c:1.145 Sun Jan 10 00:12:50 2021 +++ src/usr.bin/xlint/lint1/tree.c Sun Jan 10 11:17:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.145 2021/01/10 00:12:50 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.146 2021/01/10 11:17:53 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.145 2021/01/10 00:12:50 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.146 2021/01/10 11:17:53 rillig Exp $"); #endif #include @@ -1803,7 +1803,8 @@ convert(op_t op, int arg, type_t *tp, tn } else { ntn->tn_op = CON; ntn->tn_val = tgetblk(sizeof (val_t)); - cvtcon(op, arg, ntn->tn_type, ntn->tn_val, tn->tn_val); + convert_constant(op, arg, ntn->tn_type, ntn->tn_val, + tn->tn_val); } return ntn; @@ -2017,7 +2018,7 @@ check_pointer_conversion(op_t op, tnode_ * v old constant */ void -cvtcon(op_t op, int arg, type_t *tp, val_t *nv, val_t *v) +convert_constant(op_t op, int arg, type_t *tp, val_t *nv, val_t *v) { tspec_t ot, nt; ldbl_t max = 0.0, min = 0.0;