CVS commit: src/usr.sbin/services_mkdb
Module Name:src Committed By: christos Date: Mon Mar 22 03:28:55 UTC 2021 Modified Files: src/usr.sbin/services_mkdb: uniq.c Log Message: Avoid memory leak on empty lines (https://reviews.freebsd.org/D29370) To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/services_mkdb/uniq.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/services_mkdb/uniq.c diff -u src/usr.sbin/services_mkdb/uniq.c:1.6 src/usr.sbin/services_mkdb/uniq.c:1.7 --- src/usr.sbin/services_mkdb/uniq.c:1.6 Sat Jun 21 13:48:07 2014 +++ src/usr.sbin/services_mkdb/uniq.c Sun Mar 21 23:28:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: uniq.c,v 1.6 2014/06/21 17:48:07 christos Exp $ */ +/* $NetBSD: uniq.c,v 1.7 2021/03/22 03:28:55 christos Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: uniq.c,v 1.6 2014/06/21 17:48:07 christos Exp $"); +__RCSID("$NetBSD: uniq.c,v 1.7 2021/03/22 03:28:55 christos Exp $"); #include #include @@ -126,11 +126,12 @@ comp(const char *origline, char **compli for (p = (const unsigned char *)origline; l && *p && isspace(*p); p++, l--) continue; + if (*p == '\0' || l == 0) + return 0; + cline = emalloc(l + 1); (void)memcpy(cline, p, l); cline[l] = '\0'; - if (*cline == '\0') - return 0; complen = 0; hasalnum = 0; @@ -160,6 +161,11 @@ comp(const char *origline, char **compli --complen; } *q = '\0'; + if (!hasalnum) { + free(cline); + cline = NULL; + complen = 0; + } *compline = cline; *len = complen; return hasalnum;
CVS commit: [thorpej-cfargs] src/sys/arch/evbppc/conf
Module Name:src Committed By: thorpej Date: Mon Mar 22 03:06:01 UTC 2021 Modified Files: src/sys/arch/evbppc/conf [thorpej-cfargs]: files.pmppc Log Message: mainbus does not need to carry the "pcibus" interface attribute; PCI busses do not attach to mainbus, they attach to cpc@mainbus, and cpc already carries the "pcibus" interface attribute. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.7.28.1 src/sys/arch/evbppc/conf/files.pmppc 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/evbppc/conf/files.pmppc diff -u src/sys/arch/evbppc/conf/files.pmppc:1.7 src/sys/arch/evbppc/conf/files.pmppc:1.7.28.1 --- src/sys/arch/evbppc/conf/files.pmppc:1.7 Sat Feb 18 05:08:47 2017 +++ src/sys/arch/evbppc/conf/files.pmppc Mon Mar 22 03:06:01 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files.pmppc,v 1.7 2017/02/18 05:08:47 rin Exp $ +# $NetBSD: files.pmppc,v 1.7.28.1 2021/03/22 03:06:01 thorpej Exp $ # # maxpartitions 16 @@ -32,7 +32,7 @@ file dev/md_root.c memory_disk_hooks # System bus types # define mainbus { [addr=-1], [irq=-1] } -device mainbus: mainbus, pcibus +device mainbus: mainbus attach mainbus at root device cpu attach cpu at mainbus
CVS commit: src/sys/arch/powerpc/pic
Module Name:src Committed By: rin Date: Mon Mar 22 01:36:10 UTC 2021 Modified Files: src/sys/arch/powerpc/pic: intr.c picvar.h Log Message: Brush up previous, or make things more similar to x86: - Prevent pic_name from appearing vmstat(1) twice. - Restore "irq" in interrupt id fields of intrctl(8). For these purposes, - Add is_evname member to struct intr_source. - Bump size of is_source to INTRIDBUF, and rename it to is_intrid for clarity. Now, outputs from vmstat(1) and intrctl(8) are like: $ vmstat -ev ... openpic irq 39 3967 26 intr ... $ intrctl list interrupt id CPU0 device name(s) ... openpic irq 39 3967* wdc1 ... To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/arch/powerpc/pic/intr.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/powerpc/pic/picvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/powerpc/pic/intr.c diff -u src/sys/arch/powerpc/pic/intr.c:1.31 src/sys/arch/powerpc/pic/intr.c:1.32 --- src/sys/arch/powerpc/pic/intr.c:1.31 Sat Mar 6 07:24:24 2021 +++ src/sys/arch/powerpc/pic/intr.c Mon Mar 22 01:36:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.31 2021/03/06 07:24:24 rin Exp $ */ +/* $NetBSD: intr.c,v 1.32 2021/03/22 01:36:10 rin Exp $ */ /*- * Copyright (c) 2007 Michael Lorenz @@ -29,7 +29,7 @@ #define __INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.31 2021/03/06 07:24:24 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.32 2021/03/22 01:36:10 rin Exp $"); #ifdef _KERNEL_OPT #include "opt_interrupt.h" @@ -200,10 +200,12 @@ intr_establish_xname(int hwirq, int type break; } if (is->is_hand == NULL) { - snprintf(is->is_source, sizeof(is->is_source), "%s %d", + snprintf(is->is_intrid, sizeof(is->is_intrid), "%s irq %d", pic->pic_name, is->is_hwirq); + snprintf(is->is_evname, sizeof(is->is_evname), "irq %d", + is->is_hwirq); evcnt_attach_dynamic(>is_ev, EVCNT_TYPE_INTR, NULL, - pic->pic_name, is->is_source); + pic->pic_name, is->is_evname); } /* @@ -744,7 +746,7 @@ intr_get_source(const char *intrid) int irq; for (irq = 0, is = intrsources; irq < NVIRQ; irq++, is++) { - if (strcmp(intrid, is->is_source) == 0) + if (strcmp(intrid, is->is_intrid) == 0) return is; } return NULL; @@ -858,7 +860,7 @@ interrupt_construct_intrids(const kcpuse if (is->is_hand == NULL) continue; - strncpy(ids[i], is->is_source, sizeof(intrid_t)); + strncpy(ids[i], is->is_intrid, sizeof(intrid_t)); i++; } Index: src/sys/arch/powerpc/pic/picvar.h diff -u src/sys/arch/powerpc/pic/picvar.h:1.12 src/sys/arch/powerpc/pic/picvar.h:1.13 --- src/sys/arch/powerpc/pic/picvar.h:1.12 Thu Apr 16 23:29:52 2020 +++ src/sys/arch/powerpc/pic/picvar.h Mon Mar 22 01:36:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: picvar.h,v 1.12 2020/04/16 23:29:52 rin Exp $ */ +/* $NetBSD: picvar.h,v 1.13 2021/03/22 01:36:10 rin Exp $ */ /*- * Copyright (c) 2007 Michael Lorenz @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: picvar.h,v 1.12 2020/04/16 23:29:52 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: picvar.h,v 1.13 2021/03/22 01:36:10 rin Exp $"); #ifndef PIC_VAR_H #define PIC_VAR_H @@ -62,7 +62,8 @@ struct intr_source { struct intrhand *is_hand; struct pic_ops *is_pic; struct evcnt is_ev; - char is_source[16]; + char is_evname[16]; + char is_intrid[INTRIDBUF]; }; #define OPENPIC_MAX_ISUS 4
CVS commit: src/share/man/man5
Module Name:src Committed By: wiz Date: Mon Mar 22 00:09:06 UTC 2021 Modified Files: src/share/man/man5: ttyaction.5 Log Message: New sentence, new line. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/share/man/man5/ttyaction.5 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/man5/ttyaction.5 diff -u src/share/man/man5/ttyaction.5:1.10 src/share/man/man5/ttyaction.5:1.11 --- src/share/man/man5/ttyaction.5:1.10 Sun Mar 21 23:29:36 2021 +++ src/share/man/man5/ttyaction.5 Mon Mar 22 00:09:06 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: ttyaction.5,v 1.10 2021/03/21 23:29:36 mrg Exp $ +.\" $NetBSD: ttyaction.5,v 1.11 2021/03/22 00:09:06 wiz Exp $ .\" .\" Copyright (c) 1996 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -37,7 +37,8 @@ The .Nm ttyaction file specifies site-specific commands to run -when a login session begins and ends. The +when a login session begins and ends. +The .Nm ttyaction file contains a list of newline separated records, where each record has the following three fields: @@ -79,7 +80,8 @@ PATH=_PATH_STDPATH .Pp These variables may be used directly in the shell command part of the record for simple tasks such as changing the -ownership of related devices. For example: +ownership of related devices. +For example: .Bd -literal -offset indent console * chown ${USER}:tty /dev/mouse .Ed @@ -100,7 +102,7 @@ tty0 getty /somewhere/tty_clean ${TTY} .Sh HISTORY Support for the .Pa /etc/ttyaction -file first appeared in +file first appeared in .Nx 1.3 . The ideas for the .Pa /etc/ttyaction
CVS commit: src/sys/arch/powerpc/oea
Module Name:src Committed By: rin Date: Sun Mar 21 23:41:52 UTC 2021 Modified Files: src/sys/arch/powerpc/oea: cpu_subr.c Log Message: Fix copy-paste. To generate a diff of this commit: cvs rdiff -u -r1.107 -r1.108 src/sys/arch/powerpc/oea/cpu_subr.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/powerpc/oea/cpu_subr.c diff -u src/sys/arch/powerpc/oea/cpu_subr.c:1.107 src/sys/arch/powerpc/oea/cpu_subr.c:1.108 --- src/sys/arch/powerpc/oea/cpu_subr.c:1.107 Fri Feb 26 21:15:20 2021 +++ src/sys/arch/powerpc/oea/cpu_subr.c Sun Mar 21 23:41:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_subr.c,v 1.107 2021/02/26 21:15:20 thorpej Exp $ */ +/* $NetBSD: cpu_subr.c,v 1.108 2021/03/21 23:41:52 rin Exp $ */ /*- * Copyright (c) 2001 Matt Thomas. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.107 2021/02/26 21:15:20 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.108 2021/03/21 23:41:52 rin Exp $"); #include "sysmon_envsys.h" @@ -856,7 +856,7 @@ cpu_setup(device_t self, struct cpu_info evcnt_attach_dynamic(>ci_ev_ali, EVCNT_TYPE_TRAP, >ci_ev_traps, xname, "user alignment traps"); evcnt_attach_dynamic(>ci_ev_ali_fatal, EVCNT_TYPE_TRAP, - >ci_ev_ali, xname, "user alignment traps"); + >ci_ev_ali, xname, "user alignment failures"); evcnt_attach_dynamic(>ci_ev_umchk, EVCNT_TYPE_TRAP, >ci_ev_umchk, xname, "user MCHK failures"); evcnt_attach_dynamic(>ci_ev_vec, EVCNT_TYPE_TRAP,
CVS commit: src
Module Name:src Committed By: mrg Date: Sun Mar 21 23:29:36 UTC 2021 Modified Files: src/lib/libutil: ttyaction.3 src/share/man/man5: ttyaction.5 Log Message: note that ttyaction.[35] first appeared in netbsd 1.3. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/lib/libutil/ttyaction.3 cvs rdiff -u -r1.9 -r1.10 src/share/man/man5/ttyaction.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libutil/ttyaction.3 diff -u src/lib/libutil/ttyaction.3:1.15 src/lib/libutil/ttyaction.3:1.16 --- src/lib/libutil/ttyaction.3:1.15 Tue May 4 06:41:27 2010 +++ src/lib/libutil/ttyaction.3 Sun Mar 21 23:29:36 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: ttyaction.3,v 1.15 2010/05/04 06:41:27 jruoho Exp $ +.\" $NetBSD: ttyaction.3,v 1.16 2021/03/21 23:29:36 mrg Exp $ .\" .\" Copyright (c) 1996 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -85,6 +85,11 @@ or zero if no matching commands were fou .El .Sh SEE ALSO .Xr ttyaction 5 +.Sh HISTORY +The +.Fn ttyaction +function appeared in +.Nx 1.3 . .Sh AUTHORS .An Gordon W. Ross .Aq g...@netbsd.org , Index: src/share/man/man5/ttyaction.5 diff -u src/share/man/man5/ttyaction.5:1.9 src/share/man/man5/ttyaction.5:1.10 --- src/share/man/man5/ttyaction.5:1.9 Fri Feb 3 07:42:43 2017 +++ src/share/man/man5/ttyaction.5 Sun Mar 21 23:29:36 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: ttyaction.5,v 1.9 2017/02/03 07:42:43 abhinav Exp $ +.\" $NetBSD: ttyaction.5,v 1.10 2021/03/21 23:29:36 mrg Exp $ .\" .\" Copyright (c) 1996 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -98,6 +98,10 @@ tty0 getty /somewhere/tty_clean ${TTY} .Xr fnmatch 3 , .Xr ttyaction 3 .Sh HISTORY +Support for the +.Pa /etc/ttyaction +file first appeared in +.Nx 1.3 . The ideas for the .Pa /etc/ttyaction file were inspired by the
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Mar 21 23:03:33 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: fix typos in documentation of ModChain To generate a diff of this commit: cvs rdiff -u -r1.892 -r1.893 src/usr.bin/make/var.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/var.c diff -u src/usr.bin/make/var.c:1.892 src/usr.bin/make/var.c:1.893 --- src/usr.bin/make/var.c:1.892 Tue Mar 16 16:21:27 2021 +++ src/usr.bin/make/var.c Sun Mar 21 23:03:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.892 2021/03/16 16:21:27 rillig Exp $ */ +/* $NetBSD: var.c,v 1.893 2021/03/21 23:03:33 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.892 2021/03/16 16:21:27 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.893 2021/03/21 23:03:33 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -2072,8 +2072,8 @@ typedef struct Expr { * Chain 1 starts with the single modifier ':M*'. * Chain 2 starts with all modifiers from ${IND1}. * Chain 2 ends at the ':' between ${IND1} and ${IND2}. - * Chain 3 starts with all modifiers from ${IND1}. - * Chain 2 ends at the ':' after ${IND2}. + * Chain 3 starts with all modifiers from ${IND2}. + * Chain 3 ends at the ':' after ${IND2}. * Chain 1 continues with the the 2 modifiers ':O' and ':u'. * Chain 1 ends at the final '}' of the expression. *
CVS commit: src/external/mpl/bind/bin/nslookup
Module Name:src Committed By: wiz Date: Sun Mar 21 21:26:00 UTC 2021 Modified Files: src/external/mpl/bind/bin/nslookup: nslookup.8 Log Message: Use standard section names, sort, use more macros. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/mpl/bind/bin/nslookup/nslookup.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/mpl/bind/bin/nslookup/nslookup.8 diff -u src/external/mpl/bind/bin/nslookup/nslookup.8:1.3 src/external/mpl/bind/bin/nslookup/nslookup.8:1.4 --- src/external/mpl/bind/bin/nslookup/nslookup.8:1.3 Sun Mar 21 16:21:35 2021 +++ src/external/mpl/bind/bin/nslookup/nslookup.8 Sun Mar 21 21:26:00 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: nslookup.8,v 1.3 2021/03/21 16:21:35 christos Exp $ +.\" $NetBSD: nslookup.8,v 1.4 2021/03/21 21:26:00 wiz Exp $ .\" .\" .\" ++Copyright++ 1985, 1989 @@ -114,7 +114,7 @@ The command line length must be less tha To treat a built-in command as a host name, precede it with an escape character .Pq Sq \e . -.Em N.B.: An unrecognized command will be interpreted as a host name. +.Em N.B.: \ unrecognized command will be interpreted as a host name. .Bl -tag -width "lserver" .It Ar host Op Ar server Look up information for @@ -445,7 +445,7 @@ abbreviation = .Oo Ic no Oc Ns Ic ig ) .It Oo Ic no Oc Ns Ic fail This keyword tries the next nameserver if a nameserver responds -with +with .Dv SERVFAIL or a referral (nofail), or terminates the query (fail) on such a response. @@ -453,24 +453,17 @@ or a referral (nofail), or terminates th The default is nofail. .El .El -.Sh RETURN VALUES -.Nm -returns with an exit status of -.Dv 1 -if any query failed, and -.Dv 0 -otherwise. .Sh IDN SUPPORT -If +If .Nm has been built with IDN (internationalized domain name) support, it can accept and display non-ASCII domain names. -.Nm +.Nm appropriately converts character encoding of a domain name before sending a request to a DNS server or displaying a reply from the server. To turn off IDN support, define the IDN_DISABLE environment variable. IDN support is disabled if the variable is set when -.Nm +.Nm runs, or when the standard output is not a tty. .Sh ENVIRONMENT .Bl -tag -width "HOSTALIASES" -compact @@ -486,6 +479,13 @@ turns off IDN support .It Pa /etc/resolv.conf initial domain name and name server addresses .El +.Sh EXIT STATUS +.Nm +returns with an exit status of +.Dv 1 +if any query failed, and +.Dv 0 +otherwise. .Sh DIAGNOSTICS If the lookup request was not successful, an error message is printed. Possible errors are: @@ -545,4 +545,4 @@ It may indicate an error in .%D Nov 1, 1987 .Re .Sh AUTHORS -Andrew Cherenson +.An Andrew Cherenson
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 20:30:19 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: err.c Log Message: lint: remove redundant prototypes No functional change. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/usr.bin/xlint/lint1/err.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/err.c diff -u src/usr.bin/xlint/lint1/err.c:1.89 src/usr.bin/xlint/lint1/err.c:1.90 --- src/usr.bin/xlint/lint1/err.c:1.89 Sat Mar 20 14:17:56 2021 +++ src/usr.bin/xlint/lint1/err.c Sun Mar 21 20:30:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: err.c,v 1.89 2021/03/20 14:17:56 rillig Exp $ */ +/* $NetBSD: err.c,v 1.90 2021/03/21 20:30:19 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: err.c,v 1.89 2021/03/20 14:17:56 rillig Exp $"); +__RCSID("$NetBSD: err.c,v 1.90 2021/03/21 20:30:19 rillig Exp $"); #endif #include @@ -53,11 +53,6 @@ int nerr; int sytxerr; -static const char *lbasename(const char *); -static void verror(int, va_list); -static void vwarning(int, va_list); - - const char *msgs[] = { "empty declaration", /* 0 */ "old style declaration; add 'int'", /* 1 */
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 20:18:45 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c Log Message: lint: adjust type in documentation of add_array No functional change. To generate a diff of this commit: cvs rdiff -u -r1.156 -r1.157 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.156 src/usr.bin/xlint/lint1/decl.c:1.157 --- src/usr.bin/xlint/lint1/decl.c:1.156 Sun Mar 21 10:30:28 2021 +++ src/usr.bin/xlint/lint1/decl.c Sun Mar 21 20:18:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.156 2021/03/21 10:30:28 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.157 2021/03/21 20:18:45 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.156 2021/03/21 10:30:28 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.157 2021/03/21 20:18:45 rillig Exp $"); #endif #include @@ -1345,7 +1345,7 @@ add_pointer(sym_t *decl, pqinf_t *pi) } /* - * If a dimension was specified, dim is 1, otherwise 0 + * If a dimension was specified, dim is true, otherwise false * n is the specified dimension */ sym_t *
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 20:08:21 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_193.c msg_193.exp Log Message: tests/lint: test reachability of goto and named labels To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/xlint/lint1/msg_193.c \ src/tests/usr.bin/xlint/lint1/msg_193.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/msg_193.c diff -u src/tests/usr.bin/xlint/lint1/msg_193.c:1.10 src/tests/usr.bin/xlint/lint1/msg_193.c:1.11 --- src/tests/usr.bin/xlint/lint1/msg_193.c:1.10 Sun Mar 21 19:39:01 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 20:08:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_193.c,v 1.10 2021/03/21 19:39:01 rillig Exp $ */ +/* $NetBSD: msg_193.c,v 1.11 2021/03/21 20:08:21 rillig Exp $ */ # 3 "msg_193.c" // Test for message: statement not reached [193] @@ -555,8 +555,64 @@ test_if_maybe(void) reachable(); } -/* TODO: switch */ +/* + * To compute the reachability graph of this little monster, lint would have + * to keep all statements and their relations from the whole function in + * memory. It doesn't do that. Therefore it does not warn about any + * unreachable statements in this function. + */ +void +test_goto_numbers_alphabetically(void) +{ + goto one; +eight: + goto nine; +five: + return; +four: + goto five; +nine: + goto ten; +one: + goto two; +seven: + goto eight; +six:/* expect: warning: label six unused */ + goto seven; +ten: + return; +three: + goto four; +two: + goto three; +} -/* TODO: goto */ +void +test_while_goto(void) +{ + while (1) { + goto out; + break; /* lint only warns with the -b option */ + } + unreachable(); /* expect: 193 */ +out: + reachable(); +} + +void +test_unreachable_label(void) +{ + if (0) + goto unreachable; /* expect: 193 */ + goto reachable; + + /* named_label assumes that any label is reachable. */ +unreachable: + unreachable(); +reachable: + reachable(); +} + +/* TODO: switch */ /* TODO: system-dependent constant expression (see tn_system_dependent) */ Index: src/tests/usr.bin/xlint/lint1/msg_193.exp diff -u src/tests/usr.bin/xlint/lint1/msg_193.exp:1.10 src/tests/usr.bin/xlint/lint1/msg_193.exp:1.11 --- src/tests/usr.bin/xlint/lint1/msg_193.exp:1.10 Sun Mar 21 19:39:01 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.exp Sun Mar 21 20:08:21 2021 @@ -82,3 +82,6 @@ msg_193.c(515): warning: statement not r msg_193.c(518): warning: statement not reached [193] msg_193.c(532): warning: statement not reached [193] msg_193.c(540): warning: statement not reached [193] +msg_193.c(580): warning: label six unused in function test_goto_numbers_alphabetically [232] +msg_193.c(597): warning: statement not reached [193] +msg_193.c(606): warning: statement not reached [193]
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 19:39:01 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_193.c msg_193.exp Log Message: tests/lint: add test for reachability of non-constant conditions To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/msg_193.c \ src/tests/usr.bin/xlint/lint1/msg_193.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/msg_193.c diff -u src/tests/usr.bin/xlint/lint1/msg_193.c:1.9 src/tests/usr.bin/xlint/lint1/msg_193.c:1.10 --- src/tests/usr.bin/xlint/lint1/msg_193.c:1.9 Sun Mar 21 19:18:37 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 19:39:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_193.c,v 1.9 2021/03/21 19:18:37 rillig Exp $ */ +/* $NetBSD: msg_193.c,v 1.10 2021/03/21 19:39:01 rillig Exp $ */ # 3 "msg_193.c" // Test for message: statement not reached [193] @@ -22,10 +22,10 @@ * system-dependent constant expression */ -extern void -reachable(void); -extern void -unreachable(void); +extern void reachable(void); +extern void unreachable(void); +extern _Bool maybe(void); + void test_statement(void) @@ -524,6 +524,37 @@ test_if_nested(void) reachable(); } +void +test_if_maybe(void) +{ + if (maybe()) { + if (0) + unreachable(); /* expect: 193 */ + else + reachable(); + reachable(); + } + reachable(); + + if (0) { + if (maybe()) /* expect: 193 */ + unreachable(); + else + unreachable(); + unreachable(); + } + reachable(); + + if (1) { + if (maybe()) + reachable(); + else + reachable(); + reachable(); + } + reachable(); +} + /* TODO: switch */ /* TODO: goto */ Index: src/tests/usr.bin/xlint/lint1/msg_193.exp diff -u src/tests/usr.bin/xlint/lint1/msg_193.exp:1.9 src/tests/usr.bin/xlint/lint1/msg_193.exp:1.10 --- src/tests/usr.bin/xlint/lint1/msg_193.exp:1.9 Sun Mar 21 19:18:37 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.exp Sun Mar 21 19:39:01 2021 @@ -80,3 +80,5 @@ msg_193.c(500): warning: statement not r msg_193.c(503): warning: statement not reached [193] msg_193.c(515): warning: statement not reached [193] msg_193.c(518): warning: statement not reached [193] +msg_193.c(532): warning: statement not reached [193] +msg_193.c(540): warning: statement not reached [193]
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 19:18:37 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_193.c msg_193.exp Log Message: tests/lint: add test for reachability of nested 'if' statements To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_193.c \ src/tests/usr.bin/xlint/lint1/msg_193.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/msg_193.c diff -u src/tests/usr.bin/xlint/lint1/msg_193.c:1.8 src/tests/usr.bin/xlint/lint1/msg_193.c:1.9 --- src/tests/usr.bin/xlint/lint1/msg_193.c:1.8 Sun Mar 21 19:14:40 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 19:18:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_193.c,v 1.8 2021/03/21 19:14:40 rillig Exp $ */ +/* $NetBSD: msg_193.c,v 1.9 2021/03/21 19:18:37 rillig Exp $ */ # 3 "msg_193.c" // Test for message: statement not reached [193] @@ -490,6 +490,40 @@ test_do_while_if_return(void) unreachable(); /* expect: 193 */ } +void +test_if_nested(void) +{ + if (0) { + if (1) /* expect: 193 */ + unreachable(); + else + unreachable(); /* expect: 193 *//* XXX: redundant */ + + if (0) + unreachable(); /* expect: 193 *//* XXX: redundant */ + else + unreachable(); + + unreachable(); + } + reachable(); + + if (1) { + if (1) + reachable(); + else + unreachable(); /* expect: 193 */ + + if (0) + unreachable(); /* expect: 193 */ + else + reachable(); + + reachable(); + } + reachable(); +} + /* TODO: switch */ /* TODO: goto */ Index: src/tests/usr.bin/xlint/lint1/msg_193.exp diff -u src/tests/usr.bin/xlint/lint1/msg_193.exp:1.8 src/tests/usr.bin/xlint/lint1/msg_193.exp:1.9 --- src/tests/usr.bin/xlint/lint1/msg_193.exp:1.8 Sun Mar 21 19:14:40 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.exp Sun Mar 21 19:18:37 2021 @@ -75,3 +75,8 @@ msg_193.c(481): warning: statement not r msg_193.c(486): warning: statement not reached [193] msg_193.c(488): warning: statement not reached [193] msg_193.c(490): warning: statement not reached [193] +msg_193.c(497): warning: statement not reached [193] +msg_193.c(500): warning: statement not reached [193] +msg_193.c(503): warning: statement not reached [193] +msg_193.c(515): warning: statement not reached [193] +msg_193.c(518): warning: statement not reached [193]
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Mar 21 19:14:41 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_193.c msg_193.exp src/usr.bin/xlint/lint1: func.c Log Message: lint: warn about unreachable statement after joining the 'if' branches To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_193.c \ src/tests/usr.bin/xlint/lint1/msg_193.exp cvs rdiff -u -r1.94 -r1.95 src/usr.bin/xlint/lint1/func.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_193.c diff -u src/tests/usr.bin/xlint/lint1/msg_193.c:1.7 src/tests/usr.bin/xlint/lint1/msg_193.c:1.8 --- src/tests/usr.bin/xlint/lint1/msg_193.c:1.7 Sun Mar 21 15:44:57 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 19:14:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_193.c,v 1.7 2021/03/21 15:44:57 rillig Exp $ */ +/* $NetBSD: msg_193.c,v 1.8 2021/03/21 19:14:40 rillig Exp $ */ # 3 "msg_193.c" // Test for message: statement not reached [193] @@ -203,7 +203,7 @@ test_for_if_break(void) break; unreachable(); /* expect: 193 */ } - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ } reachable(); } @@ -234,7 +234,7 @@ test_for_if_continue(void) continue; unreachable(); /* expect: 193 */ } - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ } unreachable(); /* expect: 193 */ } @@ -265,7 +265,7 @@ test_for_if_return(void) return; unreachable(); /* expect: 193 */ } - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ } unreachable(); /* expect: 193 */ } @@ -312,7 +312,7 @@ test_while_if_break(void) break; unreachable(); /* expect: 193 */ } - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ } reachable(); } @@ -343,7 +343,7 @@ test_while_if_continue(void) continue; unreachable(); /* expect: 193 */ } - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ } unreachable(); /* expect: 193 */ } @@ -374,7 +374,7 @@ test_while_if_return(void) return; unreachable(); /* expect: 193 */ } - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ } unreachable(); /* expect: 193 */ } @@ -423,7 +423,7 @@ test_do_while_if_break(void) break; unreachable(); /* expect: 193 */ } - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ } while (1); reachable(); } @@ -454,7 +454,7 @@ test_do_while_if_continue(void) continue; unreachable(); /* expect: 193 */ } - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ } while (1); unreachable(); /* expect: 193 */ } @@ -485,7 +485,7 @@ test_do_while_if_return(void) return; unreachable(); /* expect: 193 */ } - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ } while (1); unreachable(); /* expect: 193 */ } Index: src/tests/usr.bin/xlint/lint1/msg_193.exp diff -u src/tests/usr.bin/xlint/lint1/msg_193.exp:1.7 src/tests/usr.bin/xlint/lint1/msg_193.exp:1.8 --- src/tests/usr.bin/xlint/lint1/msg_193.exp:1.7 Sun Mar 21 15:44:57 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.exp Sun Mar 21 19:14:40 2021 @@ -19,17 +19,20 @@ msg_193.c(186): warning: statement not r msg_193.c(197): warning: statement not reached [193] msg_193.c(199): warning: statement not reached [193] msg_193.c(204): warning: statement not reached [193] +msg_193.c(206): warning: statement not reached [193] msg_193.c(217): warning: statement not reached [193] msg_193.c(219): warning: statement not reached [193] msg_193.c(228): warning: statement not reached [193] msg_193.c(230): warning: statement not reached [193] msg_193.c(235): warning: statement not reached [193] +msg_193.c(237): warning: statement not reached [193] msg_193.c(239): warning: statement not reached [193] msg_193.c(248): warning: statement not reached [193] msg_193.c(250): warning: statement not reached [193] msg_193.c(259): warning: statement not reached [193] msg_193.c(261): warning: statement not reached [193] msg_193.c(266): warning: statement not reached [193] +msg_193.c(268): warning: statement not reached [193] msg_193.c(270): warning: statement not reached [193] msg_193.c(278): warning: statement not reached [193] msg_193.c(285): warning: statement not reached [193] @@ -37,32 +40,38 @@ msg_193.c(295): warning: statement not r msg_193.c(306): warning: statement not reached [193] msg_193.c(308): warning: statement not reached [193] msg_193.c(313): warning: statement not reached [193] +msg_193.c(315): warning: statement not reached [193] msg_193.c(326): warning: statement not reached [193] msg_193.c(328): warning: statement not reached [193] msg_193.c(337): warning: statement not reached
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 19:08:10 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: externs1.h func.c tree.c Log Message: lint: invert 'rchflag', call it warn_about_unreachable instead No functional change. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.93 -r1.94 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.244 -r1.245 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.81 src/usr.bin/xlint/lint1/externs1.h:1.82 --- src/usr.bin/xlint/lint1/externs1.h:1.81 Sun Mar 21 14:49:21 2021 +++ src/usr.bin/xlint/lint1/externs1.h Sun Mar 21 19:08:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.81 2021/03/21 14:49:21 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.82 2021/03/21 19:08:10 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -235,7 +235,7 @@ extern void debug_node(const tnode_t *, */ extern sym_t *funcsym; extern bool reached; -extern bool rchflg; +extern bool warn_about_unreachable; extern bool seen_fallthrough; extern int nargusg; extern pos_t argsused_pos; Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.93 src/usr.bin/xlint/lint1/func.c:1.94 --- src/usr.bin/xlint/lint1/func.c:1.93 Sun Mar 21 18:58:34 2021 +++ src/usr.bin/xlint/lint1/func.c Sun Mar 21 19:08:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.93 2021/03/21 18:58:34 rillig Exp $ */ +/* $NetBSD: func.c,v 1.94 2021/03/21 19:08:10 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.93 2021/03/21 18:58:34 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.94 2021/03/21 19:08:10 rillig Exp $"); #endif #include @@ -56,10 +56,10 @@ sym_t *funcsym; bool reached = true; /* - * Is set as long as NOTREACHED is in effect. - * Is reset everywhere where reached can become 0. + * Is true by default, can be cleared by NOTREACHED. + * Is reset to true whenever 'reached' changes. */ -bool rchflg; +bool warn_about_unreachable; /* * In conjunction with 'reached', controls printing of "fallthrough on ..." @@ -191,7 +191,7 @@ static void set_reached(bool new_reached) { reached = new_reached; - rchflg = false; + warn_about_unreachable = true; } /* @@ -200,13 +200,14 @@ set_reached(bool new_reached) void check_statement_reachable(void) { - if (!reached && !rchflg) { + if (!reached && warn_about_unreachable) { /* statement not reached */ warning(193); /* * FIXME: Setting 'reached = true' is wrong since the * statement doesn't magically become reachable just by - * issuing a warning. This must be 'rchflg = true' instead. + * issuing a warning. This must be + * 'warn_about_unreachable = false' instead. */ reached = true; /* only to suppress further warnings */ } @@ -930,7 +931,7 @@ for2(void) csrc_pos = cstmt->c_cfpos; /* simply "statement not reached" would be confusing */ - if (!reached && !rchflg) { + if (!reached && warn_about_unreachable) { /* end-of-loop code not reached */ warning(223); set_reached(true); @@ -1271,7 +1272,7 @@ not_reached(int n) { set_reached(false); - rchflg = true; + warn_about_unreachable = false; } /* ARGSUSED */ Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.244 src/usr.bin/xlint/lint1/tree.c:1.245 --- src/usr.bin/xlint/lint1/tree.c:1.244 Sun Mar 21 18:58:34 2021 +++ src/usr.bin/xlint/lint1/tree.c Sun Mar 21 19:08:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.244 2021/03/21 18:58:34 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.245 2021/03/21 19:08:10 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.244 2021/03/21 18:58:34 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.245 2021/03/21 19:08:10 rillig Exp $"); #endif #include @@ -3927,8 +3927,8 @@ check_expr_misc(const tnode_t *tn, bool switch (op) { case ADDR: - /* XXX: Taking rchflg into account here feels wrong. */ - if (ln->tn_op == NAME && (reached || rchflg)) { + /* XXX: Taking warn_about_unreachable into account here feels wrong. */ + if (ln->tn_op == NAME && (reached || !warn_about_unreachable)) { if (!szof) mark_as_set(ln->tn_sym); mark_as_used(ln->tn_sym, fcall, szof); @@ -3959,8 +3959,8 @@ check_expr_misc(const tnode_t *tn, bool case SHRASS: case REAL: case IMAG: - /* XXX: Taking rchflg into account here feels wrong. */ - if (ln->tn_op == NAME && (reached || rchflg)) { + /* XXX: Taking warn_about_unreachable into account here feels wrong. */ + if (ln->tn_op == NAME && (reached || !warn_about_unreachable)) { sc = ln->tn_sym->s_scl; /*
CVS commit: [thorpej-cfargs] src/sys
Module Name:src Committed By: thorpej Date: Sun Mar 21 19:06:19 UTC 2021 Modified Files: src/sys/arch/x86/pci [thorpej-cfargs]: amdnb_misc.c amdsmn.c src/sys/dev/audio [thorpej-cfargs]: audio.c src/sys/dev/i2c [thorpej-cfargs]: i2c.c src/sys/dev/isa [thorpej-cfargs]: pcppi.c Log Message: In "rescan" routines, always pass locators and the interface attribute straight through to config_search(). Also, for devices that carry only one interface attribute, no need to do an ifattr_match(), because rescan_with_cfdata() will have already validated that the parent is eligible, which includes an interface attribute check. To generate a diff of this commit: cvs rdiff -u -r1.3.14.2 -r1.3.14.3 src/sys/arch/x86/pci/amdnb_misc.c cvs rdiff -u -r1.10.4.1 -r1.10.4.2 src/sys/arch/x86/pci/amdsmn.c cvs rdiff -u -r1.91.2.1 -r1.91.2.2 src/sys/dev/audio/audio.c cvs rdiff -u -r1.77.2.1 -r1.77.2.2 src/sys/dev/i2c/i2c.c cvs rdiff -u -r1.45.22.1 -r1.45.22.2 src/sys/dev/isa/pcppi.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/x86/pci/amdnb_misc.c diff -u src/sys/arch/x86/pci/amdnb_misc.c:1.3.14.2 src/sys/arch/x86/pci/amdnb_misc.c:1.3.14.3 --- src/sys/arch/x86/pci/amdnb_misc.c:1.3.14.2 Sun Mar 21 17:35:48 2021 +++ src/sys/arch/x86/pci/amdnb_misc.c Sun Mar 21 19:06:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: amdnb_misc.c,v 1.3.14.2 2021/03/21 17:35:48 thorpej Exp $ */ +/* $NetBSD: amdnb_misc.c,v 1.3.14.3 2021/03/21 19:06:19 thorpej Exp $ */ /* * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: amdnb_misc.c,v 1.3.14.2 2021/03/21 17:35:48 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: amdnb_misc.c,v 1.3.14.3 2021/03/21 19:06:19 thorpej Exp $"); #include #include @@ -158,9 +158,6 @@ amdnb_misc_rescan(device_t self, const c { struct amdnb_misc_softc *sc = device_private(self); - if (!ifattr_match(ifattr, "amdnb_miscbus")) - return 0; - config_search(self, >sc_pa, CFARG_SUBMATCH, amdnb_misc_search, CFARG_IATTR, ifattr, Index: src/sys/arch/x86/pci/amdsmn.c diff -u src/sys/arch/x86/pci/amdsmn.c:1.10.4.1 src/sys/arch/x86/pci/amdsmn.c:1.10.4.2 --- src/sys/arch/x86/pci/amdsmn.c:1.10.4.1 Sat Mar 20 19:33:39 2021 +++ src/sys/arch/x86/pci/amdsmn.c Sun Mar 21 19:06:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: amdsmn.c,v 1.10.4.1 2021/03/20 19:33:39 thorpej Exp $ */ +/* $NetBSD: amdsmn.c,v 1.10.4.2 2021/03/21 19:06:19 thorpej Exp $ */ /*- * Copyright (c) 2017, 2019 Conrad Meyer @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.10.4.1 2021/03/20 19:33:39 thorpej Exp $ "); +__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.10.4.2 2021/03/21 19:06:19 thorpej Exp $ "); /* * Driver for the AMD Family 15h (model 60+) and 17h CPU @@ -153,13 +153,14 @@ amdsmn_attach(device_t parent, device_t } static int -amdsmn_rescan(device_t self, const char *ifattr, const int *flags) +amdsmn_rescan(device_t self, const char *ifattr, const int *locators) { struct amdsmn_softc *sc = device_private(self); config_search(self, >pa, CFARG_SUBMATCH, amdsmn_misc_search, CFARG_IATTR, ifattr, + CFARG_LOCATORS, locators, CFARG_EOL); return 0; Index: src/sys/dev/audio/audio.c diff -u src/sys/dev/audio/audio.c:1.91.2.1 src/sys/dev/audio/audio.c:1.91.2.2 --- src/sys/dev/audio/audio.c:1.91.2.1 Sat Mar 20 19:33:40 2021 +++ src/sys/dev/audio/audio.c Sun Mar 21 19:06:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: audio.c,v 1.91.2.1 2021/03/20 19:33:40 thorpej Exp $ */ +/* $NetBSD: audio.c,v 1.91.2.2 2021/03/21 19:06:19 thorpej Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -138,7 +138,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.91.2.1 2021/03/20 19:33:40 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.91.2.2 2021/03/21 19:06:19 thorpej Exp $"); #ifdef _KERNEL_OPT #include "audio.h" @@ -1410,16 +1410,14 @@ audiosearch(device_t parent, cfdata_t cf } static int -audiorescan(device_t self, const char *ifattr, const int *flags) +audiorescan(device_t self, const char *ifattr, const int *locators) { struct audio_softc *sc = device_private(self); - if (!ifattr_match(ifattr, "audio")) - return 0; - config_search(sc->sc_dev, NULL, CFARG_SUBMATCH, audiosearch, - CFARG_IATTR, "audio", + CFARG_IATTR, ifattr, + CFARG_LOCATORS, locators, CFARG_EOL); return 0; Index: src/sys/dev/i2c/i2c.c diff -u src/sys/dev/i2c/i2c.c:1.77.2.1 src/sys/dev/i2c/i2c.c:1.77.2.2 --- src/sys/dev/i2c/i2c.c:1.77.2.1 Sat Mar 20 19:33:40 2021 +++ src/sys/dev/i2c/i2c.c Sun Mar 21 19:06:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: i2c.c,v 1.77.2.1 2021/03/20 19:33:40 thorpej Exp $ */ +/* $NetBSD: i2c.c,v 1.77.2.2 2021/03/21 19:06:19 thorpej Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ #endif
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 18:58:34 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: func.c tree.c Log Message: lint: reduce number of places where 'reached' is set When determining the reachability of a statement, the idea was that whenever 'reached' was set to false, 'rchflg' (the abbreviation for "do not warn about unreachable statements") would be reset as well. In some (trivial) cases, this was done, but many more interesting cases simply forgot to set this second variable. To prevent this in the future, encapsulate this in a simple helper function. Now even if a statement is reachable, 'rchflg' gets reset. This does not hurt since as long as the current statement is reachable, the value of 'rchflg' does not matter. No functional change. There would be quite a big functional change though if check_statement_reachable were to reset 'rchflg' instead of 'reached', as the comment already suggests. In that case, with the current code, many legitimate warnings about unreachable statements would be skipped, especially those involving 'if' statements, since these didn't reset 'rchflg' properly before. To generate a diff of this commit: cvs rdiff -u -r1.92 -r1.93 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.243 -r1.244 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/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.92 src/usr.bin/xlint/lint1/func.c:1.93 --- src/usr.bin/xlint/lint1/func.c:1.92 Sun Mar 21 15:44:57 2021 +++ src/usr.bin/xlint/lint1/func.c Sun Mar 21 18:58:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.92 2021/03/21 15:44:57 rillig Exp $ */ +/* $NetBSD: func.c,v 1.93 2021/03/21 18:58:34 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.92 2021/03/21 15:44:57 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.93 2021/03/21 18:58:34 rillig Exp $"); #endif #include @@ -187,6 +187,13 @@ popctrl(int env) free(ci); } +static void +set_reached(bool new_reached) +{ + reached = new_reached; + rchflg = false; +} + /* * Prints a warning if a statement cannot be reached. */ @@ -196,6 +203,11 @@ check_statement_reachable(void) if (!reached && !rchflg) { /* statement not reached */ warning(193); + /* + * FIXME: Setting 'reached = true' is wrong since the + * statement doesn't magically become reachable just by + * issuing a warning. This must be 'rchflg = true' instead. + */ reached = true; /* only to suppress further warnings */ } } @@ -334,7 +346,7 @@ funcdef(sym_t *fsym) if (dcs->d_notyp) fsym->s_return_type_implicit_int = true; - reached = true; + set_reached(true); } static void @@ -410,7 +422,7 @@ funcend(void) rmsyms(dcs->d_func_proto_syms); /* must be set on level 0 */ - reached = true; + set_reached(true); } void @@ -424,7 +436,7 @@ named_label(sym_t *sym) mark_as_set(sym); } - reached = true; + set_reached(true); } static void @@ -536,7 +548,7 @@ case_label(tnode_t *tn) tfreeblk(); - reached = true; + set_reached(true); } void @@ -563,7 +575,7 @@ default_label(void) ci->c_default = true; } - reached = true; + set_reached(true); } static tnode_t * @@ -607,7 +619,9 @@ if1(tnode_t *tn) pushctrl(T_IF); if (tn != NULL && tn->tn_op == CON && !tn->tn_system_dependent) { - reached = constant_is_nonzero(tn); + /* XXX: what if inside 'if (0)'? */ + set_reached(constant_is_nonzero(tn)); + /* XXX: what about always_else? */ cstmt->c_always_then = reached; } } @@ -621,7 +635,8 @@ if2(void) { cstmt->c_reached_end_of_then = reached; - reached = !cstmt->c_always_then; + /* XXX: what if inside 'if (0)'? */ + set_reached(!cstmt->c_always_then); } /* @@ -632,11 +647,11 @@ void if3(bool els) { if (cstmt->c_reached_end_of_then) - reached = true; + set_reached(true); else if (cstmt->c_always_then) - reached = false; + set_reached(false); else if (!els) - reached = true; + set_reached(true); popctrl(T_IF); } @@ -689,7 +704,7 @@ switch1(tnode_t *tn) cstmt->c_switch = true; cstmt->c_swtype = tp; - reached = rchflg = false; + set_reached(false); seen_fallthrough = true; } @@ -732,14 +747,14 @@ switch2(void) * end of switch always reached (c_break is only set if the * break statement can be reached). */ - reached = true; + set_reached(true); } else if (!cstmt->c_default && (!hflag || !cstmt->c_swtype->t_is_enum || nenum != nclab)) { /* * there are possible values which are not handled in * switch */ - reached = true; + set_reached(true); } /* * otherwise the end of the switch expression is reached * if the end of the last statement inside it is reached. @@ -759,7 +774,8 @@ while1(tnode_t *tn) if (!reached) { /* loop
CVS commit: [thorpej-cfargs] src/sys/dev/gpio
Module Name:src Committed By: thorpej Date: Sun Mar 21 18:03:32 UTC 2021 Modified Files: src/sys/dev/gpio [thorpej-cfargs]: gpio.c Log Message: Remove a now-unused variable. To generate a diff of this commit: cvs rdiff -u -r1.64.10.3 -r1.64.10.4 src/sys/dev/gpio/gpio.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/gpio/gpio.c diff -u src/sys/dev/gpio/gpio.c:1.64.10.3 src/sys/dev/gpio/gpio.c:1.64.10.4 --- src/sys/dev/gpio/gpio.c:1.64.10.3 Sun Mar 21 17:35:48 2021 +++ src/sys/dev/gpio/gpio.c Sun Mar 21 18:03:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: gpio.c,v 1.64.10.3 2021/03/21 17:35:48 thorpej Exp $ */ +/* $NetBSD: gpio.c,v 1.64.10.4 2021/03/21 18:03:32 thorpej Exp $ */ /* $OpenBSD: gpio.c,v 1.6 2006/01/14 12:33:49 grange Exp $ */ /* @@ -19,7 +19,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.64.10.3 2021/03/21 17:35:48 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.64.10.4 2021/03/21 18:03:32 thorpej Exp $"); /* * General Purpose Input/Output framework. @@ -189,7 +189,6 @@ gpio_childdetached(device_t self, device static int gpio_rescan(device_t self, const char *ifattr, const int *locators) { - struct gpio_softc *sc = device_private(self); config_search(self, NULL, CFARG_SUBMATCH, gpio_search,
CVS commit: [thorpej-cfargs] src/sys/kern
Module Name:src Committed By: thorpej Date: Sun Mar 21 17:58:40 UTC 2021 Modified Files: src/sys/kern [thorpej-cfargs]: subr_autoconf.c Log Message: In config_search(), we already asserted that either an interface attribute is not specified, or the specified attribute is carried by the parent. Add an additional assertion: That an interface attribute is specified or that the parent has fewer than 2 interface attributes (i.e. lack of interface attribute specification would be ambiguous). Yes, "fewer than 2". Zero interface attributes doesn't really make sense, because a device cannot then be a parent of another device by definition. But cfparent_match() would already catch this situation gracefully, and there is obviously no ambiguity when a device has no interface attributes. To generate a diff of this commit: cvs rdiff -u -r1.277.2.1 -r1.277.2.2 src/sys/kern/subr_autoconf.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/subr_autoconf.c diff -u src/sys/kern/subr_autoconf.c:1.277.2.1 src/sys/kern/subr_autoconf.c:1.277.2.2 --- src/sys/kern/subr_autoconf.c:1.277.2.1 Sat Mar 20 19:33:41 2021 +++ src/sys/kern/subr_autoconf.c Sun Mar 21 17:58:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.277.2.1 2021/03/20 19:33:41 thorpej Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.277.2.2 2021/03/21 17:58:40 thorpej Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.277.2.1 2021/03/20 19:33:41 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.277.2.2 2021/03/21 17:58:40 thorpej Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -809,6 +809,23 @@ cfdriver_get_iattr(const struct cfdriver return 0; } +#if defined(DIAGNOSTIC) +static int +cfdriver_iattr_count(const struct cfdriver *cd) +{ + const struct cfiattrdata * const *cpp; + int i; + + if (cd->cd_attrs == NULL) + return 0; + + for (i = 0, cpp = cd->cd_attrs; *cpp; cpp++) { + i++; + } + return i; +} +#endif /* DIAGNOSTIC */ + /* * Lookup an interface attribute description by name. * If the driver is given, consider only its supported attributes. @@ -1071,6 +1088,7 @@ config_vsearch(device_t parent, void *au KASSERT(config_initialized); KASSERT(!ifattr || cfdriver_get_iattr(parent->dv_cfdriver, ifattr)); + KASSERT(ifattr || cfdriver_iattr_count(parent->dv_cfdriver) < 2); m.fn = fn; m.parent = parent;
CVS commit: [thorpej-cfargs] src/sys
Module Name:src Committed By: thorpej Date: Sun Mar 21 17:35:49 UTC 2021 Modified Files: src/sys/arch/acorn32/eb7500atx [thorpej-cfargs]: rsbus.c src/sys/arch/acorn32/mainbus [thorpej-cfargs]: pioc.c src/sys/arch/amiga/clockport [thorpej-cfargs]: clockport.c src/sys/arch/arm/at91 [thorpej-cfargs]: at91bus.c src/sys/arch/arm/broadcom [thorpej-cfargs]: bcm53xx_ccb.c src/sys/arch/arm/ep93xx [thorpej-cfargs]: epsoc.c src/sys/arch/arm/gemini [thorpej-cfargs]: gemini_lpc.c src/sys/arch/arm/imx [thorpej-cfargs]: imx23_ahb.c imx23_apbh.c imx23_apbx.c imx23_usb.c imx31_ahb.c imx31_aips.c imx51_axi.c imx51_usb.c src/sys/arch/arm/iomd [thorpej-cfargs]: vidc20.c src/sys/arch/arm/ixp12x0 [thorpej-cfargs]: ixpsip.c src/sys/arch/arm/mainbus [thorpej-cfargs]: mainbus.c src/sys/arch/arm/mpcore [thorpej-cfargs]: mpcore_axi.c mpcore_pmr.c src/sys/arch/arm/omap [thorpej-cfargs]: omap2_gpmc.c omap2_l3i.c omap2_obio.c omap_emifs.c omap_ocp.c omap_tipb.c omapl1x_tipb.c src/sys/arch/arm/s3c2xx0 [thorpej-cfargs]: s3c2410.c s3c2410_extint.c s3c2410_spi.c s3c2440.c s3c2440_extint.c s3c2440_i2s.c s3c2440_spi.c s3c2800.c src/sys/arch/arm/sa11x0 [thorpej-cfargs]: sa11x0.c src/sys/arch/arm/xscale [thorpej-cfargs]: ixp425_ixme.c ixp425_npe.c ixp425_sip.c pxa2x0.c src/sys/arch/arm/zynq [thorpej-cfargs]: zynq_axi.c src/sys/arch/atari/vme [thorpej-cfargs]: vme.c src/sys/arch/cesfic/cesfic [thorpej-cfargs]: autoconf.c src/sys/arch/cobalt/cobalt [thorpej-cfargs]: mainbus.c src/sys/arch/dreamcast/dev/g1 [thorpej-cfargs]: g1bus.c src/sys/arch/dreamcast/dev/g2 [thorpej-cfargs]: g2bus.c src/sys/arch/epoc32/epoc32 [thorpej-cfargs]: external.c src/sys/arch/evbarm/adi_brh [thorpej-cfargs]: obio.c src/sys/arch/evbarm/g42xxeb [thorpej-cfargs]: gb225.c obio.c src/sys/arch/evbarm/gumstix [thorpej-cfargs]: gxio.c src/sys/arch/evbarm/hdl_g [thorpej-cfargs]: obio.c src/sys/arch/evbarm/iq80310 [thorpej-cfargs]: obio.c src/sys/arch/evbarm/iq80321 [thorpej-cfargs]: obio.c src/sys/arch/evbarm/iyonix [thorpej-cfargs]: obio.c src/sys/arch/evbarm/lubbock [thorpej-cfargs]: obio.c sacc_obio.c src/sys/arch/evbsh3/evbsh3 [thorpej-cfargs]: mainbus.c src/sys/arch/hp300/dev [thorpej-cfargs]: hpib.c src/sys/arch/hp300/hp300 [thorpej-cfargs]: autoconf.c src/sys/arch/hpcarm/dev [thorpej-cfargs]: ipaq_atmelgpio.c ipaq_saip.c j720ssp.c nbppcon.c sacc_hpcarm.c uda1341.c src/sys/arch/hpcmips/dev [thorpej-cfargs]: plum.c plumiobus.c ucb1200.c src/sys/arch/hpcmips/tx [thorpej-cfargs]: tx39sib.c tx39spi.c tx39uart.c txcsbus.c txsim.c src/sys/arch/hpcmips/vr [thorpej-cfargs]: vrc4173bcu.c vrip.c src/sys/arch/i386/pnpbios [thorpej-cfargs]: pnpbios.c src/sys/arch/iyonix/iyonix [thorpej-cfargs]: obio.c src/sys/arch/landisk/dev [thorpej-cfargs]: obio.c src/sys/arch/mac68k/mac68k [thorpej-cfargs]: mainbus.c src/sys/arch/mac68k/obio [thorpej-cfargs]: obio.c src/sys/arch/mips/ralink [thorpej-cfargs]: ralink_mainbus.c src/sys/arch/mips/rmi [thorpej-cfargs]: rmixl_iobus.c rmixl_mainbus.c rmixl_obio.c rmixl_usbi.c src/sys/arch/mips/sibyte/dev [thorpej-cfargs]: sbgbus.c src/sys/arch/mipsco/obio [thorpej-cfargs]: obio.c src/sys/arch/mmeye/mmeye [thorpej-cfargs]: mainbus.c src/sys/arch/news68k/dev [thorpej-cfargs]: hb.c src/sys/arch/news68k/news68k [thorpej-cfargs]: mainbus.c src/sys/arch/newsmips/dev [thorpej-cfargs]: hb.c src/sys/arch/next68k/dev [thorpej-cfargs]: intio.c src/sys/arch/next68k/next68k [thorpej-cfargs]: mainbus.c src/sys/arch/playstation2/dev [thorpej-cfargs]: sbus.c src/sys/arch/playstation2/playstation2 [thorpej-cfargs]: mainbus.c src/sys/arch/powerpc/booke/dev [thorpej-cfargs]: pq3obio.c src/sys/arch/prep/pnpbus [thorpej-cfargs]: pnpbus.c src/sys/arch/rs6000/mca [thorpej-cfargs]: ioplanar.c src/sys/arch/sandpoint/sandpoint [thorpej-cfargs]: eumb.c src/sys/arch/sgimips/gio [thorpej-cfargs]: gio.c src/sys/arch/sgimips/ioc [thorpej-cfargs]: ioc.c src/sys/arch/sgimips/mace [thorpej-cfargs]: mace.c src/sys/arch/sgimips/sgimips [thorpej-cfargs]: mainbus.c src/sys/arch/sh3/dev [thorpej-cfargs]: adc.c shb.c src/sys/arch/sparc/dev [thorpej-cfargs]: obio.c src/sys/arch/sun2/sun2 [thorpej-cfargs]: mbio.c mbmem.c obio.c obmem.c src/sys/arch/sun3/sun3 [thorpej-cfargs]: obmem.c vme.c src/sys/arch/sun3/sun3x [thorpej-cfargs]: vme.c src/sys/arch/vax/vsa [thorpej-cfargs]: vsbus.c src/sys/arch/x68k/dev
CVS commit: src/tests/lib/libc/sys
Module Name:src Committed By: christos Date: Sun Mar 21 16:58:07 UTC 2021 Modified Files: src/tests/lib/libc/sys: t_sendrecv.c Log Message: use a pipe instead of sched_yield() To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/sys/t_sendrecv.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/sys/t_sendrecv.c diff -u src/tests/lib/libc/sys/t_sendrecv.c:1.6 src/tests/lib/libc/sys/t_sendrecv.c:1.7 --- src/tests/lib/libc/sys/t_sendrecv.c:1.6 Sat Feb 2 22:19:28 2019 +++ src/tests/lib/libc/sys/t_sendrecv.c Sun Mar 21 12:58:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_sendrecv.c,v 1.6 2019/02/03 03:19:28 mrg Exp $ */ +/* $NetBSD: t_sendrecv.c,v 1.7 2021/03/21 16:58:07 christos Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_sendrecv.c,v 1.6 2019/02/03 03:19:28 mrg Exp $"); +__RCSID("$NetBSD: t_sendrecv.c,v 1.7 2021/03/21 16:58:07 christos Exp $"); #include #include @@ -41,7 +41,6 @@ __RCSID("$NetBSD: t_sendrecv.c,v 1.6 201 #include #include #include -#include #include @@ -62,33 +61,33 @@ handle_sigchld(__unused int pid) } static void -sender(int fd) +sender(int sd) { union packet p; ssize_t n; p.seq = 0; for (size_t i = 0; i < COUNT; i++) { - for (; (n = send(fd, , sizeof(p), 0)) == sizeof(p); + for (; (n = send(sd, , sizeof(p), 0)) == sizeof(p); p.seq++) continue; - printf(">>%zd %d %ju\n", n, errno, p.seq); +// printf(">>%zd %d %ju\n", n, errno, p.seq); ATF_REQUIRE_MSG(errno == ENOBUFS, "send %s", strerror(errno)); -// sched_yield(); } - printf("sender done\n"); + close(sd); +// printf("sender done\n"); } static void -receiver(int fd) +receiver(int sd) { union packet p; ssize_t n; uintmax_t seq = 0; - do { + for (size_t i = 0; i < COUNT; i++) { if (rdied) return; - while ((n = recv(fd, , sizeof(p), 0), sizeof(p)) + while ((n = recv(sd, , sizeof(p), 0), sizeof(p)) == sizeof(p)) { if (rdied) @@ -97,26 +96,29 @@ receiver(int fd) printf("%ju != %ju\n", p.seq, seq); seq = p.seq + 1; } - printf("<<%zd %d %ju\n", n, errno, seq); +// printf("<<%zd %d %ju\n", n, errno, seq); if (n == 0) return; ATF_REQUIRE_EQ(n, -1); ATF_REQUIRE_MSG(errno == ENOBUFS, "recv %s", strerror(errno)); - } while (p.seq < COUNT); + } + close(sd); } static void sendrecv(int rerror) { - int fd[2], error; + int fd[2], sd[2], error; + char c = 0; struct sigaction sa; - error = socketpair(AF_UNIX, SOCK_DGRAM, 0, fd); -// error = pipe(fd); + error = socketpair(AF_UNIX, SOCK_DGRAM, 0, sd); ATF_REQUIRE_MSG(error != -1, "socketpair failed (%s)", strerror(errno)); + error = pipe(fd); + ATF_REQUIRE_MSG(error != -1, "pipe failed (%s)", strerror(errno)); - for (size_t i = 0; i < __arraycount(fd); i++) { - error = setsockopt(fd[i], SOL_SOCKET, SO_RERROR, , + for (size_t i = 0; i < __arraycount(sd); i++) { + error = setsockopt(sd[i], SOL_SOCKET, SO_RERROR, , sizeof(rerror)); ATF_REQUIRE_MSG(error != -1, "setsockopt(SO_RERROR) failed (%s)", strerror(errno)); @@ -133,17 +135,18 @@ sendrecv(int rerror) switch (fork()) { case -1: ATF_REQUIRE_MSG(errno == 0, - "socketpair failed (%s)", strerror(errno)); + "fork failed (%s)", strerror(errno)); __unreachable(); /*NOTREACHED*/ case 0: - sched_yield(); - sender(fd[0]); - close(fd[0]); + read(fd[1], , sizeof(c)); + sender(sd[0]); + close(sd[0]); exit(EXIT_SUCCESS); /*NOTREACHED*/ default: - receiver(fd[1]); + write(fd[0], , sizeof(c)); + receiver(sd[1]); return; } }
CVS commit: src/tests/lib/libc/setjmp
Module Name:src Committed By: christos Date: Sun Mar 21 16:36:32 UTC 2021 Modified Files: src/tests/lib/libc/setjmp: t_setjmp.c Log Message: PR/56066: Jessica Clarke: Add tests for calling {_,}longjmp with a zero value. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/setjmp/t_setjmp.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/setjmp/t_setjmp.c diff -u src/tests/lib/libc/setjmp/t_setjmp.c:1.2 src/tests/lib/libc/setjmp/t_setjmp.c:1.3 --- src/tests/lib/libc/setjmp/t_setjmp.c:1.2 Sat Jan 14 16:08:17 2017 +++ src/tests/lib/libc/setjmp/t_setjmp.c Sun Mar 21 12:36:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_setjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $ */ +/* $NetBSD: t_setjmp.c,v 1.3 2021/03/21 16:36:32 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -63,13 +63,14 @@ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_setjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $"); +__RCSID("$NetBSD: t_setjmp.c,v 1.3 2021/03/21 16:36:32 christos Exp $"); #include #include #include #include +#include #include #include #include @@ -83,6 +84,8 @@ __RCSID("$NetBSD: t_setjmp.c,v 1.2 2017/ #define TEST_U_SETJMP 1 #define TEST_SIGSETJMP_SAVE 2 #define TEST_SIGSETJMP_NOSAVE 3 +#define TEST_LONGJMP_ZERO 4 +#define TEST_U_LONGJMP_ZERO 5 static int expectsignal; @@ -101,12 +104,16 @@ h_check(int test) sigjmp_buf sjb; sigset_t ss; int i, x; + volatile bool did_longjmp; i = getpid(); + did_longjmp = false; - if (test == TEST_SETJMP || test == TEST_SIGSETJMP_SAVE) + if (test == TEST_SETJMP || test == TEST_SIGSETJMP_SAVE || + test == TEST_LONGJMP_ZERO) expectsignal = 0; - else if (test == TEST_U_SETJMP || test == TEST_SIGSETJMP_NOSAVE) + else if (test == TEST_U_SETJMP || test == TEST_SIGSETJMP_NOSAVE || + test == TEST_U_LONGJMP_ZERO) expectsignal = 1; else atf_tc_fail("unknown test"); @@ -119,26 +126,37 @@ h_check(int test) REQUIRE_ERRNO(sigaddset(, SIGABRT) != -1); REQUIRE_ERRNO(sigprocmask(SIG_BLOCK, , NULL) != -1); - if (test == TEST_SETJMP) + if (test == TEST_SETJMP || test == TEST_LONGJMP_ZERO) x = setjmp(jb); - else if (test == TEST_U_SETJMP) + else if (test == TEST_U_SETJMP || test == TEST_U_LONGJMP_ZERO) x = _setjmp(jb); else x = sigsetjmp(sjb, !expectsignal); if (x != 0) { - ATF_REQUIRE_MSG(x == i, "setjmp returned wrong value"); + if (test == TEST_LONGJMP_ZERO || test == TEST_U_LONGJMP_ZERO) + ATF_REQUIRE_MSG(x == 1, "setjmp returned wrong value"); + else + ATF_REQUIRE_MSG(x == i, "setjmp returned wrong value"); + kill(i, SIGABRT); ATF_REQUIRE_MSG(!expectsignal, "kill(SIGABRT) failed"); atf_tc_pass(); + } else if (did_longjmp) { + atf_tc_fail("setjmp returned zero after longjmp"); } REQUIRE_ERRNO(sigprocmask(SIG_UNBLOCK, , NULL) != -1); + did_longjmp = true; if (test == TEST_SETJMP) longjmp(jb, i); + else if (test == TEST_LONGJMP_ZERO) + longjmp(jb, 0); else if (test == TEST_U_SETJMP) _longjmp(jb, i); + else if (test == TEST_U_LONGJMP_ZERO) + _longjmp(jb, 0); else siglongjmp(sjb, i); @@ -185,12 +203,34 @@ ATF_TC_BODY(sigsetjmp_nosave, tc) h_check(TEST_SIGSETJMP_NOSAVE); } +ATF_TC(longjmp_zero); +ATF_TC_HEAD(longjmp_zero, tc) +{ + atf_tc_set_md_var(tc, "descr", "Checks longjmp(3) with a zero value"); +} +ATF_TC_BODY(longjmp_zero, tc) +{ + h_check(TEST_LONGJMP_ZERO); +} + +ATF_TC(_longjmp_zero); +ATF_TC_HEAD(_longjmp_zero, tc) +{ + atf_tc_set_md_var(tc, "descr", "Checks _longjmp(3) with a zero value"); +} +ATF_TC_BODY(_longjmp_zero, tc) +{ + h_check(TEST_U_LONGJMP_ZERO); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, setjmp); ATF_TP_ADD_TC(tp, _setjmp); ATF_TP_ADD_TC(tp, sigsetjmp_save); ATF_TP_ADD_TC(tp, sigsetjmp_nosave); + ATF_TP_ADD_TC(tp, longjmp_zero); + ATF_TP_ADD_TC(tp, _longjmp_zero); return atf_no_error(); }
CVS commit: [thorpej-cfargs] src/sys/arch/sandpoint/conf
Module Name:src Committed By: thorpej Date: Sun Mar 21 16:32:00 UTC 2021 Modified Files: src/sys/arch/sandpoint/conf [thorpej-cfargs]: files.sandpoint Log Message: eumb does not need to carry the "mainbus" interface attribute. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.31.62.1 src/sys/arch/sandpoint/conf/files.sandpoint Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sandpoint/conf/files.sandpoint diff -u src/sys/arch/sandpoint/conf/files.sandpoint:1.31 src/sys/arch/sandpoint/conf/files.sandpoint:1.31.62.1 --- src/sys/arch/sandpoint/conf/files.sandpoint:1.31 Sat Jan 14 19:39:25 2012 +++ src/sys/arch/sandpoint/conf/files.sandpoint Sun Mar 21 16:32:00 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files.sandpoint,v 1.31 2012/01/14 19:39:25 phx Exp $ +# $NetBSD: files.sandpoint,v 1.31.62.1 2021/03/21 16:32:00 thorpej Exp $ # # Motorola's "SandPoint" evaluation board and multiplied descendents. # @@ -52,7 +52,7 @@ device nhpow: sysmon_power, sysmon_taskq attach nhpow at mainbus file arch/sandpoint/sandpoint/nhpow.c nhpow -device eumb { [ unit = -1 ] }: mainbus +device eumb { [ unit = -1 ] } attach eumb at mainbus file arch/sandpoint/sandpoint/eumb.c eumb
CVS commit: src/external/mpl/bind/bin/nslookup
Module Name:src Committed By: christos Date: Sun Mar 21 16:21:35 UTC 2021 Modified Files: src/external/mpl/bind/bin/nslookup: nslookup.8 Log Message: revert the unintentional whitespace changes To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/mpl/bind/bin/nslookup/nslookup.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/mpl/bind/bin/nslookup/nslookup.8 diff -u src/external/mpl/bind/bin/nslookup/nslookup.8:1.2 src/external/mpl/bind/bin/nslookup/nslookup.8:1.3 --- src/external/mpl/bind/bin/nslookup/nslookup.8:1.2 Sun Mar 21 12:12:37 2021 +++ src/external/mpl/bind/bin/nslookup/nslookup.8 Sun Mar 21 12:21:35 2021 @@ -1,27 +1,27 @@ -.\" $NetBSD: nslookup.8,v 1.2 2021/03/21 16:12:37 christos Exp $ +.\" $NetBSD: nslookup.8,v 1.3 2021/03/21 16:21:35 christos Exp $ .\" .\" .\" ++Copyright++ 1985, 1989 .\" - .\" Copyright (c) 1985, 1989 -.\" The Regents of the University of California. All rights reserved. +.\"The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. +.\"notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. +.\"notice, this list of conditions and the following disclaimer in the +.\"documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. +.\"may be used to endorse or promote products derived from this software +.\"without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) @@ -41,7 +41,7 @@ .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL .\" WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT +.\" OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT .\" CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL .\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR .\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS @@ -52,7 +52,7 @@ .\" .\" @(#)nslookup.8 5.3 (Berkeley) 6/24/90 .\" -.Dd March 21, 2021 +.Dd June 24, 1990 .Dt NSLOOKUP 8 .Os .Sh NAME @@ -102,7 +102,7 @@ the arguments and are prefixed with a hy For example, to change the default query type to host information, and the initial timeout to 10 seconds, type: .Bd -literal -offset indent - nslookup -query=hinfo -timeout=10 + nslookup -query=hinfo -timeout=10 .Ed .Sh INTERACTIVE COMMANDS Commands may be interrupted at any time by typing a control-C. @@ -114,7 +114,7 @@ The command line length must be less tha To treat a built-in command as a host name, precede it with an escape character .Pq Sq \e . -.Em N.B.: An unrecognized command will be interpreted as a host name. +.Em N.B.: An unrecognized command will be interpreted as a host name. .Bl -tag -width "lserver" .It Ar host Op Ar server Look up information for @@ -187,7 +187,7 @@ optionally creating or appending to The default output contains host names and their Internet addresses. .Ar Option can be one of the following: -.Bl -tag -width "-a " +.Bl -tag -width "-a " .It Fl t Ar querytype lists all records of the specified type (see .Ar querytype @@ -229,10 +229,10 @@ Valid keywords are: .It Ic all Prints the current values of the frequently-used options to .Ic set . -Information about the current default server and host is also printed. +Information about the current default server and host is also printed. .It Ic class Ns = Ns Ar value Change the query class to one of: -.Bl -tag -width "HESIOD " +.Bl -tag -width "HESIOD "
CVS commit: src/external/mpl/bind/bin/nslookup
Module Name:src Committed By: christos Date: Sun Mar 21 16:12:37 UTC 2021 Modified Files: src/external/mpl/bind/bin/nslookup: nslookup.8 Log Message: Remove some obsolete information and add some more recent additions from the nslookup.1 page in the distribution. Consider replacing this man page with the one from the distribution, since this manual page describes options available only in the original implemementation. On the other hand, this man page is mdoc, not man... (Takahiro Kambe) To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/external/mpl/bind/bin/nslookup/nslookup.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/mpl/bind/bin/nslookup/nslookup.8 diff -u src/external/mpl/bind/bin/nslookup/nslookup.8:1.1 src/external/mpl/bind/bin/nslookup/nslookup.8:1.2 --- src/external/mpl/bind/bin/nslookup/nslookup.8:1.1 Sun Aug 12 09:02:26 2018 +++ src/external/mpl/bind/bin/nslookup/nslookup.8 Sun Mar 21 12:12:37 2021 @@ -1,27 +1,27 @@ -.\" $NetBSD: nslookup.8,v 1.1 2018/08/12 13:02:26 christos Exp $ +.\" $NetBSD: nslookup.8,v 1.2 2021/03/21 16:12:37 christos Exp $ .\" .\" .\" ++Copyright++ 1985, 1989 .\" - .\" Copyright (c) 1985, 1989 -.\"The Regents of the University of California. All rights reserved. +.\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright -.\"notice, this list of conditions and the following disclaimer. +.\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright -.\"notice, this list of conditions and the following disclaimer in the -.\"documentation and/or other materials provided with the distribution. +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors -.\"may be used to endorse or promote products derived from this software -.\"without specific prior written permission. +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) @@ -41,7 +41,7 @@ .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL .\" WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT +.\" OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT .\" CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL .\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR .\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS @@ -52,7 +52,7 @@ .\" .\" @(#)nslookup.8 5.3 (Berkeley) 6/24/90 .\" -.Dd June 24, 1990 +.Dd March 21, 2021 .Dt NSLOOKUP 8 .Os .Sh NAME @@ -102,7 +102,7 @@ the arguments and are prefixed with a hy For example, to change the default query type to host information, and the initial timeout to 10 seconds, type: .Bd -literal -offset indent - nslookup -query=hinfo -timeout=10 + nslookup -query=hinfo -timeout=10 .Ed .Sh INTERACTIVE COMMANDS Commands may be interrupted at any time by typing a control-C. @@ -114,7 +114,7 @@ The command line length must be less tha To treat a built-in command as a host name, precede it with an escape character .Pq Sq \e . -.Em N.B.: An unrecognized command will be interpreted as a host name. +.Em N.B.: An unrecognized command will be interpreted as a host name. .Bl -tag -width "lserver" .It Ar host Op Ar server Look up information for @@ -187,7 +187,7 @@ optionally creating or appending to The default output contains host names and their Internet addresses. .Ar Option can be one of the following: -.Bl -tag -width "-a " +.Bl -tag -width "-a " .It Fl t Ar querytype lists all records of the specified type (see .Ar querytype @@ -229,10 +229,10 @@ Valid keywords are: .It Ic all Prints the current values of the
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Mar 21 15:44:57 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_161.c msg_161.exp msg_193.c msg_193.exp src/usr.bin/xlint/lint1: func.c Log Message: lint: fix reachability for while (0) To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_161.c \ src/tests/usr.bin/xlint/lint1/msg_193.c \ src/tests/usr.bin/xlint/lint1/msg_193.exp cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_161.exp cvs rdiff -u -r1.91 -r1.92 src/usr.bin/xlint/lint1/func.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_161.c diff -u src/tests/usr.bin/xlint/lint1/msg_161.c:1.6 src/tests/usr.bin/xlint/lint1/msg_161.c:1.7 --- src/tests/usr.bin/xlint/lint1/msg_161.c:1.6 Sun Feb 28 03:59:28 2021 +++ src/tests/usr.bin/xlint/lint1/msg_161.c Sun Mar 21 15:44:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_161.c,v 1.6 2021/02/28 03:59:28 rillig Exp $ */ +/* $NetBSD: msg_161.c,v 1.7 2021/03/21 15:44:57 rillig Exp $ */ # 3 "msg_161.c" // Test for message: constant in conditional context [161] @@ -16,7 +16,7 @@ void while_0(void) { while (0) /* expect: 161 */ - continue; + continue; /* expect: statement not reached */ } /* Index: src/tests/usr.bin/xlint/lint1/msg_193.c diff -u src/tests/usr.bin/xlint/lint1/msg_193.c:1.6 src/tests/usr.bin/xlint/lint1/msg_193.c:1.7 --- src/tests/usr.bin/xlint/lint1/msg_193.c:1.6 Sun Mar 21 15:34:13 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 15:44:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_193.c,v 1.6 2021/03/21 15:34:13 rillig Exp $ */ +/* $NetBSD: msg_193.c,v 1.7 2021/03/21 15:44:57 rillig Exp $ */ # 3 "msg_193.c" // Test for message: statement not reached [193] @@ -282,7 +282,7 @@ void test_while_false(void) { while (0) - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ reachable(); } Index: src/tests/usr.bin/xlint/lint1/msg_193.exp diff -u src/tests/usr.bin/xlint/lint1/msg_193.exp:1.6 src/tests/usr.bin/xlint/lint1/msg_193.exp:1.7 --- src/tests/usr.bin/xlint/lint1/msg_193.exp:1.6 Sun Mar 21 15:34:13 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.exp Sun Mar 21 15:44:57 2021 @@ -32,6 +32,7 @@ msg_193.c(261): warning: statement not r msg_193.c(266): warning: statement not reached [193] msg_193.c(270): warning: statement not reached [193] msg_193.c(278): warning: statement not reached [193] +msg_193.c(285): warning: statement not reached [193] msg_193.c(295): warning: statement not reached [193] msg_193.c(306): warning: statement not reached [193] msg_193.c(308): warning: statement not reached [193] Index: src/tests/usr.bin/xlint/lint1/msg_161.exp diff -u src/tests/usr.bin/xlint/lint1/msg_161.exp:1.5 src/tests/usr.bin/xlint/lint1/msg_161.exp:1.6 --- src/tests/usr.bin/xlint/lint1/msg_161.exp:1.5 Sun Feb 28 03:59:28 2021 +++ src/tests/usr.bin/xlint/lint1/msg_161.exp Sun Mar 21 15:44:57 2021 @@ -1,3 +1,4 @@ msg_161.c(11): warning: constant in conditional context [161] msg_161.c(18): warning: constant in conditional context [161] +msg_161.c(19): warning: statement not reached [193] msg_161.c(41): warning: constant in conditional context [161] Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.91 src/usr.bin/xlint/lint1/func.c:1.92 --- src/usr.bin/xlint/lint1/func.c:1.91 Sun Mar 21 15:34:13 2021 +++ src/usr.bin/xlint/lint1/func.c Sun Mar 21 15:44:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.91 2021/03/21 15:34:13 rillig Exp $ */ +/* $NetBSD: func.c,v 1.92 2021/03/21 15:44:57 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.91 2021/03/21 15:34:13 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.92 2021/03/21 15:44:57 rillig Exp $"); #endif #include @@ -754,6 +754,7 @@ switch2(void) void while1(tnode_t *tn) { + bool body_reached; if (!reached) { /* loop not entered at top */ @@ -766,11 +767,13 @@ while1(tnode_t *tn) pushctrl(T_WHILE); cstmt->c_loop = true; - if (tn != NULL && tn->tn_op == CON) - cstmt->c_maybe_endless = constant_is_nonzero(tn); + cstmt->c_maybe_endless = is_nonzero(tn); + body_reached = !is_zero(tn); check_getopt_begin_while(tn); expr(tn, false, true, true, false); + + reached = body_reached; } /*
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Mar 21 15:34:13 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_193.c msg_193.exp src/usr.bin/xlint/lint1: func.c lint1.h Log Message: lint: fix reachability for constant controlling expression in for loop To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_193.c \ src/tests/usr.bin/xlint/lint1/msg_193.exp cvs rdiff -u -r1.90 -r1.91 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.86 -r1.87 src/usr.bin/xlint/lint1/lint1.h 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_193.c diff -u src/tests/usr.bin/xlint/lint1/msg_193.c:1.5 src/tests/usr.bin/xlint/lint1/msg_193.c:1.6 --- src/tests/usr.bin/xlint/lint1/msg_193.c:1.5 Sun Mar 21 15:24:56 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 15:34:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_193.c,v 1.5 2021/03/21 15:24:56 rillig Exp $ */ +/* $NetBSD: msg_193.c,v 1.6 2021/03/21 15:34:13 rillig Exp $ */ # 3 "msg_193.c" // Test for message: statement not reached [193] @@ -173,7 +173,7 @@ void test_for_false(void) { for (; 0;) - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ reachable(); } Index: src/tests/usr.bin/xlint/lint1/msg_193.exp diff -u src/tests/usr.bin/xlint/lint1/msg_193.exp:1.5 src/tests/usr.bin/xlint/lint1/msg_193.exp:1.6 --- src/tests/usr.bin/xlint/lint1/msg_193.exp:1.5 Sun Mar 21 15:24:56 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.exp Sun Mar 21 15:34:13 2021 @@ -14,6 +14,7 @@ msg_193.c(143): warning: statement not r msg_193.c(152): warning: statement not reached [193] msg_193.c(161): warning: statement not reached [193] msg_193.c(169): warning: statement not reached [193] +msg_193.c(176): warning: statement not reached [193] msg_193.c(186): warning: statement not reached [193] msg_193.c(197): warning: statement not reached [193] msg_193.c(199): warning: statement not reached [193] Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.90 src/usr.bin/xlint/lint1/func.c:1.91 --- src/usr.bin/xlint/lint1/func.c:1.90 Sun Mar 21 15:24:55 2021 +++ src/usr.bin/xlint/lint1/func.c Sun Mar 21 15:34:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.90 2021/03/21 15:24:55 rillig Exp $ */ +/* $NetBSD: func.c,v 1.91 2021/03/21 15:34:13 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.90 2021/03/21 15:24:55 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.91 2021/03/21 15:34:13 rillig Exp $"); #endif #include @@ -883,12 +883,11 @@ for1(tnode_t *tn1, tnode_t *tn2, tnode_t if (tn2 != NULL) expr(tn2, false, true, true, false); - cstmt->c_maybe_endless = - tn2 == NULL || (tn2->tn_op == CON && constant_is_nonzero(tn2)); + cstmt->c_maybe_endless = tn2 == NULL || is_nonzero(tn2); /* Checking the reinitialization expression is done in for2() */ - reached = true; + reached = !is_zero(tn2); } /* Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.86 src/usr.bin/xlint/lint1/lint1.h:1.87 --- src/usr.bin/xlint/lint1/lint1.h:1.86 Sun Mar 21 14:36:59 2021 +++ src/usr.bin/xlint/lint1/lint1.h Sun Mar 21 15:34:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.86 2021/03/21 14:36:59 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.87 2021/03/21 15:34:13 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -483,3 +483,15 @@ constant_is_nonzero(const tnode_t *tn) lint_assert(tn->tn_type->t_tspec == tn->tn_val->v_tspec); return is_nonzero_val(tn->tn_val); } + +static inline bool +is_zero(const tnode_t *tn) +{ + return tn != NULL && tn->tn_op == CON && !is_nonzero_val(tn->tn_val); +} + +static inline bool +is_nonzero(const tnode_t *tn) +{ + return tn != NULL && tn->tn_op == CON && is_nonzero_val(tn->tn_val); +}
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Mar 21 15:24:56 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_130.c msg_130.exp msg_193.c msg_193.exp msg_217.c msg_217.exp src/usr.bin/xlint/lint1: func.c Log Message: lint: fix reachability for if-then-else statements To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/msg_130.c cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/msg_130.exp cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_193.c \ src/tests/usr.bin/xlint/lint1/msg_193.exp cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_217.c cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_217.exp cvs rdiff -u -r1.89 -r1.90 src/usr.bin/xlint/lint1/func.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_130.c diff -u src/tests/usr.bin/xlint/lint1/msg_130.c:1.11 src/tests/usr.bin/xlint/lint1/msg_130.c:1.12 --- src/tests/usr.bin/xlint/lint1/msg_130.c:1.11 Wed Mar 10 00:02:00 2021 +++ src/tests/usr.bin/xlint/lint1/msg_130.c Sun Mar 21 15:24:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_130.c,v 1.11 2021/03/10 00:02:00 rillig Exp $ */ +/* $NetBSD: msg_130.c,v 1.12 2021/03/21 15:24:56 rillig Exp $ */ # 3 "msg_130.c" // Test for message: enum type mismatch: '%s' '%s' '%s' [130] @@ -89,7 +89,7 @@ enum_constant_from_unnamed_type(int x) if (sizeof_int == sizeof_uint) /* expect: 130 *//* FIXME */ return 6; - return 0; + return 0; /* expect: statement not reached */ } /* Index: src/tests/usr.bin/xlint/lint1/msg_130.exp diff -u src/tests/usr.bin/xlint/lint1/msg_130.exp:1.9 src/tests/usr.bin/xlint/lint1/msg_130.exp:1.10 --- src/tests/usr.bin/xlint/lint1/msg_130.exp:1.9 Wed Mar 10 00:02:00 2021 +++ src/tests/usr.bin/xlint/lint1/msg_130.exp Sun Mar 21 15:24:56 2021 @@ -2,4 +2,5 @@ msg_130.c(29): warning: enum type mismat msg_130.c(31): warning: enum type mismatch: 'enum color' '!=' 'enum size' [130] msg_130.c(32): warning: enum type mismatch: 'enum color' '==' 'enum size' [130] msg_130.c(89): warning: enum type mismatch: 'enum ' '==' 'enum ' [130] +msg_130.c(92): warning: statement not reached [193] msg_130.c(127): warning: enum type mismatch: 'enum ' '==' 'enum ' [130] Index: src/tests/usr.bin/xlint/lint1/msg_193.c diff -u src/tests/usr.bin/xlint/lint1/msg_193.c:1.4 src/tests/usr.bin/xlint/lint1/msg_193.c:1.5 --- src/tests/usr.bin/xlint/lint1/msg_193.c:1.4 Sun Mar 21 14:36:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 15:24:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_193.c,v 1.4 2021/03/21 14:36:59 rillig Exp $ */ +/* $NetBSD: msg_193.c,v 1.5 2021/03/21 15:24:56 rillig Exp $ */ # 3 "msg_193.c" // Test for message: statement not reached [193] @@ -140,7 +140,7 @@ test_if_return(void) { if (1) return; - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ } void Index: src/tests/usr.bin/xlint/lint1/msg_193.exp diff -u src/tests/usr.bin/xlint/lint1/msg_193.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_193.exp:1.5 --- src/tests/usr.bin/xlint/lint1/msg_193.exp:1.4 Sun Mar 21 14:36:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.exp Sun Mar 21 15:24:56 2021 @@ -10,6 +10,7 @@ msg_193.c(124): warning: statement not r msg_193.c(128): warning: statement not reached [193] msg_193.c(131): warning: statement not reached [193] msg_193.c(133): warning: statement not reached [193] +msg_193.c(143): warning: statement not reached [193] msg_193.c(152): warning: statement not reached [193] msg_193.c(161): warning: statement not reached [193] msg_193.c(169): warning: statement not reached [193] Index: src/tests/usr.bin/xlint/lint1/msg_217.c diff -u src/tests/usr.bin/xlint/lint1/msg_217.c:1.8 src/tests/usr.bin/xlint/lint1/msg_217.c:1.9 --- src/tests/usr.bin/xlint/lint1/msg_217.c:1.8 Sun Mar 21 14:36:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_217.c Sun Mar 21 15:24:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_217.c,v 1.8 2021/03/21 14:36:59 rillig Exp $ */ +/* $NetBSD: msg_217.c,v 1.9 2021/03/21 15:24:56 rillig Exp $ */ # 3 "msg_217.c" // Test for message: function %s falls off bottom without returning value [217] @@ -55,7 +55,7 @@ reachable_continue_leads_to_endless_loop continue; break; } -}/* FIXME *//* expect: 217 */ +} int unreachable_continue_falls_through(void) Index: src/tests/usr.bin/xlint/lint1/msg_217.exp diff -u src/tests/usr.bin/xlint/lint1/msg_217.exp:1.7 src/tests/usr.bin/xlint/lint1/msg_217.exp:1.8 --- src/tests/usr.bin/xlint/lint1/msg_217.exp:1.7 Sun Mar 21 14:36:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_217.exp Sun Mar 21 15:24:56 2021 @@ -1,4 +1,3 @@ msg_217.c(11): warning: function random falls off bottom without returning value [217] -msg_217.c(58): warning: function reachable_continue_leads_to_endless_loop falls off bottom without returning value [217]
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 14:49:21 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y externs1.h func.c lex.c Log Message: lint: rename functions for handling control statements No functional change. To generate a diff of this commit: cvs rdiff -u -r1.195 -r1.196 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.80 -r1.81 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.88 -r1.89 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/lint1/lex.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/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.195 src/usr.bin/xlint/lint1/cgram.y:1.196 --- src/usr.bin/xlint/lint1/cgram.y:1.195 Sun Mar 21 10:25:40 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Mar 21 14:49:21 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.195 2021/03/21 10:25:40 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.196 2021/03/21 14:49:21 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.195 2021/03/21 10:25:40 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.196 2021/03/21 14:49:21 rillig Exp $"); #endif #include @@ -1753,22 +1753,22 @@ opt_expr: jump_statement: /* C99 6.8.6 */ goto identifier T_SEMI { - dogoto(getsym($2)); + do_goto(getsym($2)); } | goto error T_SEMI { symtyp = FVFT; } | T_CONTINUE T_SEMI { - docont(); + do_continue(); } | T_BREAK T_SEMI { - dobreak(); + do_break(); } | T_RETURN T_SEMI { - doreturn(NULL); + do_return(NULL); } | T_RETURN expr T_SEMI { - doreturn($2); + do_return($2); } ; Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.80 src/usr.bin/xlint/lint1/externs1.h:1.81 --- src/usr.bin/xlint/lint1/externs1.h:1.80 Sat Mar 20 16:16:32 2021 +++ src/usr.bin/xlint/lint1/externs1.h Sun Mar 21 14:49:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.80 2021/03/20 16:16:32 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.81 2021/03/21 14:49:21 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -271,15 +271,15 @@ extern void do1(void); extern void do2(tnode_t *); extern void for1(tnode_t *, tnode_t *, tnode_t *); extern void for2(void); -extern void dogoto(sym_t *); -extern void docont(void); -extern void dobreak(void); -extern void doreturn(tnode_t *); +extern void do_goto(sym_t *); +extern void do_continue(void); +extern void do_break(void); +extern void do_return(tnode_t *); extern void global_clean_up_decl(bool); extern void argsused(int); extern void constcond(int); extern void fallthru(int); -extern void notreach(int); +extern void not_reached(int); extern void lintlib(int); extern void linted(int); extern void varargs(int); Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.88 src/usr.bin/xlint/lint1/func.c:1.89 --- src/usr.bin/xlint/lint1/func.c:1.88 Sun Mar 21 14:36:59 2021 +++ src/usr.bin/xlint/lint1/func.c Sun Mar 21 14:49:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.88 2021/03/21 14:36:59 rillig Exp $ */ +/* $NetBSD: func.c,v 1.89 2021/03/21 14:49:21 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.88 2021/03/21 14:36:59 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.89 2021/03/21 14:49:21 rillig Exp $"); #endif #include @@ -940,7 +940,7 @@ for2(void) * T_GOTO identifier T_SEMI */ void -dogoto(sym_t *lab) +do_goto(sym_t *lab) { mark_as_used(lab, false, false); @@ -954,7 +954,7 @@ dogoto(sym_t *lab) * T_BREAK T_SEMI */ void -dobreak(void) +do_break(void) { cstk_t *ci; @@ -980,7 +980,7 @@ dobreak(void) * T_CONTINUE T_SEMI */ void -docont(void) +do_continue(void) { cstk_t *ci; @@ -1005,7 +1005,7 @@ docont(void) * T_RETURN expr T_SEMI */ void -doreturn(tnode_t *tn) +do_return(tnode_t *tn) { tnode_t *ln, *rn; cstk_t *ci; @@ -1251,7 +1251,7 @@ fallthru(int n) */ /* ARGSUSED */ void -notreach(int n) +not_reached(int n) { reached = false; Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.14 src/usr.bin/xlint/lint1/lex.c:1.15 --- src/usr.bin/xlint/lint1/lex.c:1.14 Sat Mar 20 19:33:25 2021 +++ src/usr.bin/xlint/lint1/lex.c Sun Mar 21 14:49:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.14 2021/03/20 19:33:25 rillig Exp $ */ +/* $NetBSD: lex.c,v 1.15 2021/03/21 14:49:21 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: lex.c,v 1.14 2021/03/20 19:33:25 rillig Exp $"); +__RCSID("$NetBSD: lex.c,v 1.15 2021/03/21 14:49:21 rillig Exp $"); #endif #include @@ -1170,7 +1170,7
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Mar 21 14:36:59 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: d_c99_bool_strict.c d_c99_bool_strict.exp msg_193.c msg_193.exp msg_217.c msg_217.exp msg_333.c msg_333.exp src/usr.bin/xlint/lint1: func.c lint1.h Log Message: lint: fix reachability computation in if statements Previously, only loop statements were considered for reachability. This ignored the possibility of an early return in an if statement, or unreachable branches. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c cvs rdiff -u -r1.21 -r1.22 \ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_193.c \ src/tests/usr.bin/xlint/lint1/msg_193.exp cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_217.c cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_217.exp cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_333.c \ src/tests/usr.bin/xlint/lint1/msg_333.exp cvs rdiff -u -r1.87 -r1.88 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.85 -r1.86 src/usr.bin/xlint/lint1/lint1.h 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.25 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.26 --- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.25 Sun Mar 21 14:12:46 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c Sun Mar 21 14:36:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: d_c99_bool_strict.c,v 1.25 2021/03/21 14:12:46 rillig Exp $ */ +/* $NetBSD: d_c99_bool_strict.c,v 1.26 2021/03/21 14:36:59 rillig Exp $ */ # 3 "d_c99_bool_strict.c" /* @@ -365,7 +365,7 @@ void strict_bool_controlling_expression(bool b, int i, double d, const void *p) { if (__lint_false) /* expect: 161 */ - do_nothing(); + do_nothing(); /* expect: statement not reached */ if (__lint_true) /* expect: 161 */ do_nothing(); Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.21 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.22 --- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.21 Sun Mar 21 14:12:46 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp Sun Mar 21 14:36:59 2021 @@ -55,6 +55,7 @@ d_c99_bool_strict.c(354): operands of '= d_c99_bool_strict.c(355): operands of '=' have incompatible types (pointer != _Bool) [107] d_c99_bool_strict.c(345): warning: argument b unused in function strict_bool_conversion_from_bool_to_scalar [231] d_c99_bool_strict.c(367): warning: constant in conditional context [161] +d_c99_bool_strict.c(368): warning: statement not reached [193] d_c99_bool_strict.c(370): warning: constant in conditional context [161] d_c99_bool_strict.c(376): controlling expression must be bool, not 'int' [333] d_c99_bool_strict.c(379): controlling expression must be bool, not 'int' [333] Index: src/tests/usr.bin/xlint/lint1/msg_193.c diff -u src/tests/usr.bin/xlint/lint1/msg_193.c:1.3 src/tests/usr.bin/xlint/lint1/msg_193.c:1.4 --- src/tests/usr.bin/xlint/lint1/msg_193.c:1.3 Sun Mar 21 14:09:40 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 14:36:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_193.c,v 1.3 2021/03/21 14:09:40 rillig Exp $ */ +/* $NetBSD: msg_193.c,v 1.4 2021/03/21 14:36:59 rillig Exp $ */ # 3 "msg_193.c" // Test for message: statement not reached [193] @@ -52,7 +52,7 @@ test_if_statement(void) reachable(); reachable(); if (0) - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ reachable(); } @@ -71,12 +71,12 @@ test_if_compound_statement(void) } if (0) { - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ } if (0) { { { -unreachable(); /* TODO: expect: 193 */ +unreachable(); /* expect: 193 */ } } } @@ -90,7 +90,7 @@ test_if_without_else(void) reachable(); if (0) - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ reachable(); } @@ -100,11 +100,11 @@ test_if_with_else(void) if (1) reachable(); else - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ reachable(); if (0) - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ else reachable(); reachable(); @@ -115,22 +115,22 @@ test_if_else_if_else(void) { if (1) reachable(); - else if (1) - unreachable(); /* TODO: expect: 193 */ + else if (1) /* expect: 193 */ + unreachable(); else - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ if (0) - unreachable(); /* TODO: expect: 193 */ + unreachable(); /* expect: 193 */ else if (1) reachable(); else - unreachable();
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 14:12:46 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: d_c99_bool_strict.c d_c99_bool_strict.exp Log Message: tests/lint: sync redundant documentation in test for strict bool mode To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c cvs rdiff -u -r1.20 -r1.21 \ 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.24 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.25 --- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.24 Sat Mar 20 17:18:50 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c Sun Mar 21 14:12:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: d_c99_bool_strict.c,v 1.24 2021/03/20 17:18:50 rillig Exp $ */ +/* $NetBSD: d_c99_bool_strict.c,v 1.25 2021/03/21 14:12:46 rillig Exp $ */ # 3 "d_c99_bool_strict.c" /* @@ -31,8 +31,9 @@ * * strict-bool-operand-unary: * Operator bool? scalar? - * ! yes no - * The other binary operators do not accept bool operands. + * ! yes - + * & yes yes + * The other unary operators do not accept bool operands. * * strict-bool-operand-binary: * Operator left: bool? other? right: bool? other? @@ -405,7 +406,7 @@ strict_bool_controlling_expression(bool * Operator bool? scalar? * ! yes - * & yes yes - * The other binary operators do not accept bool operands. + * The other unary operators do not accept bool operands. */ void Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.20 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.21 --- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.20 Sat Mar 20 17:18:50 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp Sun Mar 21 14:12:46 2021 @@ -1,152 +1,151 @@ -d_c99_bool_strict.c(126): argument #1 expects '_Bool', gets passed 'int' [334] d_c99_bool_strict.c(127): argument #1 expects '_Bool', gets passed 'int' [334] d_c99_bool_strict.c(128): argument #1 expects '_Bool', gets passed 'int' [334] -d_c99_bool_strict.c(133): warning: constant in conditional context [161] -d_c99_bool_strict.c(136): warning: constant in conditional context [161] -d_c99_bool_strict.c(139): left operand of '?' must be bool, not 'int' [331] -d_c99_bool_strict.c(142): left operand of '?' must be bool, not 'int' [331] -d_c99_bool_strict.c(145): left operand of '?' must be bool, not 'int' [331] -d_c99_bool_strict.c(148): left operand of '?' must be bool, not 'int' [331] -d_c99_bool_strict.c(158): left operand of '?' must be bool, not 'int' [331] +d_c99_bool_strict.c(129): argument #1 expects '_Bool', gets passed 'int' [334] +d_c99_bool_strict.c(134): warning: constant in conditional context [161] +d_c99_bool_strict.c(137): warning: constant in conditional context [161] +d_c99_bool_strict.c(140): left operand of '?' must be bool, not 'int' [331] +d_c99_bool_strict.c(143): left operand of '?' must be bool, not 'int' [331] +d_c99_bool_strict.c(146): left operand of '?' must be bool, not 'int' [331] +d_c99_bool_strict.c(149): left operand of '?' must be bool, not 'int' [331] d_c99_bool_strict.c(159): left operand of '?' must be bool, not 'int' [331] -d_c99_bool_strict.c(162): warning: constant in conditional context [161] -d_c99_bool_strict.c(168): warning: constant in conditional context [161] -d_c99_bool_strict.c(168): left operand of '?' must be bool, not 'int' [331] -d_c99_bool_strict.c(170): integral constant expression expected [55] -d_c99_bool_strict.c(173): integral constant expression expected [55] -d_c99_bool_strict.c(176): integral constant expression expected [55] -d_c99_bool_strict.c(179): warning: constant in conditional context [161] -d_c99_bool_strict.c(179): integral constant expression expected [55] -d_c99_bool_strict.c(180): left operand of '||' must be bool, not 'int' [331] -d_c99_bool_strict.c(180): right operand of '||' must be bool, not 'int' [332] -d_c99_bool_strict.c(182): warning: constant in conditional context [161] -d_c99_bool_strict.c(182): integral constant expression expected [55] -d_c99_bool_strict.c(183): left operand of '&&' must be bool, not 'int' [331] -d_c99_bool_strict.c(183): right operand of '&&' must be bool, not 'int' [332] -d_c99_bool_strict.c(203): operands of '=' have incompatible types (_Bool != unsigned int) [107] -d_c99_bool_strict.c(205): operands of '=' have incompatible types (unsigned int != _Bool) [107] -d_c99_bool_strict.c(208): operands of '=' have incompatible types (_Bool != unsigned int) [107] -d_c99_bool_strict.c(210): operands of '=' have incompatible types (unsigned int != _Bool) [107] -d_c99_bool_strict.c(252): return value type mismatch (_Bool) and (int) [211]
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 14:09:41 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_193.c msg_193.exp Log Message: tests/lint: add tests for reachability of statements Right now, reachability is only implemented for loops, but not for selection statements. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_193.c \ src/tests/usr.bin/xlint/lint1/msg_193.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/msg_193.c diff -u src/tests/usr.bin/xlint/lint1/msg_193.c:1.2 src/tests/usr.bin/xlint/lint1/msg_193.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_193.c:1.2 Sat Jan 30 17:56:29 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 14:09:40 2021 @@ -1,10 +1,497 @@ -/* $NetBSD: msg_193.c,v 1.2 2021/01/30 17:56:29 rillig Exp $ */ +/* $NetBSD: msg_193.c,v 1.3 2021/03/21 14:09:40 rillig Exp $ */ # 3 "msg_193.c" // Test for message: statement not reached [193] -void example(void) +/* + * Test the reachability of statements in a function. + * + * if + * if-else + * if-else-if-else + * for + * while + * do-while + * switch + * break + * continue + * goto + * return + * + * constant expression + * system-dependent constant expression + */ + +extern void +reachable(void); +extern void +unreachable(void); + +void +test_statement(void) +{ + reachable(); + reachable(); +} + +void +test_compound_statement(void) +{ + reachable(); + { + reachable(); + reachable(); + } + reachable(); +} + +void +test_if_statement(void) +{ + if (1) + reachable(); + reachable(); + if (0) + unreachable(); /* TODO: expect: 193 */ + reachable(); +} + +void +test_if_compound_statement(void) +{ + if (1) { + reachable(); + } + if (1) { + { + { +reachable(); + } + } + } + + if (0) { + unreachable(); /* TODO: expect: 193 */ + } + if (0) { + { + { +unreachable(); /* TODO: expect: 193 */ + } + } + } +} + +void +test_if_without_else(void) +{ + if (1) + reachable(); + reachable(); + + if (0) + unreachable(); /* TODO: expect: 193 */ + reachable(); +} + +void +test_if_with_else(void) +{ + if (1) + reachable(); + else + unreachable(); /* TODO: expect: 193 */ + reachable(); + + if (0) + unreachable(); /* TODO: expect: 193 */ + else + reachable(); + reachable(); +} + +void +test_if_else_if_else(void) +{ + if (1) + reachable(); + else if (1) + unreachable(); /* TODO: expect: 193 */ + else + unreachable(); /* TODO: expect: 193 */ + + if (0) + unreachable(); /* TODO: expect: 193 */ + else if (1) + reachable(); + else + unreachable(); /* TODO: expect: 193 */ + + if (0) + unreachable(); /* TODO: expect: 193 */ + else if (0) + unreachable(); /* TODO: expect: 193 */ + else + reachable(); +} + +void +test_if_return(void) +{ + if (1) + return; + unreachable(); /* TODO: expect: 193 */ +} + +void +test_if_else_return(void) +{ + if (1) + reachable(); + else + return; + reachable(); +} + +void +test_for_forever(void) +{ + for (;;) + reachable(); + unreachable(); /* expect: 193 */ +} + +void +test_for_true(void) +{ + for (; 1;) + reachable(); + unreachable(); /* expect: 193 */ +} + +void +test_for_false(void) +{ + for (; 0;) + unreachable(); /* TODO: expect: 193 */ + reachable(); +} + +void +test_for_break(void) +{ + for (;;) { + reachable(); + break; + unreachable(); /* expect: 193 */ + } + reachable(); +} + +void +test_for_if_break(void) +{ + for (;;) { + reachable(); + if (0) { + unreachable(); /* TODO: expect: 193 */ + break; + unreachable(); /* expect: 193 */ + } + if (1) { + reachable(); + break; + unreachable(); /* expect: 193 */ + } + unreachable(); /* TODO: expect: 193 */ + } + reachable(); +} + +void +test_for_continue(void) +{ + for (;;) { + reachable(); + continue; + unreachable(); /* expect: 193 */ + } + unreachable(); /* expect: 193 */ +} + +void +test_for_if_continue(void) +{ + for (;;) { + reachable(); + if (0) { + unreachable(); /* TODO: expect: 193 */ + continue; + unreachable(); /* expect: 193 */ + } + if (1) { + reachable(); + continue; + unreachable(); /* expect: 193 */ + } + unreachable(); /* TODO: expect: 193 */ + } + unreachable(); /* expect: 193 */ +} + +void +test_for_return(void) { - return; - return; /* expect: 193 */ + for (;;) { + reachable(); + return; + unreachable(); /* expect: 193 */ + } + unreachable(); /* expect: 193 */ } + +void +test_for_if_return(void) +{ + for (;;) { + reachable(); + if (0) { + unreachable(); /* TODO: expect: 193 */ + return; + unreachable(); /* expect: 193 */ + } + if (1) { + reachable(); + return; + unreachable(); /* expect: 193 */ + } + unreachable(); /* TODO: expect: 193 */ + } + unreachable(); /* expect: 193 */ +} + +void +test_while_true(void) +{ + while (1) + reachable(); + unreachable(); /* expect: 193 */ +} + +void
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 13:10:58 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: Makefile Log Message: lint: add missing space when adding a new test case To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 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.63 src/usr.bin/xlint/lint1/Makefile:1.64 --- src/usr.bin/xlint/lint1/Makefile:1.63 Sat Mar 20 19:33:25 2021 +++ src/usr.bin/xlint/lint1/Makefile Sun Mar 21 13:10:58 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.63 2021/03/20 19:33:25 rillig Exp $ +# $NetBSD: Makefile,v 1.64 2021/03/21 13:10:58 rillig Exp $ .include @@ -68,7 +68,7 @@ add-test: .PHONY '' \ '/*' \ ' * TODO: Explain the purpose of the test.' \ - '*/' \ + ' */' \ '' \ '/* lint1-extra-flags: -p */' \ '' \
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 13:03:42 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: func.c lint1.h Log Message: lint: rename c_rchif to c_reached_end_of_then No functional change. To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.84 -r1.85 src/usr.bin/xlint/lint1/lint1.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/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.86 src/usr.bin/xlint/lint1/func.c:1.87 --- src/usr.bin/xlint/lint1/func.c:1.86 Sun Mar 21 12:10:27 2021 +++ src/usr.bin/xlint/lint1/func.c Sun Mar 21 13:03:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.86 2021/03/21 12:10:27 rillig Exp $ */ +/* $NetBSD: func.c,v 1.87 2021/03/21 13:03:42 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.86 2021/03/21 12:10:27 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.87 2021/03/21 13:03:42 rillig Exp $"); #endif #include @@ -615,8 +615,8 @@ void if2(void) { - cstmt->c_rchif = reached; - reached = true; + cstmt->c_reached_end_of_then = reached; + reached = true; /* XXX: sure? */ } /* @@ -628,7 +628,7 @@ if3(bool els) { if (els) { - reached |= cstmt->c_rchif; + reached |= cstmt->c_reached_end_of_then; } else { reached = true; } Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.84 src/usr.bin/xlint/lint1/lint1.h:1.85 --- src/usr.bin/xlint/lint1/lint1.h:1.84 Sun Mar 21 12:08:34 2021 +++ src/usr.bin/xlint/lint1/lint1.h Sun Mar 21 13:03:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.84 2021/03/21 12:08:34 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.85 2021/03/21 13:03:42 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -393,7 +393,7 @@ typedef struct control_statement { * always true (as in 'for (;;)' or * 'while (1)'), there may be break * statements though */ - bool c_rchif : 1; /* end of if-branch reached */ + bool c_reached_end_of_then : 1; bool c_had_return_noval : 1; /* had "return;" */ bool c_had_return_value : 1; /* had "return (e);" */ type_t *c_swtype; /* type of switch expression */
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 12:19:37 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_217.c msg_217.exp Log Message: tests/lint: demonstrate bug in endless loop detection To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_217.c cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_217.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/msg_217.c diff -u src/tests/usr.bin/xlint/lint1/msg_217.c:1.6 src/tests/usr.bin/xlint/lint1/msg_217.c:1.7 --- src/tests/usr.bin/xlint/lint1/msg_217.c:1.6 Sun Mar 21 11:55:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_217.c Sun Mar 21 12:19:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_217.c,v 1.6 2021/03/21 11:55:59 rillig Exp $ */ +/* $NetBSD: msg_217.c,v 1.7 2021/03/21 12:19:36 rillig Exp $ */ # 3 "msg_217.c" // Test for message: function %s falls off bottom without returning value [217] @@ -46,3 +46,23 @@ int main(void) { } + +int +reachable_continue_leads_to_endless_loop(void) +{ + for (;;) { + if (1) + continue; + break; + } +}/* FIXME *//* expect: 217 */ + +int +unreachable_continue_falls_through(void) +{ + for (;;) { + if (0) + continue; + break; + } +}/* expect: 217 */ Index: src/tests/usr.bin/xlint/lint1/msg_217.exp diff -u src/tests/usr.bin/xlint/lint1/msg_217.exp:1.5 src/tests/usr.bin/xlint/lint1/msg_217.exp:1.6 --- src/tests/usr.bin/xlint/lint1/msg_217.exp:1.5 Sun Mar 21 11:55:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_217.exp Sun Mar 21 12:19:36 2021 @@ -1 +1,3 @@ msg_217.c(11): warning: function random falls off bottom without returning value [217] +msg_217.c(58): warning: function reachable_continue_leads_to_endless_loop falls off bottom without returning value [217] +msg_217.c(68): warning: function unreachable_continue_falls_through falls off bottom without returning value [217]
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 12:10:27 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: func.c Log Message: lint: document why an unreachable statement is set to reachable No functional change. To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/usr.bin/xlint/lint1/func.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.85 src/usr.bin/xlint/lint1/func.c:1.86 --- src/usr.bin/xlint/lint1/func.c:1.85 Sun Mar 21 12:08:34 2021 +++ src/usr.bin/xlint/lint1/func.c Sun Mar 21 12:10:27 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.85 2021/03/21 12:08:34 rillig Exp $ */ +/* $NetBSD: func.c,v 1.86 2021/03/21 12:10:27 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.85 2021/03/21 12:08:34 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.86 2021/03/21 12:10:27 rillig Exp $"); #endif #include @@ -196,7 +196,7 @@ check_statement_reachable(void) if (!reached && !rchflg) { /* statement not reached */ warning(193); - reached = true; + reached = true; /* only to suppress further warnings */ } }
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 12:08:34 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: func.c lint1.h Log Message: lint: rename c_cont to c_continue No functional change. To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.85 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.83 -r1.84 src/usr.bin/xlint/lint1/lint1.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/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.84 src/usr.bin/xlint/lint1/func.c:1.85 --- src/usr.bin/xlint/lint1/func.c:1.84 Sun Mar 21 12:03:56 2021 +++ src/usr.bin/xlint/lint1/func.c Sun Mar 21 12:08:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.84 2021/03/21 12:03:56 rillig Exp $ */ +/* $NetBSD: func.c,v 1.85 2021/03/21 12:08:34 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.84 2021/03/21 12:03:56 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.85 2021/03/21 12:08:34 rillig Exp $"); #endif #include @@ -815,7 +815,7 @@ do2(tnode_t *tn) * If there was a continue statement, the expression controlling the * loop is reached. */ - if (cstmt->c_cont) + if (cstmt->c_continue) reached = true; if (tn != NULL) @@ -823,7 +823,7 @@ do2(tnode_t *tn) if (tn != NULL && tn->tn_op == CON) { cstmt->c_maybe_endless = constant_is_nonzero(tn); - if (!cstmt->c_maybe_endless && cstmt->c_cont) + if (!cstmt->c_maybe_endless && cstmt->c_continue) /* continue in 'do ... while (0)' loop */ error(323); } @@ -895,7 +895,7 @@ for2(void) pos_t cpos, cspos; tnode_t *tn3; - if (cstmt->c_cont) + if (cstmt->c_continue) reached = true; cpos = curr_pos; @@ -986,7 +986,8 @@ docont(void) /* continue outside loop */ error(209); } else { - ci->c_cont = true; + /* TODO: only if reachable, for symmetry with c_break */ + ci->c_continue = true; } check_statement_reachable(); Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.83 src/usr.bin/xlint/lint1/lint1.h:1.84 --- src/usr.bin/xlint/lint1/lint1.h:1.83 Sun Mar 21 12:06:10 2021 +++ src/usr.bin/xlint/lint1/lint1.h Sun Mar 21 12:08:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.83 2021/03/21 12:06:10 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.84 2021/03/21 12:08:34 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -387,7 +387,7 @@ typedef struct control_statement { bool c_switch : 1; /* case && break are valid */ bool c_break : 1; /* the loop/switch has a reachable * break statement */ - bool c_cont : 1; /* loop has continue */ + bool c_continue : 1; /* loop has continue */ bool c_default : 1; /* switch has default */ bool c_maybe_endless : 1; /* the controlling expression is * always true (as in 'for (;;)' or
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 12:06:10 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: lint1.h Log Message: lint: document the precise meaning of control_statement.c_break No functional change. To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/usr.bin/xlint/lint1/lint1.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/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.82 src/usr.bin/xlint/lint1/lint1.h:1.83 --- src/usr.bin/xlint/lint1/lint1.h:1.82 Sun Mar 21 12:03:56 2021 +++ src/usr.bin/xlint/lint1/lint1.h Sun Mar 21 12:06:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.82 2021/03/21 12:03:56 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.83 2021/03/21 12:06:10 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -385,9 +385,8 @@ typedef struct control_statement { int c_env; /* type of statement (T_IF, ...) */ bool c_loop : 1; /* continue && break are valid */ bool c_switch : 1; /* case && break are valid */ - bool c_break : 1; /* loop/switch has break */ - /* TODO: is the break guaranteed to be - * reachable? */ + bool c_break : 1; /* the loop/switch has a reachable + * break statement */ bool c_cont : 1; /* loop has continue */ bool c_default : 1; /* switch has default */ bool c_maybe_endless : 1; /* the controlling expression is
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 12:03:56 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: func.c lint1.h Log Message: lint: rename i_infinite to i_maybe_endless Not every loop that has 'while (1)' is an endless loop. It may still contain a 'return' somewhere. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.81 -r1.82 src/usr.bin/xlint/lint1/lint1.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/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.83 src/usr.bin/xlint/lint1/func.c:1.84 --- src/usr.bin/xlint/lint1/func.c:1.83 Sun Mar 21 11:55:59 2021 +++ src/usr.bin/xlint/lint1/func.c Sun Mar 21 12:03:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.83 2021/03/21 11:55:59 rillig Exp $ */ +/* $NetBSD: func.c,v 1.84 2021/03/21 12:03:56 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.83 2021/03/21 11:55:59 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.84 2021/03/21 12:03:56 rillig Exp $"); #endif #include @@ -761,7 +761,7 @@ while1(tnode_t *tn) pushctrl(T_WHILE); cstmt->c_loop = true; if (tn != NULL && tn->tn_op == CON) - cstmt->c_infinite = constant_is_nonzero(tn); + cstmt->c_maybe_endless = constant_is_nonzero(tn); check_getopt_begin_while(tn); expr(tn, false, true, true, false); @@ -779,7 +779,7 @@ while2(void) * The end of the loop can be reached if it is no endless loop * or there was a break statement which was reached. */ - reached = !cstmt->c_infinite || cstmt->c_break; + reached = !cstmt->c_maybe_endless || cstmt->c_break; rchflg = false; check_getopt_end_while(); @@ -822,15 +822,15 @@ do2(tnode_t *tn) tn = check_controlling_expression(tn); if (tn != NULL && tn->tn_op == CON) { - cstmt->c_infinite = constant_is_nonzero(tn); - if (!cstmt->c_infinite && cstmt->c_cont) + cstmt->c_maybe_endless = constant_is_nonzero(tn); + if (!cstmt->c_maybe_endless && cstmt->c_cont) /* continue in 'do ... while (0)' loop */ error(323); } expr(tn, false, true, true, true); - if (cstmt->c_infinite) + if (cstmt->c_maybe_endless) reached = false; if (cstmt->c_break) reached = true; @@ -877,7 +877,7 @@ for1(tnode_t *tn1, tnode_t *tn2, tnode_t if (tn2 != NULL) expr(tn2, false, true, true, false); - cstmt->c_infinite = + cstmt->c_maybe_endless = tn2 == NULL || (tn2->tn_op == CON && constant_is_nonzero(tn2)); /* Checking the reinitialization expression is done in for2() */ @@ -924,7 +924,8 @@ for2(void) csrc_pos = cspos; /* An endless loop without break will never terminate */ - reached = cstmt->c_break || !cstmt->c_infinite; + /* TODO: What if the loop contains a 'return'? */ + reached = cstmt->c_break || !cstmt->c_maybe_endless; rchflg = false; popctrl(T_FOR); Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.81 src/usr.bin/xlint/lint1/lint1.h:1.82 --- src/usr.bin/xlint/lint1/lint1.h:1.81 Sun Mar 21 11:55:59 2021 +++ src/usr.bin/xlint/lint1/lint1.h Sun Mar 21 12:03:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.81 2021/03/21 11:55:59 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.82 2021/03/21 12:03:56 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -390,11 +390,10 @@ typedef struct control_statement { * reachable? */ bool c_cont : 1; /* loop has continue */ bool c_default : 1; /* switch has default */ - bool c_infinite : 1; /* controlling expression always false - * (as in for (;;) or while (1)), - * there may be break statements - * though. - * TODO: rename to c_maybe_infinite */ + bool c_maybe_endless : 1; /* the controlling expression is + * always true (as in 'for (;;)' or + * 'while (1)'), there may be break + * statements though */ bool c_rchif : 1; /* end of if-branch reached */ bool c_had_return_noval : 1; /* had "return;" */ bool c_had_return_value : 1; /* had "return (e);" */
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Mar 21 11:55:59 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_217.c msg_217.exp src/usr.bin/xlint/lint1: func.c lint1.h Log Message: lint: fix wrong 'falls off bottom' after return in do-while To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_217.c cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_217.exp cvs rdiff -u -r1.82 -r1.83 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.80 -r1.81 src/usr.bin/xlint/lint1/lint1.h 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_217.c diff -u src/tests/usr.bin/xlint/lint1/msg_217.c:1.5 src/tests/usr.bin/xlint/lint1/msg_217.c:1.6 --- src/tests/usr.bin/xlint/lint1/msg_217.c:1.5 Sun Mar 21 11:48:04 2021 +++ src/tests/usr.bin/xlint/lint1/msg_217.c Sun Mar 21 11:55:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_217.c,v 1.5 2021/03/21 11:48:04 rillig Exp $ */ +/* $NetBSD: msg_217.c,v 1.6 2021/03/21 11:55:59 rillig Exp $ */ # 3 "msg_217.c" // Test for message: function %s falls off bottom without returning value [217] @@ -23,6 +23,9 @@ random(int n) * 'while 0' was unreachable. This has been fixed by allowing the 'while 0' * in a do-while-false loop to be unreachable. The same could be useful for a * do-while-true. + * + * Before func.c 1.83 from 2021-03-21, lint wrongly reported that the function + * would fall off the bottom. */ int do_while_return(int i) @@ -30,7 +33,7 @@ do_while_return(int i) do { return i; } while (0); -} /*FIXME*//* expect: 217 */ +} /* * C99 5.1.2.2.3 "Program termination" p1 defines that as a special exception, Index: src/tests/usr.bin/xlint/lint1/msg_217.exp diff -u src/tests/usr.bin/xlint/lint1/msg_217.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_217.exp:1.5 --- src/tests/usr.bin/xlint/lint1/msg_217.exp:1.4 Sun Mar 21 11:48:04 2021 +++ src/tests/usr.bin/xlint/lint1/msg_217.exp Sun Mar 21 11:55:59 2021 @@ -1,2 +1 @@ msg_217.c(11): warning: function random falls off bottom without returning value [217] -msg_217.c(33): warning: function do_while_return falls off bottom without returning value [217] Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.82 src/usr.bin/xlint/lint1/func.c:1.83 --- src/usr.bin/xlint/lint1/func.c:1.82 Sun Mar 21 11:38:24 2021 +++ src/usr.bin/xlint/lint1/func.c Sun Mar 21 11:55:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.82 2021/03/21 11:38:24 rillig Exp $ */ +/* $NetBSD: func.c,v 1.83 2021/03/21 11:55:59 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.82 2021/03/21 11:38:24 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.83 2021/03/21 11:55:59 rillig Exp $"); #endif #include @@ -830,11 +830,10 @@ do2(tnode_t *tn) expr(tn, false, true, true, true); - /* - * The end of the loop is only reached if it is no endless loop - * or there was a break statement which could be reached. - */ - reached = !cstmt->c_infinite || cstmt->c_break; + if (cstmt->c_infinite) + reached = false; + if (cstmt->c_break) + reached = true; rchflg = false; popctrl(T_DO); Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.80 src/usr.bin/xlint/lint1/lint1.h:1.81 --- src/usr.bin/xlint/lint1/lint1.h:1.80 Sun Mar 21 10:30:28 2021 +++ src/usr.bin/xlint/lint1/lint1.h Sun Mar 21 11:55:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.80 2021/03/21 10:30:28 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.81 2021/03/21 11:55:59 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -386,10 +386,15 @@ typedef struct control_statement { bool c_loop : 1; /* continue && break are valid */ bool c_switch : 1; /* case && break are valid */ bool c_break : 1; /* loop/switch has break */ + /* TODO: is the break guaranteed to be + * reachable? */ bool c_cont : 1; /* loop has continue */ bool c_default : 1; /* switch has default */ - bool c_infinite : 1; /* break condition always false - (for (;;), while (1)) */ + bool c_infinite : 1; /* controlling expression always false + * (as in for (;;) or while (1)), + * there may be break statements + * though. + * TODO: rename to c_maybe_infinite */ bool c_rchif : 1; /* end of if-branch reached */ bool c_had_return_noval : 1; /* had "return;" */ bool c_had_return_value : 1; /* had "return (e);" */
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Mar 21 11:48:04 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_217.c msg_217.exp src/usr.bin/xlint/lint1: tree.c Log Message: lint: fix wrong 'statement not reached' in do-while loop To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_217.c cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_217.exp cvs rdiff -u -r1.242 -r1.243 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_217.c diff -u src/tests/usr.bin/xlint/lint1/msg_217.c:1.4 src/tests/usr.bin/xlint/lint1/msg_217.c:1.5 --- src/tests/usr.bin/xlint/lint1/msg_217.c:1.4 Sun Feb 21 09:17:55 2021 +++ src/tests/usr.bin/xlint/lint1/msg_217.c Sun Mar 21 11:48:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_217.c,v 1.4 2021/02/21 09:17:55 rillig Exp $ */ +/* $NetBSD: msg_217.c,v 1.5 2021/03/21 11:48:04 rillig Exp $ */ # 3 "msg_217.c" // Test for message: function %s falls off bottom without returning value [217] @@ -19,16 +19,17 @@ random(int n) * Seen in external/bsd/libevent/dist/event_tagging.c, function * encode_int_internal. * - * As of 2021-01-31, lint wrongly reports that the function would fall off - * the bottom, but it cannot reach the bottom since every path contains the - * 'return i'. + * Before tree.c 1.243 from 2021-03-21, lint wrongly reported that the + * 'while 0' was unreachable. This has been fixed by allowing the 'while 0' + * in a do-while-false loop to be unreachable. The same could be useful for a + * do-while-true. */ int do_while_return(int i) { do { return i; - } while (/*CONSTCOND*/0); /*FIXME*//* expect: 193 */ + } while (0); } /*FIXME*//* expect: 217 */ /* Index: src/tests/usr.bin/xlint/lint1/msg_217.exp diff -u src/tests/usr.bin/xlint/lint1/msg_217.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_217.exp:1.4 --- src/tests/usr.bin/xlint/lint1/msg_217.exp:1.3 Sun Jan 31 13:33:10 2021 +++ src/tests/usr.bin/xlint/lint1/msg_217.exp Sun Mar 21 11:48:04 2021 @@ -1,3 +1,2 @@ msg_217.c(11): warning: function random falls off bottom without returning value [217] -msg_217.c(31): warning: statement not reached [193] -msg_217.c(32): warning: function do_while_return falls off bottom without returning value [217] +msg_217.c(33): warning: function do_while_return falls off bottom without returning value [217] Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.242 src/usr.bin/xlint/lint1/tree.c:1.243 --- src/usr.bin/xlint/lint1/tree.c:1.242 Sat Mar 20 21:08:09 2021 +++ src/usr.bin/xlint/lint1/tree.c Sun Mar 21 11:48:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.242 2021/03/20 21:08:09 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.243 2021/03/21 11:48:04 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.242 2021/03/20 21:08:09 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.243 2021/03/21 11:48:04 rillig Exp $"); #endif #include @@ -3777,7 +3777,8 @@ expr(tnode_t *tn, bool vctx, bool tctx, } /* expr() is also called in global initializations */ - if (dcs->d_ctx != EXTERN) + /* TODO: rename constcond_false_ok */ + if (dcs->d_ctx != EXTERN && !constcond_false_ok) check_statement_reachable(); check_expr_misc(tn, vctx, tctx, !tctx, false, false, false);
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 11:38:24 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: func.c Log Message: lint: remove redundant braces in doreturn No functional change. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/usr.bin/xlint/lint1/func.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.81 src/usr.bin/xlint/lint1/func.c:1.82 --- src/usr.bin/xlint/lint1/func.c:1.81 Sun Mar 21 10:30:28 2021 +++ src/usr.bin/xlint/lint1/func.c Sun Mar 21 11:38:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.81 2021/03/21 10:30:28 rillig Exp $ */ +/* $NetBSD: func.c,v 1.82 2021/03/21 11:38:24 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.81 2021/03/21 10:30:28 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.82 2021/03/21 11:38:24 rillig Exp $"); #endif #include @@ -1008,11 +1008,10 @@ doreturn(tnode_t *tn) for (ci = cstmt; ci->c_surrounding != NULL; ci = ci->c_surrounding) continue; - if (tn != NULL) { + if (tn != NULL) ci->c_had_return_value = true; - } else { + else ci->c_had_return_noval = true; - } if (tn != NULL && funcsym->s_type->t_subt->t_tspec == VOID) { /* void function %s cannot return value */
CVS commit: src/usr.bin/audio/ctl
Module Name:src Committed By: nia Date: Sun Mar 21 10:50:08 UTC 2021 Modified Files: src/usr.bin/audio/ctl: audioctl.1 Log Message: audioctl.1: describe foibles To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/usr.bin/audio/ctl/audioctl.1 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/audio/ctl/audioctl.1 diff -u src/usr.bin/audio/ctl/audioctl.1:1.23 src/usr.bin/audio/ctl/audioctl.1:1.24 --- src/usr.bin/audio/ctl/audioctl.1:1.23 Thu May 9 09:37:11 2019 +++ src/usr.bin/audio/ctl/audioctl.1 Sun Mar 21 10:50:08 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: audioctl.1,v 1.23 2019/05/09 09:37:11 wiz Exp $ +.\" $NetBSD: audioctl.1,v 1.24 2021/03/21 10:50:08 nia Exp $ .\" .\" Copyright (c) 1997, 1999 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -26,12 +26,12 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd May 8, 2019 +.Dd March 21, 2021 .Dt AUDIOCTL 1 .Os .Sh NAME .Nm audioctl -.Nd control audio device +.Nd control software audio format .Sh SYNOPSIS .Nm .Op Fl n @@ -49,7 +49,26 @@ .Sh DESCRIPTION The .Nm -command displays or sets various audio system driver variables. +command displays or sets the paramaters that determine the playback and +recording format for software using a audio device. +It is most useful when the full +.Xr audio 4 +API is not available, e.g. when playing or recording raw audio data from a +.Xr sh 1 +script, or from the command line. +It does not control the underlying hardware format, which can be +changed with +.Xr audiocfg 1 . +.Pp +The variables that can be inspected and changed with +.Nm +are normally per-application and are reset when a +.Pa /dev/audioX +device is opened. +This can be circumvented by using +.Pa /dev/soundX +instead, which retains global state. +.Pp If a list of variables is present on the command line, then .Nm prints the current value of those variables for the specified device. @@ -77,32 +96,23 @@ the audio control device to use. .El .Sh FILES .Bl -tag -width /dev/audioctl0 -compact -.It Pa /dev/audio0 -audio I/O device (resets on open) +.It Pa /dev/sound0 +audio I/O device .It Pa /dev/audioctl0 audio control device -.It Pa /dev/sound0 -audio I/O device (does not reset on open) .El .Sh EXAMPLES To set the playing sampling rate to 11025, you can use .Dl audioctl -w play.sample_rate=11025 To set all of the play parameters for CD-quality audio, you can use .Dl audioctl -w play=44100,2,16,slinear_le -Note that many of the variables that can be inspected and changed with -.Nm -are reset when -.Pa /dev/audio0 -is opened. -This can be circumvented by using -.Pa /dev/sound0 -instead. .Sh COMPATIBILITY The old .Fl f flag is still supported. This support will be removed eventually. .Sh SEE ALSO +.Xr audiocfg 1 , .Xr audioplay 1 , .Xr audiorecord 1 , .Xr mixerctl 1 , @@ -113,3 +123,21 @@ The .Nm command first appeared in .Nx 1.3 . +.Sh CAVEATS +Since the parameters controlled by +.Nm +are global, they can be changed unexpectedly if another application +uses the same audio device. +.Pp +It is always preferable to use +.Dv AUDIO_SETINFO +on a per-process +.Pa /dev/audioX +device, if the +.Xr audio 4 +ioctls are available in the programming environment. +Similarly, +.Xr audioplay 1 +and +.Xr audiorecord 1 +are more safe for use in scripting.
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 10:43:08 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_174.c Log Message: tests/lint: clarify that a brace-enclosed initializer needs an expr To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_174.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_174.c diff -u src/tests/usr.bin/xlint/lint1/msg_174.c:1.3 src/tests/usr.bin/xlint/lint1/msg_174.c:1.4 --- src/tests/usr.bin/xlint/lint1/msg_174.c:1.3 Sun Jan 31 11:12:07 2021 +++ src/tests/usr.bin/xlint/lint1/msg_174.c Sun Mar 21 10:43:08 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_174.c,v 1.3 2021/01/31 11:12:07 rillig Exp $ */ +/* $NetBSD: msg_174.c,v 1.4 2021/03/21 10:43:08 rillig Exp $ */ # 3 "msg_174.c" // Test for message: too many initializers [174] @@ -11,6 +11,9 @@ example(void) int too_many = { 17, 19 }; /* expect: 174 */ - /* XXX: Double-check with C99, this might be allowed. */ + /* + * An initializer list must have at least one expression, says the + * syntax definition in C99 6.7.8. + */ int too_few = {}; }
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 10:30:28 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c func.c lint1.h Log Message: lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated No functional change. To generate a diff of this commit: cvs rdiff -u -r1.155 -r1.156 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.80 -r1.81 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.79 -r1.80 src/usr.bin/xlint/lint1/lint1.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.155 src/usr.bin/xlint/lint1/decl.c:1.156 --- src/usr.bin/xlint/lint1/decl.c:1.155 Sun Mar 21 10:25:40 2021 +++ src/usr.bin/xlint/lint1/decl.c Sun Mar 21 10:30:28 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.155 2021/03/21 10:25:40 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.156 2021/03/21 10:30:28 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.155 2021/03/21 10:25:40 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.156 2021/03/21 10:30:28 rillig Exp $"); #endif #include @@ -639,8 +639,8 @@ popdecl(void) * parameter type list. */ if (di->d_dlsyms != NULL) { - *di->d_ldlsym = dcs->d_fpsyms; - dcs->d_fpsyms = di->d_dlsyms; + *di->d_ldlsym = dcs->d_func_proto_syms; + dcs->d_func_proto_syms = di->d_dlsyms; } break; case ABSTRACT: @@ -1396,16 +1396,16 @@ add_function(sym_t *decl, sym_t *args) * The symbols are removed from the symbol table by popdecl() after * add_function(). To be able to restore them if this is a function * definition, a pointer to the list of all symbols is stored in - * dcs->d_next->d_fpsyms. Also a list of the arguments (concatenated - * by s_next) is stored in dcs->d_next->d_fargs. + * dcs->d_next->d_func_proto_syms. Also a list of the arguments + * (concatenated by s_next) is stored in dcs->d_next->d_func_args. * (dcs->d_next must be used because *dcs is the declaration stack * element created for the list of params and is removed after * add_function()) */ if (dcs->d_next->d_ctx == EXTERN && decl->s_type == dcs->d_next->d_type) { - dcs->d_next->d_fpsyms = dcs->d_dlsyms; - dcs->d_next->d_fargs = args; + dcs->d_next->d_func_proto_syms = dcs->d_dlsyms; + dcs->d_next->d_func_args = args; } tpp = >s_type; @@ -1602,7 +1602,7 @@ declarator_name(sym_t *sym) sym->s_type = dcs->d_type; - dcs->d_fpsyms = NULL; + dcs->d_func_proto_syms = NULL; return sym; } @@ -2483,7 +2483,7 @@ check_func_lint_directives(void) * number of arguments. */ narg = 0; - for (arg = dcs->d_fargs; arg != NULL; arg = arg->s_next) + for (arg = dcs->d_func_args; arg != NULL; arg = arg->s_next) narg++; if (nargusg > narg) { /* argument number mismatch with directive: ** %s ** */ @@ -2512,7 +2512,7 @@ check_func_lint_directives(void) if (printflike_argnum != -1 || scanflike_argnum != -1) { narg = printflike_argnum != -1 ? printflike_argnum : scanflike_argnum; - arg = dcs->d_fargs; + arg = dcs->d_func_args; for (n = 1; n < narg; n++) arg = arg->s_next; if (arg->s_type->t_tspec != PTR || Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.80 src/usr.bin/xlint/lint1/func.c:1.81 --- src/usr.bin/xlint/lint1/func.c:1.80 Sun Mar 21 10:21:07 2021 +++ src/usr.bin/xlint/lint1/func.c Sun Mar 21 10:30:28 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.80 2021/03/21 10:21:07 rillig Exp $ */ +/* $NetBSD: func.c,v 1.81 2021/03/21 10:30:28 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.80 2021/03/21 10:21:07 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.81 2021/03/21 10:30:28 rillig Exp $"); #endif #include @@ -223,7 +223,7 @@ funcdef(sym_t *fsym) * Put all symbols declared in the argument list back to the * symbol table. */ - for (sym = dcs->d_fpsyms; sym != NULL; sym = sym->s_dlnxt) { + for (sym = dcs->d_func_proto_syms; sym != NULL; sym = sym->s_dlnxt) { if (sym->s_block_level != -1) { lint_assert(sym->s_block_level == 1); inssym(1, sym); @@ -282,7 +282,7 @@ funcdef(sym_t *fsym) * if this is an old style definition and we had already a * prototype. */ - dcs->d_fdpos = fsym->s_def_pos; + dcs->d_func_def_pos = fsym->s_def_pos; if ((rdsym = dcs->d_redeclared_symbol) != NULL) { @@ -378,7 +378,7 @@ funcend(void) warning(216, funcsym->s_name); /* Print warnings for unused arguments */ - arg = dcs->d_fargs; + arg = dcs->d_func_args; n = 0; while (arg != NULL && (nargusg == -1 || n < nargusg)) { check_usage_sym(dcs->d_asm, arg); @@ -396,8 +396,9 @@ funcend(void) if (dcs->d_scl == EXTERN && funcsym->s_inline) {
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 10:25:40 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y decl.c lint1.h Log Message: lint: rename d_nedecl to d_nonempty_decl No functional change. To generate a diff of this commit: cvs rdiff -u -r1.194 -r1.195 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.154 -r1.155 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.78 -r1.79 src/usr.bin/xlint/lint1/lint1.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.194 src/usr.bin/xlint/lint1/cgram.y:1.195 --- src/usr.bin/xlint/lint1/cgram.y:1.194 Sun Mar 21 09:54:02 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Mar 21 10:25:40 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.194 2021/03/21 09:54:02 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.195 2021/03/21 10:25:40 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.194 2021/03/21 09:54:02 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.195 2021/03/21 10:25:40 rillig Exp $"); #endif #include @@ -410,7 +410,7 @@ top_level_declaration: /* C99 6.9 calls if (dcs->d_scl == TYPEDEF) { /* typedef declares no type name */ warning(72); - } else if (!dcs->d_nedecl) { + } else if (!dcs->d_nonempty_decl) { /* empty declaration */ warning(2); } @@ -488,7 +488,7 @@ arg_declaration: } | declmods deftyp notype_init_decls T_SEMI | declaration_specifiers deftyp T_SEMI { - if (!dcs->d_nedecl) { + if (!dcs->d_nonempty_decl) { /* empty declaration */ warning(2); } else { @@ -497,7 +497,7 @@ arg_declaration: } } | declaration_specifiers deftyp type_init_decls T_SEMI { - if (dcs->d_nedecl) { + if (dcs->d_nonempty_decl) { /* '%s' declared in argument declaration list */ warning(3, type_name(dcs->d_type)); } @@ -521,7 +521,7 @@ declaration: /* C99 6.7 */ if (dcs->d_scl == TYPEDEF) { /* typedef declares no type name */ warning(72); - } else if (!dcs->d_nedecl) { + } else if (!dcs->d_nonempty_decl) { /* empty declaration */ warning(2); } Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.154 src/usr.bin/xlint/lint1/decl.c:1.155 --- src/usr.bin/xlint/lint1/decl.c:1.154 Sun Mar 21 10:21:07 2021 +++ src/usr.bin/xlint/lint1/decl.c Sun Mar 21 10:25:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.154 2021/03/21 10:21:07 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.155 2021/03/21 10:25:40 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.154 2021/03/21 10:21:07 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.155 2021/03/21 10:25:40 rillig Exp $"); #endif #include @@ -717,7 +717,7 @@ clrtyp(void) dcs->d_inline = false; dcs->d_mscl = false; dcs->d_terr = false; - dcs->d_nedecl = false; + dcs->d_nonempty_decl = false; dcs->d_notyp = false; } @@ -1659,7 +1659,7 @@ mktag(sym_t *tag, tspec_t kind, bool dec tag = newtag(tag, scl, decl, semi); } else { /* a new tag, no empty declaration */ - dcs->d_next->d_nedecl = true; + dcs->d_next->d_nonempty_decl = true; if (scl == ENUM_TAG && !decl) { if (!tflag && (sflag || pflag)) /* forward reference to enum type */ @@ -1682,7 +1682,7 @@ mktag(sym_t *tag, tspec_t kind, bool dec tag->s_block_level = -1; tag->s_type = tp = getblk(sizeof (type_t)); tp->t_packed = dcs->d_packed; - dcs->d_next->d_nedecl = true; + dcs->d_next->d_nonempty_decl = true; } if (tp->t_tspec == NOTSPEC) { @@ -1724,14 +1724,14 @@ newtag(sym_t *tag, scl_t scl, bool decl, warning(45, storage_class_name(tag->s_scl), tag->s_name); } - dcs->d_next->d_nedecl = true; + dcs->d_next->d_nonempty_decl = true; } else if (decl) { /* "struct a { ... } " */ if (hflag) /* redefinition hides earlier one: %s */ warning(43, tag->s_name); tag = pushdown(tag); - dcs->d_next->d_nedecl = true; + dcs->d_next->d_nonempty_decl = true; } else if (tag->s_scl != scl) { /* base type is really '%s %s' */ warning(45, storage_class_name(tag->s_scl), @@ -1743,7 +1743,7 @@ newtag(sym_t *tag, scl_t scl, bool decl, tag->s_name); } tag = pushdown(tag); - dcs->d_next->d_nedecl = true; + dcs->d_next->d_nonempty_decl = true; } } else { if (tag->s_scl != scl) { @@ -1751,15 +1751,15 @@ newtag(sym_t *tag, scl_t scl, bool decl, error(46, storage_class_name(tag->s_scl)); print_previous_declaration(-1, tag); tag = pushdown(tag); - dcs->d_next->d_nedecl = true; + dcs->d_next->d_nonempty_decl = true; } else if (decl && !is_incomplete(tag->s_type)) { /* (%s) tag
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 10:21:07 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c func.c lint1.h Log Message: lint: rename d_rdcsym to d_redeclared_symbol No functional change. To generate a diff of this commit: cvs rdiff -u -r1.153 -r1.154 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.79 -r1.80 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.77 -r1.78 src/usr.bin/xlint/lint1/lint1.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.153 src/usr.bin/xlint/lint1/decl.c:1.154 --- src/usr.bin/xlint/lint1/decl.c:1.153 Sun Mar 21 10:16:12 2021 +++ src/usr.bin/xlint/lint1/decl.c Sun Mar 21 10:21:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.153 2021/03/21 10:16:12 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.154 2021/03/21 10:21:07 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.153 2021/03/21 10:16:12 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.154 2021/03/21 10:21:07 rillig Exp $"); #endif #include @@ -1162,15 +1162,15 @@ declarator_1_struct_union(sym_t *dsym) lint_assert(dsym->s_scl == MOS || dsym->s_scl == MOU); - if (dcs->d_rdcsym != NULL) { + if (dcs->d_redeclared_symbol != NULL) { /* should be ensured by storesym() */ - lint_assert(dcs->d_rdcsym->s_scl == MOS || - dcs->d_rdcsym->s_scl == MOU); + lint_assert(dcs->d_redeclared_symbol->s_scl == MOS || + dcs->d_redeclared_symbol->s_scl == MOU); - if (dsym->s_styp == dcs->d_rdcsym->s_styp) { + if (dsym->s_styp == dcs->d_redeclared_symbol->s_styp) { /* duplicate member name: %s */ error(33, dsym->s_name); - rmsym(dcs->d_rdcsym); + rmsym(dcs->d_redeclared_symbol); } } @@ -1522,12 +1522,12 @@ declarator_name(sym_t *sym) scl_t sc = NOSCL; if (sym->s_scl == NOSCL) { - dcs->d_rdcsym = NULL; + dcs->d_redeclared_symbol = NULL; } else if (sym->s_defarg) { sym->s_defarg = false; - dcs->d_rdcsym = NULL; + dcs->d_redeclared_symbol = NULL; } else { - dcs->d_rdcsym = sym; + dcs->d_redeclared_symbol = sym; sym = pushdown(sym); } @@ -1979,7 +1979,7 @@ decl1ext(sym_t *dsym, bool initflg) outsym(dsym, dsym->s_scl, dsym->s_def); } - if ((rdsym = dcs->d_rdcsym) != NULL) { + if ((rdsym = dcs->d_redeclared_symbol) != NULL) { /* * If the old symbol stems from an old style function @@ -2080,7 +2080,7 @@ check_redeclaration(sym_t *dsym, bool *d { sym_t *rsym; - if ((rsym = dcs->d_rdcsym)->s_scl == CTCONST) { + if ((rsym = dcs->d_redeclared_symbol)->s_scl == CTCONST) { /* redeclaration of %s */ error(27, dsym->s_name); print_previous_declaration(-1, rsym); @@ -2407,11 +2407,11 @@ declare_argument(sym_t *sym, bool initfl check_type(sym); - if (dcs->d_rdcsym != NULL && - dcs->d_rdcsym->s_block_level == block_level) { + if (dcs->d_redeclared_symbol != NULL && + dcs->d_redeclared_symbol->s_block_level == block_level) { /* redeclaration of formal parameter %s */ error(237, sym->s_name); - rmsym(dcs->d_rdcsym); + rmsym(dcs->d_redeclared_symbol); sym->s_arg = true; } @@ -2583,7 +2583,8 @@ check_func_old_style_arguments(void) } if (msg) /* prototype declaration */ - print_previous_declaration(285, dcs->d_rdcsym); + print_previous_declaration(285, + dcs->d_redeclared_symbol); /* from now on the prototype is valid */ funcsym->s_osdef = false; @@ -2677,7 +2678,7 @@ declare_local(sym_t *dsym, bool initflg) check_type(dsym); - if (dcs->d_rdcsym != NULL && dsym->s_scl == EXTERN) + if (dcs->d_redeclared_symbol != NULL && dsym->s_scl == EXTERN) declare_external_in_block(dsym); if (dsym->s_scl == EXTERN) { @@ -2692,9 +2693,9 @@ declare_local(sym_t *dsym, bool initflg) } } - if (dcs->d_rdcsym != NULL) { + if (dcs->d_redeclared_symbol != NULL) { - if (dcs->d_rdcsym->s_block_level == 0) { + if (dcs->d_redeclared_symbol->s_block_level == 0) { switch (dsym->s_scl) { case AUTO: @@ -2722,10 +2723,11 @@ declare_local(sym_t *dsym, bool initflg) lint_assert(/*CONSTCOND*/false); } - } else if (dcs->d_rdcsym->s_block_level == block_level) { + } else if (dcs->d_redeclared_symbol->s_block_level == + block_level) { /* no hflag, because it's illegal! */ - if (dcs->d_rdcsym->s_arg) { + if (dcs->d_redeclared_symbol->s_arg) { /* * if !tflag, a "redeclaration of %s" error * is produced below @@ -2734,11 +2736,12 @@ declare_local(sym_t *dsym, bool initflg) if (hflag) /* decl. hides parameter: %s */ warning(91, dsym->s_name); - rmsym(dcs->d_rdcsym); + rmsym(dcs->d_redeclared_symbol); } } - } else if (dcs->d_rdcsym->s_block_level < block_level) { + } else if
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 10:16:12 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c Log Message: lint: inline local variable in declarator_1_struct_union No functional change. To generate a diff of this commit: cvs rdiff -u -r1.152 -r1.153 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.152 src/usr.bin/xlint/lint1/decl.c:1.153 --- src/usr.bin/xlint/lint1/decl.c:1.152 Sat Mar 20 13:25:31 2021 +++ src/usr.bin/xlint/lint1/decl.c Sun Mar 21 10:16:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.152 2021/03/20 13:25:31 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.153 2021/03/21 10:16:12 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.152 2021/03/20 13:25:31 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.153 2021/03/21 10:16:12 rillig Exp $"); #endif #include @@ -1159,13 +1159,14 @@ declarator_1_struct_union(sym_t *dsym) tspec_t t; int sz; int o = 0; /* Appease GCC */ - scl_t sc; - lint_assert((sc = dsym->s_scl) == MOS || sc == MOU); + lint_assert(dsym->s_scl == MOS || dsym->s_scl == MOU); if (dcs->d_rdcsym != NULL) { /* should be ensured by storesym() */ - lint_assert((sc = dcs->d_rdcsym->s_scl) == MOS || sc == MOU); + lint_assert(dcs->d_rdcsym->s_scl == MOS || + dcs->d_rdcsym->s_scl == MOU); + if (dsym->s_styp == dcs->d_rdcsym->s_styp) { /* duplicate member name: %s */ error(33, dsym->s_name);
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 10:08:02 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: func.c lint1.h Log Message: lint: rename clst to case_labels No functional change. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.76 -r1.77 src/usr.bin/xlint/lint1/lint1.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/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.78 src/usr.bin/xlint/lint1/func.c:1.79 --- src/usr.bin/xlint/lint1/func.c:1.78 Sat Mar 20 16:16:32 2021 +++ src/usr.bin/xlint/lint1/func.c Sun Mar 21 10:08:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.78 2021/03/20 16:16:32 rillig Exp $ */ +/* $NetBSD: func.c,v 1.79 2021/03/21 10:08:01 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.78 2021/03/20 16:16:32 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.79 2021/03/21 10:08:01 rillig Exp $"); #endif #include @@ -170,7 +170,7 @@ void popctrl(int env) { cstk_t *ci; - clst_t *cl, *next; + case_label_t *cl, *next; lint_assert(cstmt != NULL); lint_assert(cstmt->c_env == env); @@ -178,7 +178,7 @@ popctrl(int env) ci = cstmt; cstmt = ci->c_surrounding; - for (cl = ci->c_clst; cl != NULL; cl = next) { + for (cl = ci->c_case_labels; cl != NULL; cl = next) { next = cl->cl_next; free(cl); } @@ -447,7 +447,7 @@ check_case_label_enum(const tnode_t *tn, static void check_case_label(tnode_t *tn, cstk_t *ci) { - clst_t *cl; + case_label_t *cl; val_t *v; val_t nv; tspec_t t; @@ -498,7 +498,7 @@ check_case_label(tnode_t *tn, cstk_t *ci free(v); /* look if we had this value already */ - for (cl = ci->c_clst; cl != NULL; cl = cl->cl_next) { + for (cl = ci->c_case_labels; cl != NULL; cl = cl->cl_next) { if (cl->cl_val.v_quad == nv.v_quad) break; } @@ -515,10 +515,10 @@ check_case_label(tnode_t *tn, cstk_t *ci * append the value to the list of * case values */ - cl = xcalloc(1, sizeof (clst_t)); + cl = xcalloc(1, sizeof *cl); cl->cl_val = nv; - cl->cl_next = ci->c_clst; - ci->c_clst = cl; + cl->cl_next = ci->c_case_labels; + ci->c_case_labels = cl; } } @@ -694,7 +694,7 @@ switch2(void) { int nenum = 0, nclab = 0; sym_t *esym; - clst_t *cl; + case_label_t *cl; lint_assert(cstmt->c_swtype != NULL); @@ -710,7 +710,7 @@ switch2(void) esym != NULL; esym = esym->s_next) { nenum++; } - for (cl = cstmt->c_clst; cl != NULL; cl = cl->cl_next) + for (cl = cstmt->c_case_labels; cl != NULL; cl = cl->cl_next) nclab++; if (hflag && eflag && nenum != nclab && !cstmt->c_default) { /* enumeration value(s) not handled in switch */ Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.76 src/usr.bin/xlint/lint1/lint1.h:1.77 --- src/usr.bin/xlint/lint1/lint1.h:1.76 Sat Mar 20 13:00:43 2021 +++ src/usr.bin/xlint/lint1/lint1.h Sun Mar 21 10:08:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.76 2021/03/20 13:00:43 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.77 2021/03/21 10:08:01 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -370,12 +370,12 @@ typedef struct pqinf { } pqinf_t; /* - * Case values are stored in a list of type clst_t. + * Case values are stored in a list of type case_label_t. */ -typedef struct clst { +typedef struct case_label { val_t cl_val; - struct clst *cl_next; -} clst_t; + struct case_label *cl_next; +} case_label_t; /* * Used to keep information about nested control statements. @@ -393,7 +393,7 @@ typedef struct control_statement { bool c_had_return_noval : 1; /* had "return;" */ bool c_had_return_value : 1; /* had "return (e);" */ type_t *c_swtype; /* type of switch expression */ - clst_t *c_clst; /* list of case values */ + case_label_t *c_case_labels; /* list of case values */ struct mbl *c_fexprm; /* saved memory for end of loop expression in for() */ tnode_t *c_f3expr; /* end of loop expr in for() */
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 09:54:02 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: rename declspecs to declaration_specifiers, just as in C99 No functional change. To generate a diff of this commit: cvs rdiff -u -r1.193 -r1.194 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.193 src/usr.bin/xlint/lint1/cgram.y:1.194 --- src/usr.bin/xlint/lint1/cgram.y:1.193 Sun Mar 21 09:49:34 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Mar 21 09:54:02 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.193 2021/03/21 09:49:34 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.194 2021/03/21 09:54:02 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.193 2021/03/21 09:49:34 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.194 2021/03/21 09:54:02 rillig Exp $"); #endif #include @@ -406,7 +406,7 @@ top_level_declaration: /* C99 6.9 calls } } | declmods deftyp notype_init_decls T_SEMI - | declspecs deftyp T_SEMI { + | declaration_specifiers deftyp T_SEMI { if (dcs->d_scl == TYPEDEF) { /* typedef declares no type name */ warning(72); @@ -415,7 +415,7 @@ top_level_declaration: /* C99 6.9 calls warning(2); } } - | declspecs deftyp type_init_decls T_SEMI + | declaration_specifiers deftyp type_init_decls T_SEMI | error T_SEMI { global_clean_up(); } @@ -460,7 +460,7 @@ func_decl: | declmods deftyp notype_decl { $$ = $3; } - | declspecs deftyp type_decl { + | declaration_specifiers deftyp type_decl { $$ = $3; } ; @@ -487,7 +487,7 @@ arg_declaration: warning(2); } | declmods deftyp notype_init_decls T_SEMI - | declspecs deftyp T_SEMI { + | declaration_specifiers deftyp T_SEMI { if (!dcs->d_nedecl) { /* empty declaration */ warning(2); @@ -496,14 +496,14 @@ arg_declaration: warning(3, type_name(dcs->d_type)); } } - | declspecs deftyp type_init_decls T_SEMI { + | declaration_specifiers deftyp type_init_decls T_SEMI { if (dcs->d_nedecl) { /* '%s' declared in argument declaration list */ warning(3, type_name(dcs->d_type)); } } | declmods error - | declspecs error + | declaration_specifiers error ; declaration: /* C99 6.7 */ @@ -517,7 +517,7 @@ declaration: /* C99 6.7 */ } } | declmods deftyp notype_init_decls T_SEMI - | declspecs deftyp T_SEMI { + | declaration_specifiers deftyp T_SEMI { if (dcs->d_scl == TYPEDEF) { /* typedef declares no type name */ warning(72); @@ -526,7 +526,7 @@ declaration: /* C99 6.7 */ warning(2); } } - | declspecs deftyp type_init_decls T_SEMI + | declaration_specifiers deftyp type_init_decls T_SEMI | error T_SEMI ; @@ -635,16 +635,16 @@ deftyp: } ; -declspecs: /* C99 6.7 calls this declaration_specifiers */ +declaration_specifiers: /* C99 6.7 */ clrtyp_typespec { add_type($1); } | declmods typespec { add_type($2); } - | type_attribute declspecs - | declspecs declmod - | declspecs notype_typespec { + | type_attribute declaration_specifiers + | declaration_specifiers declmod + | declaration_specifiers notype_typespec { add_type($2); } ; @@ -1294,7 +1294,7 @@ parameter_declaration: declmods deftyp { $$ = declare_argument(abstract_name(), false); } - | declspecs deftyp { + | declaration_specifiers deftyp { $$ = declare_argument(abstract_name(), false); } | declmods deftyp notype_param_decl { @@ -1307,13 +1307,13 @@ parameter_declaration: * "function with an abstract argument of type function". * This grammar realizes the second case. */ - | declspecs deftyp param_decl { + | declaration_specifiers deftyp param_decl { $$ = declare_argument($3, false); } | declmods deftyp abstract_decl { $$ = declare_argument($3, false); } - | declspecs deftyp abstract_decl { + | declaration_specifiers deftyp abstract_decl { $$ = declare_argument($3, false); } ; @@ -1729,8 +1729,8 @@ for_start: } ; for_exprs: - for_start declspecs deftyp notype_init_decls T_SEMI opt_expr - T_SEMI opt_expr T_RPAREN { + for_start declaration_specifiers deftyp notype_init_decls T_SEMI + opt_expr T_SEMI opt_expr T_RPAREN { /* variable declaration in for loop */ c99ism(325); for1(NULL, $6, $8);
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 09:49:34 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: rename grammar rule 'data_def' to 'top_level_declaration' No functional change. To generate a diff of this commit: cvs rdiff -u -r1.192 -r1.193 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.192 src/usr.bin/xlint/lint1/cgram.y:1.193 --- src/usr.bin/xlint/lint1/cgram.y:1.192 Sun Mar 21 09:22:35 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Mar 21 09:49:34 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.192 2021/03/21 09:22:35 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.193 2021/03/21 09:49: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.192 2021/03/21 09:22:35 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.193 2021/03/21 09:49:34 rillig Exp $"); #endif #include @@ -362,13 +362,22 @@ external_declaration: /* C99 6.9 */ global_clean_up_decl(false); clear_warning_flags(); } - | data_def { + | top_level_declaration { global_clean_up_decl(false); clear_warning_flags(); } ; -data_def: +/* + * On the top level, lint allows several forms of declarations that it doesn't + * allow in functions. For example, a single ';' is an empty declaration and + * is supported by some compilers, but in a function it would be an empty + * statement, not a declaration. This makes a difference in C90 mode, where + * a statement must not be followed by a declaration. + * + * See 'declaration' for all other declarations. + */ +top_level_declaration: /* C99 6.9 calls this 'declaration' */ T_SEMI { if (sflag) { /* empty declaration */ @@ -456,12 +465,12 @@ func_decl: } ; -arg_declaration_list_opt: +arg_declaration_list_opt: /* C99 6.9.1p13 example 1 */ /* empty */ | arg_declaration_list ; -arg_declaration_list: +arg_declaration_list: /* C99 6.9.1p13 example 1 */ arg_declaration | arg_declaration_list arg_declaration /* XXX or better "arg_declaration error" ? */ @@ -472,7 +481,6 @@ arg_declaration_list: * "arg_declaration" is separated from "declaration" because it * needs other error handling. */ - arg_declaration: declmods deftyp T_SEMI { /* empty declaration */ @@ -498,7 +506,7 @@ arg_declaration: | declspecs error ; -declaration: +declaration: /* C99 6.7 */ declmods deftyp T_SEMI { if (dcs->d_scl == TYPEDEF) { /* typedef declares no type name */ @@ -627,7 +635,7 @@ deftyp: } ; -declspecs: +declspecs: /* C99 6.7 calls this declaration_specifiers */ clrtyp_typespec { add_type($1); }
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 09:22:35 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: remove redundant '%prec' declarations from the grammar No change to the generated binary. To generate a diff of this commit: cvs rdiff -u -r1.191 -r1.192 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.191 src/usr.bin/xlint/lint1/cgram.y:1.192 --- src/usr.bin/xlint/lint1/cgram.y:1.191 Sun Mar 21 08:55:59 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Mar 21 09:22:35 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.191 2021/03/21 08:55:59 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.192 2021/03/21 09:22:35 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.191 2021/03/21 08:55:59 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.192 2021/03/21 09:22:35 rillig Exp $"); #endif #include @@ -264,7 +264,7 @@ anonymize(sym_t *s) %left T_SHIFT %left T_ADDITIVE %left T_ASTERISK T_MULTIPLICATIVE -%right T_UNARY T_INCDEC T_SIZEOF T_BUILTIN_OFFSETOF T_ALIGNOF T_REAL T_IMAG +%right T_UNARY T_INCDEC T_SIZEOF T_REAL T_IMAG %left T_LPAREN T_LBRACK T_MEMBACC %token T_NAME @@ -1343,7 +1343,7 @@ initializer: /* C99 6.7.8 "Initializat ; initializer_list: /* C99 6.7.8 "Initialization" */ - initializer_list_item %prec T_COMMA + initializer_list_item | initializer_list T_COMMA initializer_list_item ; @@ -1962,12 +1962,11 @@ term: | T_IMAG T_LPAREN term T_RPAREN { $$ = build(IMAG, $3, NULL); } - | T_BUILTIN_OFFSETOF T_LPAREN type_name T_COMMA identifier T_RPAREN - %prec T_BUILTIN_OFFSETOF { + | T_BUILTIN_OFFSETOF T_LPAREN type_name T_COMMA identifier T_RPAREN { symtyp = FMEMBER; $$ = build_offsetof($3, getsym($5)); } - | T_SIZEOF term %prec T_SIZEOF { + | T_SIZEOF term { $$ = $2 == NULL ? NULL : build_sizeof($2->tn_type); if ($$ != NULL) check_expr_misc($2, false, false, false, false, false, true); @@ -1975,7 +1974,7 @@ term: | T_SIZEOF T_LPAREN type_name T_RPAREN %prec T_SIZEOF { $$ = build_sizeof($3); } - | T_ALIGNOF T_LPAREN type_name T_RPAREN %prec T_ALIGNOF { + | T_ALIGNOF T_LPAREN type_name T_RPAREN { $$ = build_alignof($3); } | T_LPAREN type_name T_RPAREN term %prec T_UNARY {
CVS commit: src/sys/arch/aarch64/aarch64
Module Name:src Committed By: skrll Date: Sun Mar 21 09:08:40 UTC 2021 Modified Files: src/sys/arch/aarch64/aarch64: locore.S Log Message: Fix a comment To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/arch/aarch64/aarch64/locore.S 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/aarch64/aarch64/locore.S diff -u src/sys/arch/aarch64/aarch64/locore.S:1.77 src/sys/arch/aarch64/aarch64/locore.S:1.78 --- src/sys/arch/aarch64/aarch64/locore.S:1.77 Sat Mar 20 14:30:50 2021 +++ src/sys/arch/aarch64/aarch64/locore.S Sun Mar 21 09:08:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.77 2021/03/20 14:30:50 skrll Exp $ */ +/* $NetBSD: locore.S,v 1.78 2021/03/21 09:08:40 skrll Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu @@ -38,7 +38,7 @@ #include #include "assym.h" -RCSID("$NetBSD: locore.S,v 1.77 2021/03/20 14:30:50 skrll Exp $") +RCSID("$NetBSD: locore.S,v 1.78 2021/03/21 09:08:40 skrll Exp $") #ifdef AARCH64_DEVICE_MEM_STRONGLY_ORDERED #define MAIR_DEVICE_MEM MAIR_DEVICE_nGnRnE @@ -175,7 +175,7 @@ vstart: msr tpidr_el0, xzr msr tpidrro_el0, xzr - /* set curcpu() */ + /* set curlwp() */ adrl x0, lwp0 /* curlwp is lwp0 */ msr tpidr_el1, x0 DPRINTREG("curlwp = ", x0);
CVS commit: src/sys/arch
Module Name:src Committed By: skrll Date: Sun Mar 21 09:00:55 UTC 2021 Modified Files: src/sys/arch/arm/arm32: arm32_kvminit.c src/sys/arch/evbarm/conf: Makefile.evbarm.inc std.generic std.rpi Log Message: -DKERNEL_BASE_VOFFSET= has annoyed me for the last time... Introduce KERNEL_VOFFSET_RUNTIME which prevents the addition of -DKERNEL_BASE_VOFFSET= to the command line and use it on the __HAVE_GENERIC_START kernels which do runtime calculation of the offset. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/arch/arm/arm32/arm32_kvminit.c cvs rdiff -u -r1.34 -r1.35 src/sys/arch/evbarm/conf/Makefile.evbarm.inc cvs rdiff -u -r1.8 -r1.9 src/sys/arch/evbarm/conf/std.generic cvs rdiff -u -r1.24 -r1.25 src/sys/arch/evbarm/conf/std.rpi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/arm32/arm32_kvminit.c diff -u src/sys/arch/arm/arm32/arm32_kvminit.c:1.67 src/sys/arch/arm/arm32/arm32_kvminit.c:1.68 --- src/sys/arch/arm/arm32/arm32_kvminit.c:1.67 Sat Dec 12 09:27:31 2020 +++ src/sys/arch/arm/arm32/arm32_kvminit.c Sun Mar 21 09:00:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: arm32_kvminit.c,v 1.67 2020/12/12 09:27:31 skrll Exp $ */ +/* $NetBSD: arm32_kvminit.c,v 1.68 2021/03/21 09:00:55 skrll Exp $ */ /* * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved. @@ -127,7 +127,7 @@ #include "opt_multiprocessor.h" #include -__KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.67 2020/12/12 09:27:31 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.68 2021/03/21 09:00:55 skrll Exp $"); #include @@ -165,6 +165,12 @@ __KERNEL_RCSID(0, "$NetBSD: arm32_kvmini #define VPRINTF(...) __nothing #endif +#if defined(__HAVE_GENERIC_START) +#if defined(KERNEL_BASE_VOFFSET) +#error KERNEL_BASE_VOFFSET should not be defined with __HAVE_GENERIC_START +#endif +#endif + struct bootmem_info bootmem_info; extern void *msgbufaddr; Index: src/sys/arch/evbarm/conf/Makefile.evbarm.inc diff -u src/sys/arch/evbarm/conf/Makefile.evbarm.inc:1.34 src/sys/arch/evbarm/conf/Makefile.evbarm.inc:1.35 --- src/sys/arch/evbarm/conf/Makefile.evbarm.inc:1.34 Tue Aug 25 02:38:15 2015 +++ src/sys/arch/evbarm/conf/Makefile.evbarm.inc Sun Mar 21 09:00:55 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.evbarm.inc,v 1.34 2015/08/25 02:38:15 uebayasi Exp $ +# $NetBSD: Makefile.evbarm.inc,v 1.35 2021/03/21 09:00:55 skrll Exp $ # # If this is a install kernel and the ramdisk image exists in the object @@ -20,6 +20,11 @@ SYSTEM_LD_TAIL_EXTRA+=; \ .include "${BOARDMKFRAG}" .endif +# +# All boards should use a runtime calculation of kern_vtopdiff, but +# support the leagacy compile time method. +# +.if !defined(KERNEL_VOFFSET_RUNTIME) .if defined(KERNEL_BASE_PHYS) && defined(KERNEL_BASE_VIRT) . if ${KERNEL_BASE_PHYS} == ${KERNEL_BASE_VIRT} CPPFLAGS+=-DKERNEL_BASES_EQUAL -DKERNEL_BASE_VOFFSET=0 @@ -27,6 +32,7 @@ CPPFLAGS+=-DKERNEL_BASES_EQUAL -DKERNEL_ CPPFLAGS+=-DKERNEL_BASE_VOFFSET="(${KERNEL_BASE_VIRT}-${KERNEL_BASE_PHYS})" . endif .endif +.endif EXTRA_CLEAN+= ${KERNELS:=.map} Index: src/sys/arch/evbarm/conf/std.generic diff -u src/sys/arch/evbarm/conf/std.generic:1.8 src/sys/arch/evbarm/conf/std.generic:1.9 --- src/sys/arch/evbarm/conf/std.generic:1.8 Fri Aug 14 16:18:37 2020 +++ src/sys/arch/evbarm/conf/std.generic Sun Mar 21 09:00:55 2021 @@ -1,4 +1,4 @@ -# $NetBSD: std.generic,v 1.8 2020/08/14 16:18:37 skrll Exp $ +# $NetBSD: std.generic,v 1.9 2021/03/21 09:00:55 skrll Exp $ # # generic NetBSD/evbarm with FDT support @@ -34,6 +34,10 @@ options __HAVE_PCI_MSI_MSIX makeoptions BOARDMKFRAG="${THISARM}/conf/mk.generic" +# Prevent the addition of a command line -DKERNEL_BASE_VOFFSET= as it +# is done at runtime. +makeoptions KERNEL_VOFFSET_RUNTIME=1 + # The physical address is chosen by u-boot and determined by armv6_start.S. # The 64 byte offset is due to u-boot header. makeoptions KERNEL_BASE_PHYS="0x0040" Index: src/sys/arch/evbarm/conf/std.rpi diff -u src/sys/arch/evbarm/conf/std.rpi:1.24 src/sys/arch/evbarm/conf/std.rpi:1.25 --- src/sys/arch/evbarm/conf/std.rpi:1.24 Thu Oct 18 09:01:54 2018 +++ src/sys/arch/evbarm/conf/std.rpi Sun Mar 21 09:00:55 2021 @@ -1,4 +1,4 @@ -# $NetBSD: std.rpi,v 1.24 2018/10/18 09:01:54 skrll Exp $ +# $NetBSD: std.rpi,v 1.25 2021/03/21 09:00:55 skrll Exp $ # # standard NetBSD/evbarm for Raspberry Pi options @@ -26,3 +26,7 @@ options __HAVE_MM_MD_DIRECT_MAPPED_PHYS makeoptions BOARDMKFRAG="${THISARM}/conf/mk.rpi" makeoptions LOADADDRESS="0x80008000" + +# Prevent the addition of a command line -DKERNEL_BASE_VOFFSET= as it +# is done at runtime. +makeoptions KERNEL_VOFFSET_RUNTIME=1
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 08:55:59 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y scan.l Log Message: lint: rename token T_XOR to T_BITXOR For symmetry with the operator, which is named BITXOR. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.190 -r1.191 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.132 -r1.133 src/usr.bin/xlint/lint1/scan.l 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.190 src/usr.bin/xlint/lint1/cgram.y:1.191 --- src/usr.bin/xlint/lint1/cgram.y:1.190 Sun Mar 21 08:52:05 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Mar 21 08:55:59 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.190 2021/03/21 08:52:05 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.191 2021/03/21 08:55:59 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.190 2021/03/21 08:52:05 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.191 2021/03/21 08:55:59 rillig Exp $"); #endif #include @@ -157,7 +157,7 @@ anonymize(sym_t *s) %token T_RELATIONAL %token T_EQUALITY %token T_AMPER -%token T_XOR +%token T_BITXOR %token T_BITOR %token T_LOGAND %token T_LOGOR @@ -257,7 +257,7 @@ anonymize(sym_t *s) %left T_LOGOR %left T_LOGAND %left T_BITOR -%left T_XOR +%left T_BITXOR %left T_AMPER %left T_EQUALITY %left T_RELATIONAL @@ -1823,7 +1823,7 @@ expr: | expr T_AMPER expr { $$ = build(BITAND, $1, $3); } - | expr T_XOR expr { + | expr T_BITXOR expr { $$ = build(BITXOR, $1, $3); } | expr T_BITOR expr { Index: src/usr.bin/xlint/lint1/scan.l diff -u src/usr.bin/xlint/lint1/scan.l:1.132 src/usr.bin/xlint/lint1/scan.l:1.133 --- src/usr.bin/xlint/lint1/scan.l:1.132 Sun Mar 21 08:46:26 2021 +++ src/usr.bin/xlint/lint1/scan.l Sun Mar 21 08:55:59 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: scan.l,v 1.132 2021/03/21 08:46:26 rillig Exp $ */ +/* $NetBSD: scan.l,v 1.133 2021/03/21 08:55:59 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: scan.l,v 1.132 2021/03/21 08:46:26 rillig Exp $"); +__RCSID("$NetBSD: scan.l,v 1.133 2021/03/21 08:55:59 rillig Exp $"); #endif #include "lint1.h" @@ -83,7 +83,7 @@ TL ([fFlL]?[i]?) "&&"return T_LOGAND; "|"return T_BITOR; "&"return T_AMPER; -"^"return T_XOR; +"^"return T_BITXOR; "=="return lex_operator(T_EQUALITY, EQ); "!="return lex_operator(T_EQUALITY, NE); "<"return lex_operator(T_RELATIONAL, LT);
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 08:52:05 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: in debug output, use uniform file location references This makes it easy to click on the location in the IDE instead of having to manually parse the location and navigate to it. No functional change outside debug mode. To generate a diff of this commit: cvs rdiff -u -r1.189 -r1.190 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.189 src/usr.bin/xlint/lint1/cgram.y:1.190 --- src/usr.bin/xlint/lint1/cgram.y:1.189 Sun Mar 21 08:46:26 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Mar 21 08:52:05 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.189 2021/03/21 08:46:26 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.190 2021/03/21 08:52:05 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.189 2021/03/21 08:46:26 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.190 2021/03/21 08:52:05 rillig Exp $"); #endif #include @@ -75,8 +75,8 @@ static sym_t *symbolrename(sym_t *, sbuf static void CLEAR_WARN_FLAGS(const char *file, size_t line) { - printf("%s, %d: clear flags %s %zu\n", curr_pos.p_file, - curr_pos.p_line, file, line); + printf("%s:%d: %s:%zu: clearing flags\n", + curr_pos.p_file, curr_pos.p_line, file, line); clear_warn_flags(); olwarn = LWARN_BAD; } @@ -85,8 +85,8 @@ static void SAVE_WARN_FLAGS(const char *file, size_t line) { lint_assert(olwarn == LWARN_BAD); - printf("%s, %d: save flags %s %zu = %d\n", curr_pos.p_file, - curr_pos.p_line, file, line, lwarn); + printf("%s:%d: %s:%zu: saving flags %d\n", + curr_pos.p_file, curr_pos.p_line, file, line, lwarn); olwarn = lwarn; } @@ -95,24 +95,24 @@ RESTORE_WARN_FLAGS(const char *file, siz { if (olwarn != LWARN_BAD) { lwarn = olwarn; - printf("%s, %d: restore flags %s %zu = %d\n", curr_pos.p_file, - curr_pos.p_line, file, line, lwarn); + printf("%s:%d: %s:%zu: restoring flags %d\n", + curr_pos.p_file, curr_pos.p_line, file, line, lwarn); olwarn = LWARN_BAD; } else CLEAR_WARN_FLAGS(file, line); } #define cgram_debug(fmt, args...) printf("cgram_debug: " fmt "\n", ##args) #else -#define CLEAR_WARN_FLAGS(f, l) clear_warn_flags(), olwarn = LWARN_BAD +#define CLEAR_WARN_FLAGS(f, l) clear_warn_flags(), olwarn = LWARN_BAD #define SAVE_WARN_FLAGS(f, l) olwarn = lwarn #define RESTORE_WARN_FLAGS(f, l) \ (void)(olwarn == LWARN_BAD ? (clear_warn_flags(), 0) : (lwarn = olwarn)) #define cgram_debug(fmt, args...) do { } while (false) #endif -#define clear_warning_flags() CLEAR_WARN_FLAGS(__FILE__, __LINE__) -#define save_warning_flags() SAVE_WARN_FLAGS(__FILE__, __LINE__) -#define restore_warning_flags() RESTORE_WARN_FLAGS(__FILE__, __LINE__) +#define clear_warning_flags() CLEAR_WARN_FLAGS(__FILE__, __LINE__) +#define save_warning_flags() SAVE_WARN_FLAGS(__FILE__, __LINE__) +#define restore_warning_flags() RESTORE_WARN_FLAGS(__FILE__, __LINE__) /* unbind the anonymous struct members from the struct */ static void
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Mar 21 08:46:26 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y scan.l Log Message: lint: remove redundant operator information from the grammar Several tokens can only ever map to a single operator and thus do not need to encode the operator. Indeed, they already encoded it as NOOP, and it was not used by any grammar rule. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.188 -r1.189 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.131 -r1.132 src/usr.bin/xlint/lint1/scan.l 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.188 src/usr.bin/xlint/lint1/cgram.y:1.189 --- src/usr.bin/xlint/lint1/cgram.y:1.188 Sat Mar 20 16:16:32 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Mar 21 08:46:26 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.188 2021/03/20 16:16:32 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.189 2021/03/21 08:46:26 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.188 2021/03/20 16:16:32 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.189 2021/03/21 08:46:26 rillig Exp $"); #endif #include @@ -126,7 +126,6 @@ anonymize(sym_t *s) %expect 134 %union { - int y_int; val_t *y_val; sbuf_t *y_sb; sym_t *y_sym; @@ -151,20 +150,20 @@ anonymize(sym_t *s) %token T_TYPEOF %token T_EXTENSION %token T_ALIGNOF -%token T_ASTERISK +%token T_ASTERISK %token T_MULTIPLICATIVE %token T_ADDITIVE %token T_SHIFT %token T_RELATIONAL %token T_EQUALITY -%token T_AMPER -%token T_XOR -%token T_BITOR -%token T_LOGAND -%token T_LOGOR +%token T_AMPER +%token T_XOR +%token T_BITOR +%token T_LOGAND +%token T_LOGOR %token T_QUEST %token T_COLON -%token T_ASSIGN +%token T_ASSIGN %token T_OPASSIGN %token T_COMMA %token T_SEMI Index: src/usr.bin/xlint/lint1/scan.l diff -u src/usr.bin/xlint/lint1/scan.l:1.131 src/usr.bin/xlint/lint1/scan.l:1.132 --- src/usr.bin/xlint/lint1/scan.l:1.131 Sun Jan 24 09:25:16 2021 +++ src/usr.bin/xlint/lint1/scan.l Sun Mar 21 08:46:26 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: scan.l,v 1.131 2021/01/24 09:25:16 rillig Exp $ */ +/* $NetBSD: scan.l,v 1.132 2021/03/21 08:46:26 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: scan.l,v 1.131 2021/01/24 09:25:16 rillig Exp $"); +__RCSID("$NetBSD: scan.l,v 1.132 2021/03/21 08:46:26 rillig Exp $"); #endif #include "lint1.h" @@ -68,7 +68,7 @@ TL ([fFlL]?[i]?) 0[xX]{HD}+\.{HD}*{HX}{TL} | 0[xX]{HD}+{HX}{TL} | \.{D}+{EX}?{TL} return lex_floating_constant(yytext, yyleng); -"="return lex_operator(T_ASSIGN, NOOP); +"="return T_ASSIGN; "*="return lex_operator(T_OPASSIGN, MULASS); "/="return lex_operator(T_OPASSIGN, DIVASS); "%="return lex_operator(T_OPASSIGN, MODASS); @@ -79,11 +79,11 @@ TL ([fFlL]?[i]?) "&="return lex_operator(T_OPASSIGN, ANDASS); "^="return lex_operator(T_OPASSIGN, XORASS); "|="return lex_operator(T_OPASSIGN, ORASS); -"||"return lex_operator(T_LOGOR, NOOP); -"&&"return lex_operator(T_LOGAND, NOOP); -"|"return lex_operator(T_BITOR, NOOP); -"&"return lex_operator(T_AMPER, NOOP); -"^"return lex_operator(T_XOR, NOOP); +"||"return T_LOGOR; +"&&"return T_LOGAND; +"|"return T_BITOR; +"&"return T_AMPER; +"^"return T_XOR; "=="return lex_operator(T_EQUALITY, EQ); "!="return lex_operator(T_EQUALITY, NE); "<"return lex_operator(T_RELATIONAL, LT); @@ -98,7 +98,7 @@ TL ([fFlL]?[i]?) "."return lex_operator(T_MEMBACC, POINT); "+"return lex_operator(T_ADDITIVE, PLUS); "-"return lex_operator(T_ADDITIVE, MINUS); -"*"return lex_operator(T_ASTERISK, NOOP); +"*"return T_ASTERISK; "/"return lex_operator(T_MULTIPLICATIVE, DIV); "%"return lex_operator(T_MULTIPLICATIVE, MOD); "!"return lex_operator(T_UNARY, NOT);
CVS commit: src/sys/arch/aarch64
Module Name:src Committed By: skrll Date: Sun Mar 21 07:32:44 UTC 2021 Modified Files: src/sys/arch/aarch64/aarch64: aarch64_machdep.c src/sys/arch/aarch64/include: asan.h vmparam.h Log Message: Adjust the kernel virtual address space so that KASAN will map the kernel seperately from managed kernel virtual memory and not map the unused space between the two. To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/sys/arch/aarch64/aarch64/aarch64_machdep.c cvs rdiff -u -r1.16 -r1.17 src/sys/arch/aarch64/include/asan.h cvs rdiff -u -r1.17 -r1.18 src/sys/arch/aarch64/include/vmparam.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/aarch64/aarch64_machdep.c diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.57 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.58 --- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.57 Sun Mar 21 07:17:12 2021 +++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c Sun Mar 21 07:32:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: aarch64_machdep.c,v 1.57 2021/03/21 07:17:12 skrll Exp $ */ +/* $NetBSD: aarch64_machdep.c,v 1.58 2021/03/21 07:32:44 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.57 2021/03/21 07:17:12 skrll Exp $"); +__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.58 2021/03/21 07:32:44 skrll Exp $"); #include "opt_arm_debug.h" #include "opt_cpuoptions.h" @@ -96,6 +96,11 @@ vaddr_t module_start, module_end; static struct vm_map module_map_store; #endif +#ifdef KASAN +vaddr_t kasan_kernelstart; +vaddr_t kasan_kernelsize; +#endif + /* XXX */ vaddr_t physical_start; vaddr_t physical_end; @@ -195,6 +200,11 @@ cpu_kernel_vm_init(uint64_t memory_start kernstart_phys, kernend_phys, kernend_extra); fdt_memory_remove_range(kernstart_phys, kernend_phys - kernstart_phys + kernend_extra); + +#ifdef KASAN + kasan_kernelstart = kernstart; + kasan_kernelsize = L2_ROUND_BLOCK(kernend) - kernstart; +#endif } @@ -245,8 +255,10 @@ initarm_common(vaddr_t kvm_base, vsize_t kernstart = trunc_page((vaddr_t)__kernel_text); kernend = round_page((vaddr_t)_end); + kernstart_l2 = L2_TRUNC_BLOCK(kernstart); kernend_l2 = L2_ROUND_BLOCK(kernend); + kernelvmstart = kernend_l2; #ifdef MODULAR @@ -266,6 +278,10 @@ initarm_common(vaddr_t kvm_base, vsize_t kernelvmstart = module_end; #endif /* MODULAR */ + KASSERT(kernelvmstart < VM_KERNEL_VM_BASE); + + kernelvmstart = VM_KERNEL_VM_BASE; + paddr_t kernstart_phys __unused = KERN_VTOPHYS(kernstart); paddr_t kernend_phys __unused = KERN_VTOPHYS(kernend); @@ -307,12 +323,13 @@ initarm_common(vaddr_t kvm_base, vsize_t "kernel_start_l2 = 0x%016lx\n" "kernel_start = 0x%016lx\n" "kernel_end= 0x%016lx\n" + "(extra) = 0x%016lx\n" "kernel_end_l2 = 0x%016lx\n" #ifdef MODULAR "module_start = 0x%016lx\n" "module_end= 0x%016lx\n" #endif - "(kernel va area)\n" + "(kernel va area) = 0x%016lx\n" "(devmap va area) = 0x%016lx\n" "VM_MAX_KERNEL_ADDRESS = 0x%016lx\n" "--\n", @@ -328,11 +345,13 @@ initarm_common(vaddr_t kvm_base, vsize_t kernstart_l2, kernstart, kernend, + kernend_extra, kernend_l2, #ifdef MODULAR module_start, module_end, #endif + VM_KERNEL_VM_BASE, VM_KERNEL_IO_ADDRESS, VM_MAX_KERNEL_ADDRESS); Index: src/sys/arch/aarch64/include/asan.h diff -u src/sys/arch/aarch64/include/asan.h:1.16 src/sys/arch/aarch64/include/asan.h:1.17 --- src/sys/arch/aarch64/include/asan.h:1.16 Fri Dec 11 18:03:33 2020 +++ src/sys/arch/aarch64/include/asan.h Sun Mar 21 07:32:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: asan.h,v 1.16 2020/12/11 18:03:33 skrll Exp $ */ +/* $NetBSD: asan.h,v 1.17 2021/03/21 07:32:44 skrll Exp $ */ /* * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net @@ -206,10 +206,14 @@ kasan_md_init(void) CTASSERT((__MD_SHADOW_SIZE / L0_SIZE) == 64); + extern vaddr_t kasan_kernelstart; + extern vaddr_t kasan_kernelsize; + + kasan_shadow_map((void *)kasan_kernelstart, kasan_kernelsize); + /* The VAs we've created until now. */ vaddr_t eva = pmap_growkernel(VM_KERNEL_VM_BASE); - kasan_shadow_map((void *)VM_MIN_KERNEL_ADDRESS, - eva - VM_MIN_KERNEL_ADDRESS); + kasan_shadow_map((void *)VM_KERNEL_VM_BASE, eva - VM_KERNEL_VM_BASE); } static inline bool Index: src/sys/arch/aarch64/include/vmparam.h diff -u src/sys/arch/aarch64/include/vmparam.h:1.17 src/sys/arch/aarch64/include/vmparam.h:1.18 --- src/sys/arch/aarch64/include/vmparam.h:1.17 Tue Nov 10 07:51:19 2020 +++ src/sys/arch/aarch64/include/vmparam.h Sun Mar 21 07:32:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: vmparam.h,v 1.17 2020/11/10 07:51:19
CVS commit: src/sys/arch/aarch64/aarch64
Module Name:src Committed By: skrll Date: Sun Mar 21 07:17:12 UTC 2021 Modified Files: src/sys/arch/aarch64/aarch64: aarch64_machdep.c Log Message: Tweak a comment To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/arch/aarch64/aarch64/aarch64_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/aarch64/aarch64_machdep.c diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.56 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.57 --- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.56 Sat Dec 12 09:27:31 2020 +++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c Sun Mar 21 07:17:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: aarch64_machdep.c,v 1.56 2020/12/12 09:27:31 skrll Exp $ */ +/* $NetBSD: aarch64_machdep.c,v 1.57 2021/03/21 07:17:12 skrll Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.56 2020/12/12 09:27:31 skrll Exp $"); +__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.57 2021/03/21 07:17:12 skrll Exp $"); #include "opt_arm_debug.h" #include "opt_cpuoptions.h" @@ -180,7 +180,7 @@ cpu_kernel_vm_init(uint64_t memory_start * *text rwx => r-x *rodata rwx => r-- - *data rwx => rw- + *data rwx => rw- (.bss included) * * kernel image has mapped by L2 block. (2Mbyte) */
CVS commit: src/sys/arch/aarch64/aarch64
Module Name:src Committed By: skrll Date: Sun Mar 21 07:09:54 UTC 2021 Modified Files: src/sys/arch/aarch64/aarch64: efi_machdep.c Log Message: Remove the unnecessary invalidation code in arm_efirt_md_map_range. pmapboot_enter will panic if any overlapping mappings existed before and a full TLB invalidate was done as part of turning the MMU on in locore. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/aarch64/aarch64/efi_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/aarch64/efi_machdep.c diff -u src/sys/arch/aarch64/aarch64/efi_machdep.c:1.9 src/sys/arch/aarch64/aarch64/efi_machdep.c:1.10 --- src/sys/arch/aarch64/aarch64/efi_machdep.c:1.9 Sat Mar 20 06:48:23 2021 +++ src/sys/arch/aarch64/aarch64/efi_machdep.c Sun Mar 21 07:09:54 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: efi_machdep.c,v 1.9 2021/03/20 06:48:23 skrll Exp $ */ +/* $NetBSD: efi_machdep.c,v 1.10 2021/03/21 07:09:54 skrll Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.9 2021/03/20 06:48:23 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.10 2021/03/21 07:09:54 skrll Exp $"); #include #include @@ -69,11 +69,6 @@ arm_efirt_md_map_range(vaddr_t va, paddr } pmapboot_enter(va, pa, sz, L3_SIZE, attr, NULL); - while (sz >= PAGE_SIZE) { - aarch64_tlbi_by_va(va); - va += PAGE_SIZE; - sz -= PAGE_SIZE; - } } int