CVS commit: src/external/cddl/osnet/usr.sbin/dtrace
Module Name:src Committed By: simonb Date: Sat Mar 27 02:58:39 UTC 2021 Modified Files: src/external/cddl/osnet/usr.sbin/dtrace: Makefile Log Message: Use LDADD/DPADD instead of PROGDPLIBS - we are linking against installed libraries. Use compat/exec.mk - dtrace isn't compat32 friendly (yet?). To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/external/cddl/osnet/usr.sbin/dtrace/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/cddl/osnet/usr.sbin/dtrace
Module Name:src Committed By: simonb Date: Sat Mar 27 02:58:39 UTC 2021 Modified Files: src/external/cddl/osnet/usr.sbin/dtrace: Makefile Log Message: Use LDADD/DPADD instead of PROGDPLIBS - we are linking against installed libraries. Use compat/exec.mk - dtrace isn't compat32 friendly (yet?). To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/external/cddl/osnet/usr.sbin/dtrace/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/usr.sbin/dtrace/Makefile diff -u src/external/cddl/osnet/usr.sbin/dtrace/Makefile:1.14 src/external/cddl/osnet/usr.sbin/dtrace/Makefile:1.15 --- src/external/cddl/osnet/usr.sbin/dtrace/Makefile:1.14 Sat Apr 4 13:15:48 2020 +++ src/external/cddl/osnet/usr.sbin/dtrace/Makefile Sat Mar 27 02:58:39 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.14 2020/04/04 13:15:48 christos Exp $ +# $NetBSD: Makefile,v 1.15 2021/03/27 02:58:39 simonb Exp $ # $FreeBSD: head/cddl/usr.sbin/dtrace/Makefile 314654 2017-03-04 11:30:04Z ngie $ @@ -39,13 +39,9 @@ COPTS.dtrace.c += -Wno-missing-field-ini COPTS.dtrace.c += -Wno-format LDFLAGS+= -pthread +LDADD+= -lctf -ldtrace -lelf -lproc -ly -ll -lz +DPADD+= ${LIBCTF} ${LIBDTRACE} ${LIBELF} ${LIBPROC} ${LIBY} ${LIBL} ${LIBZ} -PROGDPLIBS+= ctf ${.CURDIR}/../../lib/libctf -PROGDPLIBS+= dtrace ${.CURDIR}/../../lib/libdtrace -PROGDPLIBS+= elf ${NETBSDSRCDIR}/external/bsd/elftoolchain/lib/libelf -PROGDPLIBS+= proc ${NETBSDSRCDIR}/external/bsd/libproc/lib -PROGDPLIBS+= y ${NETBSDSRCDIR}/lib/liby -PROGDPLIBS+= l ${NETBSDSRCDIR}/external/bsd/flex/lib -PROGDPLIBS+= z ${NETBSDSRCDIR}/lib/libz +.include "../../compat/exec.mk" .include
CVS commit: src/share/mk
Module Name:src Committed By: simonb Date: Sat Mar 27 02:46:46 UTC 2021 Modified Files: src/share/mk: bsd.hostprog.mk Log Message: Make columns nicely aligned. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/share/mk/bsd.hostprog.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/mk/bsd.hostprog.mk diff -u src/share/mk/bsd.hostprog.mk:1.83 src/share/mk/bsd.hostprog.mk:1.84 --- src/share/mk/bsd.hostprog.mk:1.83 Sat Apr 4 01:35:22 2020 +++ src/share/mk/bsd.hostprog.mk Sat Mar 27 02:46:45 2021 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.hostprog.mk,v 1.83 2020/04/04 01:35:22 christos Exp $ +# $NetBSD: bsd.hostprog.mk,v 1.84 2021/03/27 02:46:45 simonb Exp $ # @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94 .include @@ -7,71 +7,71 @@ # Basic targets # Default values -LIBATF_C?= /usr/lib/libatf-c.a -LIBATF_CXX?= /usr/lib/libatf-c++.a -LIBBLUETOOTH?= /usr/lib/libbluetooth.a -LIBBZ2?= /usr/lib/libbz2.a -LIBC?= /usr/lib/libc.a -LIBCOMPAT?= /usr/lib/libcompat.a -LIBCRYPT?= /usr/lib/libcrypt.a -LIBCURSES?= /usr/lib/libcurses.a -LIBC_PIC?= /usr/lib/libc_pic.a -LIBC_SO?= /usr/lib/libc.so -LIBDBM?= /usr/lib/libdbm.a -LIBDES?= /usr/lib/libdes.a -LIBEDIT?= /usr/lib/libedit.a -LIBEVENT?= /usr/lib/libevent.a +LIBATF_C?= /usr/lib/libatf-c.a +LIBATF_CXX?= /usr/lib/libatf-c++.a +LIBBLUETOOTH?= /usr/lib/libbluetooth.a +LIBBZ2?= /usr/lib/libbz2.a +LIBC?= /usr/lib/libc.a +LIBCOMPAT?= /usr/lib/libcompat.a +LIBCRYPT?= /usr/lib/libcrypt.a +LIBCURSES?= /usr/lib/libcurses.a +LIBC_PIC?= /usr/lib/libc_pic.a +LIBC_SO?= /usr/lib/libc.so +LIBDBM?= /usr/lib/libdbm.a +LIBDES?= /usr/lib/libdes.a +LIBEDIT?= /usr/lib/libedit.a +LIBEVENT?= /usr/lib/libevent.a LIBEVENT_OPENSSL?= /usr/lib/libevent_openssl.a LIBEVENT_PTHREADS?= /usr/lib/libevent_pthreads.a -LIBEXPAT?= /usr/lib/libexpat.a -LIBFETCH?= /usr/lib/libfetch.a -LIBFORM?= /usr/lib/libform.a -LIBGCC?= /usr/lib/libgcc.a -LIBGNUCTF?= /usr/lib/libgnuctf.a -LIBGNUMALLOC?= /usr/lib/libgnumalloc.a -LIBINTL?= /usr/lib/libintl.a -LIBIPSEC?= /usr/lib/libipsec.a -LIBKVM?= /usr/lib/libkvm.a -LIBL?= /usr/lib/libl.a -LIBLUTOK?= /usr/lib/liblutok.a -LIBLZMA?= /usr/lib/liblzma.a -LIBM?= /usr/lib/libm.a -LIBMAGIC?= /usr/lib/libmagic.a -LIBMENU?= /usr/lib/libmenu.a -LIBMP?= /usr/lib/libmp.a -LIBNTP?= /usr/lib/libntp.a -LIBNVMM?= /usr/lib/libnvmm.a -LIBOBJC?= /usr/lib/libobjc.a -LIBP2K?= /usr/lib/libp2k.a -LIBPANEL?= /usr/lib/libpanel.a -LIBPC?= /usr/lib/libpc.a -LIBPCAP?= /usr/lib/libpcap.a -LIBPCI?= /usr/lib/libpci.a -LIBPLOT?= /usr/lib/libplot.a -LIBPOSIX?= /usr/lib/libposix.a -LIBPTHREAD?=/usr/lib/libpthread.a -LIBPUFFS?= /usr/lib/libpuffs.a -LIBQUOTA?= /usr/lib/libquota.a -LIBREFUSE?= /usr/lib/librefuse.a -LIBRESOLV?= /usr/lib/libresolv.a -LIBRPCSVC?= /usr/lib/librpcsvc.a -LIBRUMP?= /usr/lib/librump.a -LIBRUMPCLIENT?= /usr/lib/librumpclient.a -LIBRUMPNET?= /usr/lib/librumpnet.a -LIBRUMPRES?= /usr/lib/librumpres.a -LIBRUMPUSER?= /usr/lib/librumpuser.a -LIBRUMPVFS?= /usr/lib/librumpvfs.a -LIBSKEY?= /usr/lib/libskey.a -LIBSQLITE3?= /usr/lib/libsqlite3.a -LIBSSP?= /usr/lib/libssp.a -LIBSTDCXX?= /usr/lib/libstdc++.a -LIBSUPCXX?= /usr/lib/libsupc++.a -LIBTERMINFO?= /usr/lib/libterminfo.a -LIBUKFS?= /usr/lib/libukfs.a -LIBUTIL?= /usr/lib/libutil.a -LIBWRAP?= /usr/lib/libwrap.a -LIBY?= /usr/lib/liby.a -LIBZ?= /usr/lib/libz.a +LIBEXPAT?= /usr/lib/libexpat.a +LIBFETCH?= /usr/lib/libfetch.a +LIBFORM?= /usr/lib/libform.a +LIBGCC?= /usr/lib/libgcc.a +LIBGNUCTF?= /usr/lib/libgnuctf.a +LIBGNUMALLOC?= /usr/lib/libgnumalloc.a +LIBINTL?= /usr/lib/libintl.a +LIBIPSEC?= /usr/lib/libipsec.a +LIBKVM?= /usr/lib/libkvm.a +LIBL?= /usr/lib/libl.a +LIBLUTOK?= /usr/lib/liblutok.a +LIBLZMA?= /usr/lib/liblzma.a +LIBM?= /usr/lib/libm.a +LIBMAGIC?= /usr/lib/libmagic.a +LIBMENU?= /usr/lib/libmenu.a +LIBMP?= /usr/lib/libmp.a +LIBNTP?= /usr/lib/libntp.a +LIBNVMM?= /usr/lib/libnvmm.a +LIBOBJC?= /usr/lib/libobjc.a +LIBP2K?= /usr/lib/libp2k.a +LIBPANEL?= /usr/lib/libpanel.a +LIBPC?= /usr/lib/libpc.a +LIBPCAP?= /usr/lib/libpcap.a +LIBPCI?= /usr/lib/libpci.a +LIBPLOT?= /usr/lib/libplot.a +LIBPOSIX?= /usr/lib/libposix.a +LIBPTHREAD?= /usr/lib/libpthread.a +LIBPUFFS?= /usr/lib/libpuffs.a +LIBQUOTA?= /usr/lib/libquota.a +LIBREFUSE?= /usr/lib/librefuse.a +LIBRESOLV?= /usr/lib/libresolv.a +LIBRPCSVC?= /usr/lib/librpcsvc.a +LIBRUMP?= /usr/lib/librump.a +LIBRUMPCLIENT?= /usr/lib/librumpclient.a +LIBRUMPNET?= /usr/lib/librumpnet.a +LIBRUMPRES?= /usr/lib/librumpres.a +LIBRUMPUSER?= /usr/lib/librumpuser.a +LIBRUMPVFS?= /usr/lib/librumpvfs.a +LIBSKEY?= /usr/lib/libskey.a +LIBSQLITE3?= /usr/lib/libsqlite3.a +LIBSSP?= /usr/lib/libssp.a +LIBSTDCXX?= /usr/lib/libstdc++.a +LIBSUPCXX?= /usr/lib/libsupc++.a +LIBTERMINFO?= /usr/lib/libterminfo.a +LIBUKFS?= /usr/lib/libukfs.a +LIBUTIL?= /usr/lib/libutil.a +LIBWRAP?= /usr/lib/libwrap.a +LIBY?=
CVS commit: src/share/mk
Module Name:src Committed By: simonb Date: Sat Mar 27 02:46:46 UTC 2021 Modified Files: src/share/mk: bsd.hostprog.mk Log Message: Make columns nicely aligned. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/share/mk/bsd.hostprog.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [thorpej-cfargs] src/sys
Module Name:src Committed By: thorpej Date: Sat Mar 27 01:41:43 UTC 2021 Modified Files: src/sys/arch/evbmips/mipssim [thorpej-cfargs]: virtio_mainbus.c src/sys/dev/acpi [thorpej-cfargs]: virtio_acpi.c src/sys/dev/fdt [thorpej-cfargs]: virtio_mmio_fdt.c src/sys/dev/pci [thorpej-cfargs]: virtio_pci.c Log Message: - config_found_ia() -> config_found(). - virtio only carries a single interface attribute, so no need to specify it explicitly. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.1.2.1 src/sys/arch/evbmips/mipssim/virtio_mainbus.c cvs rdiff -u -r1.7 -r1.7.2.1 src/sys/dev/acpi/virtio_acpi.c cvs rdiff -u -r1.7 -r1.7.2.1 src/sys/dev/fdt/virtio_mmio_fdt.c cvs rdiff -u -r1.28 -r1.28.2.1 src/sys/dev/pci/virtio_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbmips/mipssim/virtio_mainbus.c diff -u src/sys/arch/evbmips/mipssim/virtio_mainbus.c:1.1 src/sys/arch/evbmips/mipssim/virtio_mainbus.c:1.1.2.1 --- src/sys/arch/evbmips/mipssim/virtio_mainbus.c:1.1 Mon Feb 15 22:39:46 2021 +++ src/sys/arch/evbmips/mipssim/virtio_mainbus.c Sat Mar 27 01:41:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: virtio_mainbus.c,v 1.1 2021/02/15 22:39:46 reinoud Exp $ */ +/* $NetBSD: virtio_mainbus.c,v 1.1.2.1 2021/03/27 01:41:43 thorpej Exp $ */ /* * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: virtio_mainbus.c,v 1.1 2021/02/15 22:39:46 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: virtio_mainbus.c,v 1.1.2.1 2021/03/27 01:41:43 thorpej Exp $"); #include #include @@ -108,13 +108,13 @@ virtio_mainbus_attach(device_t parent, d if (virtio_mmio_common_probe_present(msc)) virtio_mmio_common_attach(msc); - virtio_mainbus_rescan(self, "virtio", NULL); + virtio_mainbus_rescan(self, NULL, NULL); } /* ARGSUSED */ static int -virtio_mainbus_rescan(device_t self, const char *attr, const int *scan_flags) +virtio_mainbus_rescan(device_t self, const char *ifattr, const int *locs) { struct virtio_mainbus_softc *sc = device_private(self); struct virtio_mmio_softc *msc = >sc_msc; @@ -127,7 +127,7 @@ virtio_mainbus_rescan(device_t self, con memset(, 0, sizeof(va)); va.sc_childdevid = vsc->sc_childdevid; - config_found_ia(self, attr, , NULL); + config_found(self, , NULL, CFARG_EOL); if (virtio_attach_failed(vsc)) return 0; Index: src/sys/dev/acpi/virtio_acpi.c diff -u src/sys/dev/acpi/virtio_acpi.c:1.7 src/sys/dev/acpi/virtio_acpi.c:1.7.2.1 --- src/sys/dev/acpi/virtio_acpi.c:1.7 Fri Jan 29 15:49:55 2021 +++ src/sys/dev/acpi/virtio_acpi.c Sat Mar 27 01:41:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: virtio_acpi.c,v 1.7 2021/01/29 15:49:55 thorpej Exp $ */ +/* $NetBSD: virtio_acpi.c,v 1.7.2.1 2021/03/27 01:41:43 thorpej Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: virtio_acpi.c,v 1.7 2021/01/29 15:49:55 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: virtio_acpi.c,v 1.7.2.1 2021/03/27 01:41:43 thorpej Exp $"); #include #include @@ -160,7 +160,7 @@ virtio_acpi_rescan(device_t self, const memset(, 0, sizeof(va)); va.sc_childdevid = vsc->sc_childdevid; - config_found_ia(self, ifattr, , NULL); + config_found(self, , NULL, CFARG_EOL); if (virtio_attach_failed(vsc)) return 0; Index: src/sys/dev/fdt/virtio_mmio_fdt.c diff -u src/sys/dev/fdt/virtio_mmio_fdt.c:1.7 src/sys/dev/fdt/virtio_mmio_fdt.c:1.7.2.1 --- src/sys/dev/fdt/virtio_mmio_fdt.c:1.7 Wed Jan 27 03:10:21 2021 +++ src/sys/dev/fdt/virtio_mmio_fdt.c Sat Mar 27 01:41:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: virtio_mmio_fdt.c,v 1.7 2021/01/27 03:10:21 thorpej Exp $ */ +/* $NetBSD: virtio_mmio_fdt.c,v 1.7.2.1 2021/03/27 01:41:43 thorpej Exp $ */ /* * Copyright (c) 2018 Jonathan A. Kollasch @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: virtio_mmio_fdt.c,v 1.7 2021/01/27 03:10:21 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: virtio_mmio_fdt.c,v 1.7.2.1 2021/03/27 01:41:43 thorpej Exp $"); #include #include @@ -105,7 +105,7 @@ virtio_mmio_fdt_attach(device_t parent, msc->sc_free_interrupts = virtio_mmio_fdt_free_interrupts; virtio_mmio_common_attach(msc); - virtio_mmio_fdt_rescan(self, "virtio", NULL); + virtio_mmio_fdt_rescan(self, NULL, NULL); } /* ARGSUSED */ @@ -123,7 +123,7 @@ virtio_mmio_fdt_rescan(device_t self, co memset(, 0, sizeof(va)); va.sc_childdevid = vsc->sc_childdevid; - config_found_ia(self, attr, , NULL); + config_found(self, , NULL, CFARG_EOL); if (virtio_attach_failed(vsc)) return 0; Index: src/sys/dev/pci/virtio_pci.c diff -u src/sys/dev/pci/virtio_pci.c:1.28 src/sys/dev/pci/virtio_pci.c:1.28.2.1 --- src/sys/dev/pci/virtio_pci.c:1.28 Fri Feb 5 19:18:23 2021 +++ src/sys/dev/pci/virtio_pci.c Sat Mar 27 01:41:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: virtio_pci.c,v 1.28
CVS commit: [thorpej-cfargs] src/sys
Module Name:src Committed By: thorpej Date: Sat Mar 27 01:41:43 UTC 2021 Modified Files: src/sys/arch/evbmips/mipssim [thorpej-cfargs]: virtio_mainbus.c src/sys/dev/acpi [thorpej-cfargs]: virtio_acpi.c src/sys/dev/fdt [thorpej-cfargs]: virtio_mmio_fdt.c src/sys/dev/pci [thorpej-cfargs]: virtio_pci.c Log Message: - config_found_ia() -> config_found(). - virtio only carries a single interface attribute, so no need to specify it explicitly. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.1.2.1 src/sys/arch/evbmips/mipssim/virtio_mainbus.c cvs rdiff -u -r1.7 -r1.7.2.1 src/sys/dev/acpi/virtio_acpi.c cvs rdiff -u -r1.7 -r1.7.2.1 src/sys/dev/fdt/virtio_mmio_fdt.c cvs rdiff -u -r1.28 -r1.28.2.1 src/sys/dev/pci/virtio_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/usr.bin/xlint
On Sat, Mar 27, 2021 at 01:44:07 +0100, Roland Illig wrote: > On 27.03.2021 00:16, Valery Ushakov wrote: > > On Sat, Mar 27, 2021 at 00:01:25 +0100, Roland Illig wrote: > > > To me, writing 'sizeof expr' is clearer than 'sizeof(expr)' since > > > 'sizeof' is not a function, same as with 'return'. > > > > > > Did I misinterpret the style guide in this regard? > > > > We do want it to look like a function call (and so the usual style > > rules for the function call apply). Think of cases where it's used as > > a subexpression, e.g. > > > > sizeof(expr) + 4 > > The parentheses of a function call expression have highest precedence > and bind to the left. The parentheses to the right of the sizeof > operator do not bind at all though. Therefore I find it misleading to > write them like in a function call. > > The following code demonstrates why I prefer to omit the parentheses > around the argument to the 'sizeof' operator: [...] > /* misleading since it looks like a function call */ > printf("%zu\n", sizeof(argv)[3]); [...] > It was fun to find out that there actually _is_ a case where the > different precedence matters. At first I had thought that the whole > discussion would be academic anyway. You cite examples worthy of IOCCC, but we already know C is treacherous (things like relative precedence of bitwise and comparison, etc). But most uses of sizeof are not like that. Note also that the parentheses are required fort the sizeof(type-name) variant. I.e. you cannot write sizeof int, only sizeof(int). IOCCC cases aside, I still maintain that sizeof *p + 4 is strictly less readable than sizeof(*p) + 4 and is nicely similar to sizeof(uint32_t) + 4 etc Derek Jones' "The New C Standard" (influential exegetical tour de force) doesn't seem to explicitly recommend parentheses for the unary-expr case but seems to consitently use it in its own text. -uwe
Re: CVS commit: src/usr.bin/xlint
On 27.03.2021 00:16, Valery Ushakov wrote: On Sat, Mar 27, 2021 at 00:01:25 +0100, Roland Illig wrote: To me, writing 'sizeof expr' is clearer than 'sizeof(expr)' since 'sizeof' is not a function, same as with 'return'. Did I misinterpret the style guide in this regard? We do want it to look like a function call (and so the usual style rules for the function call apply). Think of cases where it's used as a subexpression, e.g. sizeof(expr) + 4 The parentheses of a function call expression have highest precedence and bind to the left. The parentheses to the right of the sizeof operator do not bind at all though. Therefore I find it misleading to write them like in a function call. The following code demonstrates why I prefer to omit the parentheses around the argument to the 'sizeof' operator: #include int main(int argc __attribute__((__unused__)), char **argv) { /* misleading since it looks like a function call */ printf("%zu\n", sizeof(argv)[3]); /* parentheses make the precedence unambiguous */ printf("%zu\n", sizeof((argv)[3])); /* a space removes the confusion about precedence */ printf("%zu\n", sizeof (argv)[3]); /* without any parentheses, spacing equals precedence */ printf("%zu\n", sizeof argv[3]); /* * If the parentheses to the right of 'sizeof' had the same * precedence as function call parentheses, this artificial * code could be written without the outer pair of parentheses. */ printf("%c\n", (sizeof(argv))["0123456789"]); #if 0 /* * If 'sizeof' were a function returning size_t, this code * would compile. */ /* error: array subscript is not an integer */ printf("%c\n", sizeof(argv)["0123456789"]); #endif } It was fun to find out that there actually _is_ a case where the different precedence matters. At first I had thought that the whole discussion would be academic anyway. Roland
CVS commit: src/external/mpl/bind
Module Name:src Committed By: rillig Date: Sat Mar 27 00:06:27 UTC 2021 Modified Files: src/external/mpl/bind/dist/lib/isc/unix/include/isc: stdatomic.h src/external/mpl/bind/include/isc: stdatomic.h Log Message: bind: fix typo in stdatomic to support lint + Clang Before this fix, lint complained: > dist/lib/isc/queue.c(203): error: expected undefined [99] https://gitlab.isc.org/isc-projects/bind9/-/issues/2601 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 \ src/external/mpl/bind/dist/lib/isc/unix/include/isc/stdatomic.h cvs rdiff -u -r1.4 -r1.5 src/external/mpl/bind/include/isc/stdatomic.h 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/dist/lib/isc/unix/include/isc/stdatomic.h diff -u src/external/mpl/bind/dist/lib/isc/unix/include/isc/stdatomic.h:1.3 src/external/mpl/bind/dist/lib/isc/unix/include/isc/stdatomic.h:1.4 --- src/external/mpl/bind/dist/lib/isc/unix/include/isc/stdatomic.h:1.3 Fri Feb 19 16:42:20 2021 +++ src/external/mpl/bind/dist/lib/isc/unix/include/isc/stdatomic.h Sat Mar 27 00:06:27 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: stdatomic.h,v 1.3 2021/02/19 16:42:20 christos Exp $ */ +/* $NetBSD: stdatomic.h,v 1.4 2021/03/27 00:06:27 rillig Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -144,7 +144,7 @@ typedef uintmax_t atomic_uintmax_t; __c11_atomic_compare_exchange_weak_explicit(obj, expected, desired, \ succ, fail) #define atomic_exchange_explicit(obj, desired, order) \ - __c11_atomic_exchange_explicit(obj, expected, order) + __c11_atomic_exchange_explicit(obj, desired, order) #elif defined(__GNUC_ATOMICS) /* __atomic builtins */ #define atomic_init(obj, desired) (*obj = desired) #define atomic_load_explicit(obj, order) __atomic_load_n(obj, order) Index: src/external/mpl/bind/include/isc/stdatomic.h diff -u src/external/mpl/bind/include/isc/stdatomic.h:1.4 src/external/mpl/bind/include/isc/stdatomic.h:1.5 --- src/external/mpl/bind/include/isc/stdatomic.h:1.4 Fri Feb 19 16:42:23 2021 +++ src/external/mpl/bind/include/isc/stdatomic.h Sat Mar 27 00:06:27 2021 @@ -142,7 +142,7 @@ typedef uintmax_t atomic_uintmax_t; __c11_atomic_compare_exchange_weak_explicit(obj, expected, desired, \ succ, fail) #define atomic_exchange_explicit(obj, desired, order) \ - __c11_atomic_exchange_explicit(obj, expected, order) + __c11_atomic_exchange_explicit(obj, desired, order) #elif defined(__GNUC_ATOMICS) /* __atomic builtins */ #define atomic_init(obj, desired) (*obj = desired) #define atomic_load_explicit(obj, order) __atomic_load_n(obj, order)
CVS commit: src/external/mpl/bind
Module Name:src Committed By: rillig Date: Sat Mar 27 00:06:27 UTC 2021 Modified Files: src/external/mpl/bind/dist/lib/isc/unix/include/isc: stdatomic.h src/external/mpl/bind/include/isc: stdatomic.h Log Message: bind: fix typo in stdatomic to support lint + Clang Before this fix, lint complained: > dist/lib/isc/queue.c(203): error: expected undefined [99] https://gitlab.isc.org/isc-projects/bind9/-/issues/2601 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 \ src/external/mpl/bind/dist/lib/isc/unix/include/isc/stdatomic.h cvs rdiff -u -r1.4 -r1.5 src/external/mpl/bind/include/isc/stdatomic.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/usr.bin/xlint
> > There are several forms of writing sizeof: > > 1. sizeof expr > 2. sizeof(expr) > 3. sizeof (expr) > 4. sizeof(type) > 5. sizeof (type) > > I thought that the point of the rule you cited was to discourage forms 3 > and 5. Does the rule also discourage form 1, and if so, why? > > To me, writing 'sizeof expr' is clearer than 'sizeof(expr)' since > 'sizeof' is not a function, same as with 'return'. > > Did I misinterpret the style guide in this regard? I think that this (no space after sizeof) is an unindented effect of the rule (preventing sizeof x). Having said that, most of the code uses sizeof(x) instead of sizeof x so I typically follow suit for consistency. Nevertheless we should mention what is the preferred style and document it clearly. christos signature.asc Description: Message signed with OpenPGP
CVS commit: src
Module Name:src Committed By: rillig Date: Fri Mar 26 23:17:33 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: d_pr_22119.c d_pr_22119.exp msg_099.c msg_099.exp src/usr.bin/xlint/lint1: err.c tree.c Log Message: lint: add quotes around placeholder in message about undefined variable Before: error: expected undefined [99] After: error: 'expected' undefined [99] Seen in external/mpl/bind, which for Clang defines in stdatomic.h: > #define atomic_exchange_explicit(obj, desired, order) \ > __c11_atomic_exchange_explicit(obj, expected, order) Note the mismatch between 'desired' and 'expected'. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/d_pr_22119.c cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/d_pr_22119.exp cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_099.c \ src/tests/usr.bin/xlint/lint1/msg_099.exp cvs rdiff -u -r1.94 -r1.95 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.250 -r1.251 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/xlint/lint1/d_pr_22119.c diff -u src/tests/usr.bin/xlint/lint1/d_pr_22119.c:1.1 src/tests/usr.bin/xlint/lint1/d_pr_22119.c:1.2 --- src/tests/usr.bin/xlint/lint1/d_pr_22119.c:1.1 Sun Feb 28 22:12:16 2021 +++ src/tests/usr.bin/xlint/lint1/d_pr_22119.c Fri Mar 26 23:17:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: d_pr_22119.c,v 1.1 2021/02/28 22:12:16 rillig Exp $ */ +/* $NetBSD: d_pr_22119.c,v 1.2 2021/03/26 23:17:33 rillig Exp $ */ # 3 "d_pr_22119.c" /* @@ -13,6 +13,6 @@ func1(void) { void (*f1)(void); - f1 = (void (*)(void))p; /* expect: p undefined [99] */ + f1 = (void (*)(void))p; /* expect: 'p' undefined [99] */ f1 = (void *()(void))p; /* crash before 2021-02-28 */ } Index: src/tests/usr.bin/xlint/lint1/d_pr_22119.exp diff -u src/tests/usr.bin/xlint/lint1/d_pr_22119.exp:1.2 src/tests/usr.bin/xlint/lint1/d_pr_22119.exp:1.3 --- src/tests/usr.bin/xlint/lint1/d_pr_22119.exp:1.2 Sun Mar 21 20:44:59 2021 +++ src/tests/usr.bin/xlint/lint1/d_pr_22119.exp Fri Mar 26 23:17:33 2021 @@ -1 +1 @@ -d_pr_22119.c(16): error: p undefined [99] +d_pr_22119.c(16): error: 'p' undefined [99] Index: src/tests/usr.bin/xlint/lint1/msg_099.c diff -u src/tests/usr.bin/xlint/lint1/msg_099.c:1.3 src/tests/usr.bin/xlint/lint1/msg_099.c:1.4 --- src/tests/usr.bin/xlint/lint1/msg_099.c:1.3 Sun Jan 31 11:12:07 2021 +++ src/tests/usr.bin/xlint/lint1/msg_099.c Fri Mar 26 23:17:33 2021 @@ -1,7 +1,7 @@ -/* $NetBSD: msg_099.c,v 1.3 2021/01/31 11:12:07 rillig Exp $ */ +/* $NetBSD: msg_099.c,v 1.4 2021/03/26 23:17:33 rillig Exp $ */ # 3 "msg_099.c" -// Test for message: %s undefined [99] +// Test for message: '%s' undefined [99] void example(int defined_variable) Index: src/tests/usr.bin/xlint/lint1/msg_099.exp diff -u src/tests/usr.bin/xlint/lint1/msg_099.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_099.exp:1.4 --- src/tests/usr.bin/xlint/lint1/msg_099.exp:1.3 Sun Mar 21 20:44:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_099.exp Fri Mar 26 23:17:33 2021 @@ -1 +1 @@ -msg_099.c(10): error: undefined_variable undefined [99] +msg_099.c(10): error: 'undefined_variable' undefined [99] Index: src/usr.bin/xlint/lint1/err.c diff -u src/usr.bin/xlint/lint1/err.c:1.94 src/usr.bin/xlint/lint1/err.c:1.95 --- src/usr.bin/xlint/lint1/err.c:1.94 Fri Mar 26 21:05:27 2021 +++ src/usr.bin/xlint/lint1/err.c Fri Mar 26 23:17:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: err.c,v 1.94 2021/03/26 21:05:27 rillig Exp $ */ +/* $NetBSD: err.c,v 1.95 2021/03/26 23:17:33 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: err.c,v 1.94 2021/03/26 21:05:27 rillig Exp $"); +__RCSID("$NetBSD: err.c,v 1.95 2021/03/26 23:17:33 rillig Exp $"); #endif #include @@ -153,7 +153,7 @@ const char *msgs[] = { "cannot dereference non-pointer type", /* 96 */ "suffix U is illegal in traditional C", /* 97 */ "suffixes F and L are illegal in traditional C", /* 98 */ - "%s undefined", /* 99 */ + "'%s' undefined", /* 99 */ "unary + is illegal in traditional C", /* 100 */ "undefined struct/union member: %s", /* 101 */ "illegal member use: %s", /* 102 */ Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.250 src/usr.bin/xlint/lint1/tree.c:1.251 --- src/usr.bin/xlint/lint1/tree.c:1.250 Fri Mar 26 20:31:07 2021 +++ src/usr.bin/xlint/lint1/tree.c Fri Mar 26 23:17:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.250 2021/03/26 20:31:07 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.251 2021/03/26 23:17:33 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.250 2021/03/26 20:31:07 rillig
CVS commit: src
Module Name:src Committed By: rillig Date: Fri Mar 26 23:17:33 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: d_pr_22119.c d_pr_22119.exp msg_099.c msg_099.exp src/usr.bin/xlint/lint1: err.c tree.c Log Message: lint: add quotes around placeholder in message about undefined variable Before: error: expected undefined [99] After: error: 'expected' undefined [99] Seen in external/mpl/bind, which for Clang defines in stdatomic.h: > #define atomic_exchange_explicit(obj, desired, order) \ > __c11_atomic_exchange_explicit(obj, expected, order) Note the mismatch between 'desired' and 'expected'. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/d_pr_22119.c cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/d_pr_22119.exp cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_099.c \ src/tests/usr.bin/xlint/lint1/msg_099.exp cvs rdiff -u -r1.94 -r1.95 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.250 -r1.251 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.
Re: CVS commit: src/usr.bin/xlint
On Sat, Mar 27, 2021 at 00:01:25 +0100, Roland Illig wrote: > > > Log Message: > > > lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)' > > > > style says "sizeof(" not "sizeof " > > > > * Casts and sizeof's are not followed by a space. > > There are several forms of writing sizeof: > > 1. sizeof expr > 2. sizeof(expr) > 3. sizeof (expr) > 4. sizeof(type) > 5. sizeof (type) > > I thought that the point of the rule you cited was to discourage forms 3 > and 5. Does the rule also discourage form 1, and if so, why? > > To me, writing 'sizeof expr' is clearer than 'sizeof(expr)' since > 'sizeof' is not a function, same as with 'return'. > > Did I misinterpret the style guide in this regard? We do want it to look like a function call (and so the usual style rules for the function call apply). Think of cases where it's used as a subexpression, e.g. sizeof(expr) + 4 -uwe
Re: CVS commit: src/usr.bin/xlint
On 26.03.2021 23:18, Christos Zoulas wrote: In article <20210326203108.3a4e5f...@cvs.netbsd.org>, Roland Illig wrote: -=-=-=-=-=- Module Name:src Committed By: rillig Date: Fri Mar 26 20:31:07 UTC 2021 Modified Files: src/usr.bin/xlint/common: tyname.c src/usr.bin/xlint/lint1: cgram.y decl.c err.c func.c init.c lex.c main1.c mem1.c tree.c src/usr.bin/xlint/lint2: chk.c emit2.c hash.c main2.c read.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)' style says "sizeof(" not "sizeof " * Casts and sizeof's are not followed by a space. There are several forms of writing sizeof: 1. sizeof expr 2. sizeof(expr) 3. sizeof (expr) 4. sizeof(type) 5. sizeof (type) I thought that the point of the rule you cited was to discourage forms 3 and 5. Does the rule also discourage form 1, and if so, why? To me, writing 'sizeof expr' is clearer than 'sizeof(expr)' since 'sizeof' is not a function, same as with 'return'. Did I misinterpret the style guide in this regard? Roland
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Mar 26 22:33:54 UTC 2021 Modified Files: src/usr.bin/indent: README Log Message: indent: don't claim that indent is "the nicest C pretty printer around" That statement may have been true in 1993, but definitely is not true anymore, as of 2021. The part about "needs to be completely redone" is still true though since indent cannot even format its own source code in an acceptable way. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/indent/README Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Mar 26 22:33:54 UTC 2021 Modified Files: src/usr.bin/indent: README Log Message: indent: don't claim that indent is "the nicest C pretty printer around" That statement may have been true in 1993, but definitely is not true anymore, as of 2021. The part about "needs to be completely redone" is still true though since indent cannot even format its own source code in an acceptable way. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/indent/README 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/indent/README diff -u src/usr.bin/indent/README:1.2 src/usr.bin/indent/README:1.3 --- src/usr.bin/indent/README:1.2 Thu Apr 4 15:22:13 2019 +++ src/usr.bin/indent/README Fri Mar 26 22:33:54 2021 @@ -2,7 +2,7 @@ This is the C indenter, it originally ca via some distribution tape for PDP-11 Unix. It has subsequently been hacked upon by James Gosling @ CMU. It isn't very pretty, and really needs to be completely redone, but it is probably the nicest C pretty printer -around. +around (as of 1993 or even earlier). Further additions to provide "Kernel Normal Form" were contributed by the folks at Sun Microsystems. @@ -94,4 +94,3 @@ regards.. oz cc: ccvaxa!willcox sun.com!jar uunet!rsalz -
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Mar 26 22:27:43 UTC 2021 Modified Files: src/usr.bin/indent: Makefile Log Message: indent: remove workaround for array initialization bug in lint The bug has been fixed in init.c 1.133 from 2021-03-25. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/indent/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/indent/Makefile diff -u src/usr.bin/indent/Makefile:1.11 src/usr.bin/indent/Makefile:1.12 --- src/usr.bin/indent/Makefile:1.11 Sun Mar 14 00:22:16 2021 +++ src/usr.bin/indent/Makefile Fri Mar 26 22:27:43 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.11 2021/03/14 00:22:16 rillig Exp $ +# $NetBSD: Makefile,v 1.12 2021/03/26 22:27:43 rillig Exp $ # from: @(#)Makefile 8.1 (Berkeley) 6/6/93 PROG= indent @@ -7,7 +7,4 @@ SRCS= indent.c io.c lexi.c parse.c pr_co CPPFLAGS+= ${DEBUG:D-Ddebug} LINTFLAGS+= -e -w -# bug in lint; see tests/usr.bin/lint/lint1/msg_168.c -LINTFLAGS.lexi.c+= -X 168 - .include
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Mar 26 22:27:43 UTC 2021 Modified Files: src/usr.bin/indent: Makefile Log Message: indent: remove workaround for array initialization bug in lint The bug has been fixed in init.c 1.133 from 2021-03-25. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/indent/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/usr.bin/xlint
In article <20210326203108.3a4e5f...@cvs.netbsd.org>, Roland Illig wrote: >-=-=-=-=-=- > >Module Name: src >Committed By: rillig >Date: Fri Mar 26 20:31:07 UTC 2021 > >Modified Files: > src/usr.bin/xlint/common: tyname.c > src/usr.bin/xlint/lint1: cgram.y decl.c err.c func.c init.c lex.c > main1.c mem1.c tree.c > src/usr.bin/xlint/lint2: chk.c emit2.c hash.c main2.c read.c > src/usr.bin/xlint/xlint: xlint.c > >Log Message: >lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)' style says "sizeof(" not "sizeof " * Casts and sizeof's are not followed by a space. christos
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Mar 26 22:02:00 UTC 2021 Modified Files: src/usr.bin/indent: indent.c Log Message: indent: fix Clang build everywhere but on amd64 No idea why Clang didn't complain about this on amd64, only on all other platforms. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/usr.bin/indent/indent.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Mar 26 22:02:00 UTC 2021 Modified Files: src/usr.bin/indent: indent.c Log Message: indent: fix Clang build everywhere but on amd64 No idea why Clang didn't complain about this on amd64, only on all other platforms. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/usr.bin/indent/indent.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/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.59 src/usr.bin/indent/indent.c:1.60 --- src/usr.bin/indent/indent.c:1.59 Sun Mar 14 00:22:16 2021 +++ src/usr.bin/indent/indent.c Fri Mar 26 22:02:00 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.59 2021/03/14 00:22:16 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.60 2021/03/26 22:02:00 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -46,7 +46,7 @@ static char sccsid[] = "@(#)indent.c 5.1 #include #ifndef lint #if defined(__NetBSD__) -__RCSID("$NetBSD: indent.c,v 1.59 2021/03/14 00:22:16 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.60 2021/03/26 22:02:00 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $"); #endif @@ -546,7 +546,7 @@ main_prepare_parsing(void) ps.ind_level = ps.i_l_follow = col / opt.indent_size; } -static void +static void __attribute__((__noreturn__)) process_end_of_file(void) { if (s_lab != e_lab || s_code != e_code || s_com != e_com) @@ -1269,7 +1269,7 @@ process_preprocessing(void) */ } -static void +static void __attribute__((__noreturn__)) main_loop(void) { token_type type_code; @@ -1313,7 +1313,7 @@ main_loop(void) if (type_code == end_of_file) { process_end_of_file(); - return; + /* NOTREACHED */ } if (
CVS commit: src/distrib/amd64/installimage
Module Name:src Committed By: pgoyette Date: Fri Mar 26 21:18:29 UTC 2021 Modified Files: src/distrib/amd64/installimage: Makefile Log Message: The install-image has grown a bit recently, and at least amd64 has outgrown the previous size specification when the system was built with all of MKDEBUG, MKKDEBUG, and MKDEBUGLIB set to "yes" (and also when in-tree X11 is included). So, bump the size a bit. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/distrib/amd64/installimage/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/distrib/amd64/installimage
Module Name:src Committed By: pgoyette Date: Fri Mar 26 21:18:29 UTC 2021 Modified Files: src/distrib/amd64/installimage: Makefile Log Message: The install-image has grown a bit recently, and at least amd64 has outgrown the previous size specification when the system was built with all of MKDEBUG, MKKDEBUG, and MKDEBUGLIB set to "yes" (and also when in-tree X11 is included). So, bump the size a bit. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/distrib/amd64/installimage/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/amd64/installimage/Makefile diff -u src/distrib/amd64/installimage/Makefile:1.14 src/distrib/amd64/installimage/Makefile:1.15 --- src/distrib/amd64/installimage/Makefile:1.14 Mon Jan 18 03:35:11 2021 +++ src/distrib/amd64/installimage/Makefile Fri Mar 26 21:18:29 2021 @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.14 2021/01/18 03:35:11 pgoyette Exp $ +# $NetBSD: Makefile,v 1.15 2021/03/26 21:18:29 pgoyette Exp $ .include INSTIMGBASE= NetBSD-${DISTRIBVER}-amd64-install # gives ${IMGBASE}.img -INSTIMAGEMB?= 1590 # for all installation binaries +INSTIMAGEMB?= 1600 # for all installation binaries PRIMARY_BOOT= bootxx_ffsv1 SECONDARY_BOOT= boot
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 21:05:28 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: err.c Log Message: lint: improve output format for internal errors The new format follows the common conventions for file locations and allows quick navigation in IDEs. To trigger an internal error, it suffices to have 2 tokens in lint1's input, after preprocessing: 'void __pure'. To generate a diff of this commit: cvs rdiff -u -r1.93 -r1.94 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.
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 21:05:28 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: err.c Log Message: lint: improve output format for internal errors The new format follows the common conventions for file locations and allows quick navigation in IDEs. To trigger an internal error, it suffices to have 2 tokens in lint1's input, after preprocessing: 'void __pure'. To generate a diff of this commit: cvs rdiff -u -r1.93 -r1.94 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.93 src/usr.bin/xlint/lint1/err.c:1.94 --- src/usr.bin/xlint/lint1/err.c:1.93 Fri Mar 26 20:31:07 2021 +++ src/usr.bin/xlint/lint1/err.c Fri Mar 26 21:05:27 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: err.c,v 1.93 2021/03/26 20:31:07 rillig Exp $ */ +/* $NetBSD: err.c,v 1.94 2021/03/26 21:05:27 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: err.c,v 1.93 2021/03/26 20:31:07 rillig Exp $"); +__RCSID("$NetBSD: err.c,v 1.94 2021/03/26 21:05:27 rillig Exp $"); #endif #include @@ -485,13 +485,13 @@ lerror(const char *file, int line, const va_list ap; const char *fn; - va_start(ap, msg); fn = lbasename(curr_pos.p_file); - (void)fprintf(stderr, "%s(%d): lint error: %s, %d: ", - fn, curr_pos.p_line, file, line); + (void)fprintf(stderr, "lint: internal error in %s:%d near %s:%d: ", + file, line, fn, curr_pos.p_line); + va_start(ap, msg); (void)vfprintf(stderr, msg, ap); - (void)fprintf(stderr, "\n"); va_end(ap); + (void)fprintf(stderr, "\n"); abort(); }
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: christos Date: Fri Mar 26 20:51:34 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c Log Message: use __func__ To generate a diff of this commit: cvs rdiff -u -r1.161 -r1.162 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.161 src/usr.bin/xlint/lint1/decl.c:1.162 --- src/usr.bin/xlint/lint1/decl.c:1.161 Fri Mar 26 16:31:07 2021 +++ src/usr.bin/xlint/lint1/decl.c Fri Mar 26 16:51:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.161 2021/03/26 20:31:07 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.162 2021/03/26 20:51:34 christos 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.161 2021/03/26 20:31:07 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.162 2021/03/26 20:51:34 christos Exp $"); #endif #include @@ -599,8 +599,7 @@ begin_declaration_level(scl_t sc) di->d_ctx = sc; di->d_ldlsym = >d_dlsyms; if (dflag) - (void)printf("begin_declaration_level(%p %d)\n", - dcs, (int)sc); + (void)printf("%s(%p %d)\n", __func__, dcs, (int)sc); } @@ -613,8 +612,7 @@ end_declaration_level(void) dinfo_t *di; if (dflag) - (void)printf("end_declaration_level(%p %d)\n", - dcs, (int)dcs->d_ctx); + (void)printf("%s(%p %d)\n", __func__, dcs, (int)dcs->d_ctx); lint_assert(dcs->d_next != NULL); di = dcs;
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: christos Date: Fri Mar 26 20:51:34 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c Log Message: use __func__ To generate a diff of this commit: cvs rdiff -u -r1.161 -r1.162 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.
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Fri Mar 26 20:31:07 UTC 2021 Modified Files: src/usr.bin/xlint/common: tyname.c src/usr.bin/xlint/lint1: cgram.y decl.c err.c func.c init.c lex.c main1.c mem1.c tree.c src/usr.bin/xlint/lint2: chk.c emit2.c hash.c main2.c read.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)' No functional change. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/usr.bin/xlint/common/tyname.c cvs rdiff -u -r1.203 -r1.204 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.160 -r1.161 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.92 -r1.93 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.97 -r1.98 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.133 -r1.134 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.16 -r1.17 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.38 -r1.39 src/usr.bin/xlint/lint1/main1.c cvs rdiff -u -r1.27 -r1.28 src/usr.bin/xlint/lint1/mem1.c cvs rdiff -u -r1.249 -r1.250 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.40 -r1.41 src/usr.bin/xlint/lint2/chk.c \ src/usr.bin/xlint/lint2/read.c cvs rdiff -u -r1.17 -r1.18 src/usr.bin/xlint/lint2/emit2.c cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/lint2/hash.c \ src/usr.bin/xlint/lint2/main2.c cvs rdiff -u -r1.56 -r1.57 src/usr.bin/xlint/xlint/xlint.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Fri Mar 26 20:31:07 UTC 2021 Modified Files: src/usr.bin/xlint/common: tyname.c src/usr.bin/xlint/lint1: cgram.y decl.c err.c func.c init.c lex.c main1.c mem1.c tree.c src/usr.bin/xlint/lint2: chk.c emit2.c hash.c main2.c read.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)' No functional change. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/usr.bin/xlint/common/tyname.c cvs rdiff -u -r1.203 -r1.204 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.160 -r1.161 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.92 -r1.93 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.97 -r1.98 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.133 -r1.134 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.16 -r1.17 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.38 -r1.39 src/usr.bin/xlint/lint1/main1.c cvs rdiff -u -r1.27 -r1.28 src/usr.bin/xlint/lint1/mem1.c cvs rdiff -u -r1.249 -r1.250 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.40 -r1.41 src/usr.bin/xlint/lint2/chk.c \ src/usr.bin/xlint/lint2/read.c cvs rdiff -u -r1.17 -r1.18 src/usr.bin/xlint/lint2/emit2.c cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/lint2/hash.c \ src/usr.bin/xlint/lint2/main2.c cvs rdiff -u -r1.56 -r1.57 src/usr.bin/xlint/xlint/xlint.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/common/tyname.c diff -u src/usr.bin/xlint/common/tyname.c:1.34 src/usr.bin/xlint/common/tyname.c:1.35 --- src/usr.bin/xlint/common/tyname.c:1.34 Sun Mar 7 17:12:41 2021 +++ src/usr.bin/xlint/common/tyname.c Fri Mar 26 20:31:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tyname.c,v 1.34 2021/03/07 17:12:41 rillig Exp $ */ +/* $NetBSD: tyname.c,v 1.35 2021/03/26 20:31:07 rillig Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tyname.c,v 1.34 2021/03/07 17:12:41 rillig Exp $"); +__RCSID("$NetBSD: tyname.c,v 1.35 2021/03/26 20:31:07 rillig Exp $"); #endif #include @@ -74,7 +74,7 @@ new_name_tree_node(const char *name) { name_tree_node *n; - n = xmalloc(sizeof(*n)); + n = xmalloc(sizeof *n); n->ntn_name = xstrdup(name); n->ntn_less = NULL; n->ntn_greater = NULL; @@ -137,7 +137,7 @@ buf_add(buffer *buf, const char *s) static void buf_add_int(buffer *buf, int n) { - char num[1 + sizeof(n) * CHAR_BIT + 1]; + char num[1 + sizeof n * CHAR_BIT + 1]; snprintf(num, sizeof num, "%d", n); buf_add(buf, num); Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.203 src/usr.bin/xlint/lint1/cgram.y:1.204 --- src/usr.bin/xlint/lint1/cgram.y:1.203 Fri Mar 26 18:54:39 2021 +++ src/usr.bin/xlint/lint1/cgram.y Fri Mar 26 20:31:07 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.203 2021/03/26 18:54:39 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.204 2021/03/26 20:31:07 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.203 2021/03/26 18:54:39 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.204 2021/03/26 20:31:07 rillig Exp $"); #endif #include @@ -1197,7 +1197,7 @@ pointer: asterisk: T_ASTERISK { - $$ = xcalloc(1, sizeof (pqinf_t)); + $$ = xcalloc(1, sizeof *$$); $$->p_pcnt = 1; } ; @@ -1213,7 +1213,7 @@ type_qualifier_list: type_qualifier: T_QUAL { - $$ = xcalloc(1, sizeof (pqinf_t)); + $$ = xcalloc(1, sizeof *$$); if ($1 == CONST) { $$->p_const = true; } else if ($1 == VOLATILE) { Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.160 src/usr.bin/xlint/lint1/decl.c:1.161 --- src/usr.bin/xlint/lint1/decl.c:1.160 Fri Mar 26 17:44:52 2021 +++ src/usr.bin/xlint/lint1/decl.c Fri Mar 26 20:31:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.160 2021/03/26 17:44:52 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.161 2021/03/26 20:31: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.160 2021/03/26 17:44:52 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.161 2021/03/26 20:31:07 rillig Exp $"); #endif #include @@ -91,7 +91,7 @@ initdecl(void) int i; /* declaration stack */ - dcs = xcalloc(1, sizeof (dinfo_t)); + dcs = xcalloc(1, sizeof *dcs); dcs->d_ctx = EXTERN; dcs->d_ldlsym = >d_dlsyms; @@ -99,7 +99,7 @@ initdecl(void) inittyp(); /* shared type structures */ - typetab = xcalloc(NTSPEC, sizeof (type_t)); + typetab = xcalloc(NTSPEC, sizeof *typetab); for (i = 0; i < NTSPEC; i++) typetab[i].t_tspec = NOTSPEC; typetab[BOOL].t_tspec = BOOL; @@ -162,7 +162,7 @@ tduptyp(const type_t *tp)
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 19:17:58 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: func.c lint1.h Log Message: lint: rename members of struct control_statement to be more expressive C99 does not define names for the head parts of the 'for' statements, it just calls them clause-1, expression-2 and expression-3. Therefore the rather abstract name 'expr3'. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.88 -r1.89 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.96 src/usr.bin/xlint/lint1/func.c:1.97 --- src/usr.bin/xlint/lint1/func.c:1.96 Fri Mar 26 18:54:39 2021 +++ src/usr.bin/xlint/lint1/func.c Fri Mar 26 19:17:58 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.96 2021/03/26 18:54:39 rillig Exp $ */ +/* $NetBSD: func.c,v 1.97 2021/03/26 19:17:58 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.96 2021/03/26 18:54:39 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.97 2021/03/26 19:17:58 rillig Exp $"); #endif #include @@ -183,7 +183,7 @@ end_control_statement(control_statement_ free(cl); } - free(ci->c_swtype); + free(ci->c_switch_type); free(ci); } @@ -439,15 +439,15 @@ check_case_label_enum(const tnode_t *tn, { /* similar to typeok_enum in tree.c */ - if (!(tn->tn_type->t_is_enum || ci->c_swtype->t_is_enum)) + if (!(tn->tn_type->t_is_enum || ci->c_switch_type->t_is_enum)) return; - if (tn->tn_type->t_is_enum && ci->c_swtype->t_is_enum && - tn->tn_type->t_enum == ci->c_swtype->t_enum) + if (tn->tn_type->t_is_enum && ci->c_switch_type->t_is_enum && + tn->tn_type->t_enum == ci->c_switch_type->t_enum) return; #if 0 /* not yet ready, see msg_130.c */ /* enum type mismatch: '%s' '%s' '%s' */ - warning(130, type_name(ci->c_swtype), getopname(EQ), + warning(130, type_name(ci->c_switch_type), getopname(EQ), type_name(tn->tn_type)); #endif } @@ -480,7 +480,7 @@ check_case_label(tnode_t *tn, cstk_t *ci check_case_label_enum(tn, ci); - lint_assert(ci->c_swtype != NULL); + lint_assert(ci->c_switch_type != NULL); if (reached && !seen_fallthrough) { if (hflag) @@ -502,7 +502,7 @@ check_case_label(tnode_t *tn, cstk_t *ci */ v = constant(tn, true); (void)memset(, 0, sizeof nv); - convert_constant(CASE, 0, ci->c_swtype, , v); + convert_constant(CASE, 0, ci->c_switch_type, , v); free(v); /* look if we had this value already */ @@ -697,7 +697,7 @@ switch1(tnode_t *tn) begin_control_statement(CS_SWITCH); cstmt->c_switch = true; - cstmt->c_swtype = tp; + cstmt->c_switch_type = tp; set_reached(false); seen_fallthrough = true; @@ -713,17 +713,17 @@ switch2(void) sym_t *esym; case_label_t *cl; - lint_assert(cstmt->c_swtype != NULL); + lint_assert(cstmt->c_switch_type != NULL); /* * If the switch expression was of type enumeration, count the case * labels and the number of enumerators. If both counts are not * equal print a warning. */ - if (cstmt->c_swtype->t_is_enum) { + if (cstmt->c_switch_type->t_is_enum) { nenum = nclab = 0; - lint_assert(cstmt->c_swtype->t_enum != NULL); - for (esym = cstmt->c_swtype->t_enum->en_first_enumerator; + lint_assert(cstmt->c_switch_type->t_enum != NULL); + for (esym = cstmt->c_switch_type->t_enum->en_first_enumerator; esym != NULL; esym = esym->s_next) { nenum++; } @@ -744,7 +744,8 @@ switch2(void) */ set_reached(true); } else if (!cstmt->c_default && - (!hflag || !cstmt->c_swtype->t_is_enum || nenum != nclab)) { + (!hflag || !cstmt->c_switch_type->t_is_enum || + nenum != nclab)) { /* * there are possible values which are not handled in * switch @@ -882,10 +883,10 @@ for1(tnode_t *tn1, tnode_t *tn2, tnode_t * Also remember this expression itself. We must check it at * the end of the loop to get "used but not set" warnings correct. */ - cstmt->c_fexprm = tsave(); - cstmt->c_f3expr = tn3; - cstmt->c_fpos = curr_pos; - cstmt->c_cfpos = csrc_pos; + cstmt->c_for_expr3_mem = tsave(); + cstmt->c_for_expr3 = tn3; + cstmt->c_for_expr3_pos = curr_pos; + cstmt->c_for_expr3_csrc_pos = csrc_pos; if (tn1 != NULL) expr(tn1, false, false, true, false); @@ -919,10 +920,10 @@ for2(void) cspos = csrc_pos; /* Restore the tree memory for the reinitialization expression */ - trestor(cstmt->c_fexprm); - tn3 = cstmt->c_f3expr; - curr_pos = cstmt->c_fpos; - csrc_pos = cstmt->c_cfpos; + trestor(cstmt->c_for_expr3_mem); + tn3 = cstmt->c_for_expr3; + curr_pos = cstmt->c_for_expr3_pos; + csrc_pos = cstmt->c_for_expr3_csrc_pos; /* simply "statement not reached" would be confusing */ if (!reached &&
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 19:17:58 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: func.c lint1.h Log Message: lint: rename members of struct control_statement to be more expressive C99 does not define names for the head parts of the 'for' statements, it just calls them clause-1, expression-2 and expression-3. Therefore the rather abstract name 'expr3'. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.88 -r1.89 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.
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 18:54:39 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y externs1.h func.c lint1.h Log Message: lint: rename pushctrl and popctrl to be more expressive While here, remove the magic number 0 that in this context means "function body". No functional change. To generate a diff of this commit: cvs rdiff -u -r1.202 -r1.203 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.86 -r1.87 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.95 -r1.96 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.87 -r1.88 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.202 src/usr.bin/xlint/lint1/cgram.y:1.203 --- src/usr.bin/xlint/lint1/cgram.y:1.202 Fri Mar 26 17:44:52 2021 +++ src/usr.bin/xlint/lint1/cgram.y Fri Mar 26 18:54:39 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.202 2021/03/26 17:44:52 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.203 2021/03/26 18:54:39 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.202 2021/03/26 17:44:52 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.203 2021/03/26 18:54:39 rillig Exp $"); #endif #include @@ -447,10 +447,10 @@ function_definition: /* C99 6.9.1 */ block_level--; check_func_lint_directives(); check_func_old_style_arguments(); - pushctrl(0); + begin_control_statement(CS_FUNCTION_BODY); } compound_statement { funcend(); - popctrl(0); + end_control_statement(CS_FUNCTION_BODY); } ; Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.86 src/usr.bin/xlint/lint1/externs1.h:1.87 --- src/usr.bin/xlint/lint1/externs1.h:1.86 Fri Mar 26 17:44:52 2021 +++ src/usr.bin/xlint/lint1/externs1.h Fri Mar 26 18:54:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.86 2021/03/26 17:44:52 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.87 2021/03/26 18:54:39 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -252,8 +252,8 @@ extern bool bitfieldtype_ok; extern bool plibflg; extern bool quadflg; -extern void pushctrl(int); -extern void popctrl(int); +extern void begin_control_statement(control_statement_kind); +extern void end_control_statement(control_statement_kind); extern void check_statement_reachable(void); extern void funcdef(sym_t *); extern void funcend(void); Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.95 src/usr.bin/xlint/lint1/func.c:1.96 --- src/usr.bin/xlint/lint1/func.c:1.95 Sun Mar 21 19:14:40 2021 +++ src/usr.bin/xlint/lint1/func.c Fri Mar 26 18:54:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.95 2021/03/21 19:14:40 rillig Exp $ */ +/* $NetBSD: func.c,v 1.96 2021/03/26 18:54:39 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.95 2021/03/21 19:14:40 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.96 2021/03/26 18:54:39 rillig Exp $"); #endif #include @@ -153,12 +153,12 @@ bool quadflg; * Puts a new element at the top of the stack used for control statements. */ void -pushctrl(int env) +begin_control_statement(control_statement_kind kind) { cstk_t *ci; ci = xcalloc(1, sizeof (cstk_t)); - ci->c_env = env; + ci->c_kind = kind; ci->c_surrounding = cstmt; cstmt = ci; } @@ -167,13 +167,13 @@ pushctrl(int env) * Removes the top element of the stack used for control statements. */ void -popctrl(int env) +end_control_statement(control_statement_kind kind) { cstk_t *ci; case_label_t *cl, *next; lint_assert(cstmt != NULL); - lint_assert(cstmt->c_env == env); + lint_assert(cstmt->c_kind == kind); ci = cstmt; cstmt = ci->c_surrounding; @@ -611,7 +611,7 @@ if1(tnode_t *tn) tn = check_controlling_expression(tn); if (tn != NULL) expr(tn, false, true, false, false); - pushctrl(T_IF); + begin_control_statement(CS_IF); if (tn != NULL && tn->tn_op == CON && !tn->tn_system_dependent) { /* XXX: what if inside 'if (0)'? */ @@ -648,7 +648,7 @@ if3(bool els) else if (!els) set_reached(true); - popctrl(T_IF); + end_control_statement(CS_IF); } /* @@ -695,7 +695,7 @@ switch1(tnode_t *tn) check_getopt_begin_switch(); expr(tn, true, false, true, false); - pushctrl(T_SWITCH); + begin_control_statement(CS_SWITCH); cstmt->c_switch = true; cstmt->c_swtype = tp; @@ -755,7 +755,7 @@ switch2(void) * if the end of the last statement inside it is reached. */ - popctrl(T_SWITCH); + end_control_statement(CS_SWITCH); } /* @@ -776,7 +776,7 @@ while1(tnode_t *tn) if (tn != NULL) tn = check_controlling_expression(tn); - pushctrl(T_WHILE); + begin_control_statement(CS_WHILE);
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 18:54:39 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y externs1.h func.c lint1.h Log Message: lint: rename pushctrl and popctrl to be more expressive While here, remove the magic number 0 that in this context means "function body". No functional change. To generate a diff of this commit: cvs rdiff -u -r1.202 -r1.203 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.86 -r1.87 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.95 -r1.96 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.87 -r1.88 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.
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 17:44:52 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y decl.c externs1.h Log Message: lint: rename pushdecl and popdecl to be more expressive The previous names were highly ambiguous. The 'decl' could have meant 'declaration', which would be the usual abbreviation. It could also be split into 'dec' and 'l', meaning 'declaration level', which would make more sense in this particular context. To avoid having to guess anything about these names, rename the functions. Instead of 'push' and 'pop', I renamed them to 'begin' and 'end' since these are the high-level operation that are of interest. That the hierarchy of declaration levels is implemented as a stack is nice to know but not as important to understand the whole situation. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.201 -r1.202 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.159 -r1.160 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.85 -r1.86 src/usr.bin/xlint/lint1/externs1.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.201 src/usr.bin/xlint/lint1/cgram.y:1.202 --- src/usr.bin/xlint/lint1/cgram.y:1.201 Fri Mar 26 16:05:19 2021 +++ src/usr.bin/xlint/lint1/cgram.y Fri Mar 26 17:44:52 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.201 2021/03/26 16:05:19 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.202 2021/03/26 17:44:52 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.201 2021/03/26 16:05:19 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.202 2021/03/26 17:44:52 rillig Exp $"); #endif #include @@ -439,11 +439,11 @@ function_definition: /* C99 6.9.1 */ } funcdef($1); block_level++; - pushdecl(ARG); + begin_declaration_level(ARG); if (lwarn == LWARN_NONE) $1->s_used = true; } arg_declaration_list_opt { - popdecl(); + end_declaration_level(); block_level--; check_func_lint_directives(); check_func_old_style_arguments(); @@ -703,11 +703,11 @@ notype_typespec: $$ = $2->tn_type; } | struct_spec { - popdecl(); + end_declaration_level(); $$ = $1; } | enum_spec { - popdecl(); + end_declaration_level(); $$ = $1; } ; @@ -743,7 +743,7 @@ struct: struct type_attribute | T_STRUCT_OR_UNION { symtyp = FTAG; - pushdecl($1 == STRUCT ? MOS : MOU); + begin_declaration_level($1 == STRUCT ? MOS : MOU); dcs->d_offset = 0; dcs->d_stralign = CHAR_SIZE; $$ = $1; @@ -940,7 +940,7 @@ enum_spec: enum: T_ENUM { symtyp = FTAG; - pushdecl(CTCONST); + begin_declaration_level(CTCONST); } ; @@ -1072,7 +1072,7 @@ notype_direct_decl: } | notype_direct_decl param_list opt_asm_or_symbolrename { $$ = add_function(symbolrename($1, $3), $2); - popdecl(); + end_declaration_level(); block_level--; } | notype_direct_decl type_attribute_list @@ -1105,7 +1105,7 @@ type_direct_decl: } | type_direct_decl param_list opt_asm_or_symbolrename { $$ = add_function(symbolrename($1, $3), $2); - popdecl(); + end_declaration_level(); block_level--; } | type_direct_decl type_attribute_list @@ -1145,7 +1145,7 @@ direct_param_decl: } | direct_param_decl param_list opt_asm_or_symbolrename { $$ = add_function(symbolrename($1, $3), $2); - popdecl(); + end_declaration_level(); block_level--; } ; @@ -1174,7 +1174,7 @@ direct_notype_param_decl: } | direct_notype_param_decl param_list opt_asm_or_symbolrename { $$ = add_function(symbolrename($1, $3), $2); - popdecl(); + end_declaration_level(); block_level--; } ; @@ -1236,7 +1236,7 @@ param_list: id_list_lparen: T_LPAREN { block_level++; - pushdecl(PROTO_ARG); + begin_declaration_level(PROTO_ARG); } ; @@ -1268,7 +1268,7 @@ abstract_decl_param_list: abstract_decl_lparen: T_LPAREN { block_level++; - pushdecl(PROTO_ARG); + begin_declaration_level(PROTO_ARG); } ; @@ -1420,9 +1420,9 @@ init_rbrace: type_name: { - pushdecl(ABSTRACT); + begin_declaration_level(ABSTRACT); } abstract_declaration { - popdecl(); + end_declaration_level(); $$ = $2->s_type; } ; @@ -1478,12 +1478,12 @@ direct_abstract_decl: } | abstract_decl_param_list opt_asm_or_symbolrename { $$ = add_function(symbolrename(abstract_name(), $2), $1); - popdecl(); + end_declaration_level(); block_level--; } | direct_abstract_decl abstract_decl_param_list opt_asm_or_symbolrename { $$ = add_function(symbolrename($1, $3), $2); - popdecl(); + end_declaration_level(); block_level--; } | direct_abstract_decl type_attribute_list @@ -1537,13 +1537,13 @@ compound_statement_lbrace: T_LBRACE { block_level++;
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 17:44:52 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y decl.c externs1.h Log Message: lint: rename pushdecl and popdecl to be more expressive The previous names were highly ambiguous. The 'decl' could have meant 'declaration', which would be the usual abbreviation. It could also be split into 'dec' and 'l', meaning 'declaration level', which would make more sense in this particular context. To avoid having to guess anything about these names, rename the functions. Instead of 'push' and 'pop', I renamed them to 'begin' and 'end' since these are the high-level operation that are of interest. That the hierarchy of declaration levels is implemented as a stack is nice to know but not as important to understand the whole situation. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.201 -r1.202 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.159 -r1.160 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.85 -r1.86 src/usr.bin/xlint/lint1/externs1.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: rillig Date: Fri Mar 26 16:59:19 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_247.c msg_247.exp src/usr.bin/xlint/lint1: tree.c Log Message: lint: allow pointer cast to 'char *' and 'unsigned char *' This reduces the number of warnings in the regular NetBSD build by 5560. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_247.c cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_247.exp cvs rdiff -u -r1.248 -r1.249 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_247.c diff -u src/tests/usr.bin/xlint/lint1/msg_247.c:1.6 src/tests/usr.bin/xlint/lint1/msg_247.c:1.7 --- src/tests/usr.bin/xlint/lint1/msg_247.c:1.6 Fri Mar 26 16:19:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_247.c Fri Mar 26 16:59:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_247.c,v 1.6 2021/03/26 16:19:43 rillig Exp $ */ +/* $NetBSD: msg_247.c,v 1.7 2021/03/26 16:59:19 rillig Exp $ */ # 3 "msg_247.c" // Test for message: pointer cast from '%s' to '%s' may be troublesome [247] @@ -45,7 +45,7 @@ example(struct Other *arg) char * cast_to_char_pointer(struct Other *arg) { - return (char *)arg; /* expect: 247 *//* FIXME */ + return (char *)arg; } /* @@ -55,7 +55,7 @@ cast_to_char_pointer(struct Other *arg) unsigned char * cast_to_unsigned_char_pointer(struct Other *arg) { - return (unsigned char *)arg; /* expect: 247 *//* FIXME */ + return (unsigned char *)arg; } /* Index: src/tests/usr.bin/xlint/lint1/msg_247.exp diff -u src/tests/usr.bin/xlint/lint1/msg_247.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_247.exp:1.5 --- src/tests/usr.bin/xlint/lint1/msg_247.exp:1.4 Fri Mar 26 16:19:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_247.exp Fri Mar 26 16:59:19 2021 @@ -1,4 +1,2 @@ msg_247.c(31): warning: pointer cast from 'pointer to struct Other' to 'pointer to struct ' may be troublesome [247] -msg_247.c(48): warning: pointer cast from 'pointer to struct Other' to 'pointer to char' may be troublesome [247] -msg_247.c(58): warning: pointer cast from 'pointer to struct Other' to 'pointer to unsigned char' may be troublesome [247] msg_247.c(70): warning: pointer cast from 'pointer to struct Other' to 'pointer to signed char' may be troublesome [247] Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.248 src/usr.bin/xlint/lint1/tree.c:1.249 --- src/usr.bin/xlint/lint1/tree.c:1.248 Fri Mar 26 16:53:19 2021 +++ src/usr.bin/xlint/lint1/tree.c Fri Mar 26 16:59:18 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.248 2021/03/26 16:53:19 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.249 2021/03/26 16:59:18 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.248 2021/03/26 16:53:19 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.249 2021/03/26 16:59:18 rillig Exp $"); #endif #include @@ -2230,6 +2230,9 @@ should_warn_about_pointer_cast(const typ if (tp->t_subt->t_str != tn->tn_type->t_subt->t_str) return true; + if (nst == CHAR || nst == UCHAR) + return false; /* for the sake of traditional C code */ + /* * XXX: Why should it be ok to cast between arbitrary structs that * just happen to be of the same size?
CVS commit: src
Module Name:src Committed By: rillig Date: Fri Mar 26 16:59:19 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_247.c msg_247.exp src/usr.bin/xlint/lint1: tree.c Log Message: lint: allow pointer cast to 'char *' and 'unsigned char *' This reduces the number of warnings in the regular NetBSD build by 5560. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_247.c cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_247.exp cvs rdiff -u -r1.248 -r1.249 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.
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 16:53:19 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: rename variables in check_pointer_conversion No functional change. To generate a diff of this commit: cvs rdiff -u -r1.247 -r1.248 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.247 src/usr.bin/xlint/lint1/tree.c:1.248 --- src/usr.bin/xlint/lint1/tree.c:1.247 Fri Mar 26 16:45:06 2021 +++ src/usr.bin/xlint/lint1/tree.c Fri Mar 26 16:53:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.247 2021/03/26 16:45:06 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.248 2021/03/26 16:53:19 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.247 2021/03/26 16:45:06 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.248 2021/03/26 16:53:19 rillig Exp $"); #endif #include @@ -2238,13 +2238,13 @@ should_warn_about_pointer_cast(const typ } /* - * Print warnings for questionable pointer conversions. + * Warn about questionable pointer conversions. */ static void check_pointer_conversion(op_t op, tnode_t *tn, type_t *tp) { - tspec_t nt, ot; - const char *nts, *ots; + tspec_t nst, ost; + const char *nts, *ots; /* * We got already an error (pointers of different types @@ -2253,22 +2253,21 @@ check_pointer_conversion(op_t op, tnode_ if (op != CVT) return; - /* TODO: rename to 'nst' and 'ost' */ - nt = tp->t_subt->t_tspec; - ot = tn->tn_type->t_subt->t_tspec; - - if (nt == VOID || ot == VOID) { - if (sflag && (nt == FUNC || ot == FUNC)) { - /* (void *)0 already handled in convert() */ - *(nt == FUNC ? : ) = "function pointer"; - *(nt == VOID ? : ) = "'void *'"; + nst = tp->t_subt->t_tspec; + ost = tn->tn_type->t_subt->t_tspec; + + if (nst == VOID || ost == VOID) { + if (sflag && (nst == FUNC || ost == FUNC)) { + /* null pointers are already handled in convert() */ + *(nst == FUNC ? : ) = "function pointer"; + *(nst == VOID ? : ) = "'void *'"; /* ANSI C forbids conversion of %s to %s */ warning(303, ots, nts); } return; - } else if (nt == FUNC && ot == FUNC) { + } else if (nst == FUNC && ost == FUNC) { return; - } else if (nt == FUNC || ot == FUNC) { + } else if (nst == FUNC || ost == FUNC) { /* converting '%s' to '%s' is questionable */ warning(229, type_name(tn->tn_type), type_name(tp)); return; @@ -2280,7 +2279,7 @@ check_pointer_conversion(op_t op, tnode_ warning(135, type_name(tn->tn_type), type_name(tp)); } - if (cflag && should_warn_about_pointer_cast(tp, nt, tn, ot)) { + if (cflag && should_warn_about_pointer_cast(tp, nst, tn, ost)) { /* pointer cast from '%s' to '%s' may be troublesome */ warning(247, type_name(tn->tn_type), type_name(tp)); }
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 16:53:19 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: rename variables in check_pointer_conversion No functional change. To generate a diff of this commit: cvs rdiff -u -r1.247 -r1.248 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.
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 16:45:06 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: extract decision for warning about pointer cast This makes the code several lines longer but way more readable. In the previous dense expression it was hard to see what was going on at all and that there are two completely separate situations in which this warning applies. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.246 -r1.247 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.246 src/usr.bin/xlint/lint1/tree.c:1.247 --- src/usr.bin/xlint/lint1/tree.c:1.246 Mon Mar 22 15:29:43 2021 +++ src/usr.bin/xlint/lint1/tree.c Fri Mar 26 16:45:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.246 2021/03/22 15:29:43 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.247 2021/03/26 16:45:06 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.246 2021/03/22 15:29:43 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.247 2021/03/26 16:45:06 rillig Exp $"); #endif #include @@ -,6 +,21 @@ check_pointer_integer_conversion(op_t op } } +static bool +should_warn_about_pointer_cast(const type_t *tp, tspec_t nst, + const tnode_t *tn, tspec_t ost) +{ + if (nst == STRUCT || nst == UNION) + if (tp->t_subt->t_str != tn->tn_type->t_subt->t_str) + return true; + + /* + * XXX: Why should it be ok to cast between arbitrary structs that + * just happen to be of the same size? + */ + return portable_size_in_bits(nst) != portable_size_in_bits(ost); +} + /* * Print warnings for questionable pointer conversions. */ @@ -2238,6 +2253,7 @@ check_pointer_conversion(op_t op, tnode_ if (op != CVT) return; + /* TODO: rename to 'nst' and 'ost' */ nt = tp->t_subt->t_tspec; ot = tn->tn_type->t_subt->t_tspec; @@ -2264,13 +2280,9 @@ check_pointer_conversion(op_t op, tnode_ warning(135, type_name(tn->tn_type), type_name(tp)); } - if (((nt == STRUCT || nt == UNION) && - tp->t_subt->t_str != tn->tn_type->t_subt->t_str) || - portable_size_in_bits(nt) != portable_size_in_bits(ot)) { - if (cflag) { - /* pointer cast from '%s' to '%s' may be troublesome */ - warning(247, type_name(tn->tn_type), type_name(tp)); - } + if (cflag && should_warn_about_pointer_cast(tp, nt, tn, ot)) { + /* pointer cast from '%s' to '%s' may be troublesome */ + warning(247, type_name(tn->tn_type), type_name(tp)); } }
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 16:45:06 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: extract decision for warning about pointer cast This makes the code several lines longer but way more readable. In the previous dense expression it was hard to see what was going on at all and that there are two completely separate situations in which this warning applies. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.246 -r1.247 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.
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 16:19:43 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_247.c msg_247.exp Log Message: tests/lint: add tests for warning about cast to character types To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_247.c cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_247.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_247.c diff -u src/tests/usr.bin/xlint/lint1/msg_247.c:1.5 src/tests/usr.bin/xlint/lint1/msg_247.c:1.6 --- src/tests/usr.bin/xlint/lint1/msg_247.c:1.5 Sun Mar 14 22:24:24 2021 +++ src/tests/usr.bin/xlint/lint1/msg_247.c Fri Mar 26 16:19:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_247.c,v 1.5 2021/03/14 22:24:24 rillig Exp $ */ +/* $NetBSD: msg_247.c,v 1.6 2021/03/26 16:19:43 rillig Exp $ */ # 3 "msg_247.c" // Test for message: pointer cast from '%s' to '%s' may be troublesome [247] @@ -30,3 +30,48 @@ example(struct Other *arg) */ display = (PDisplay)arg; /* expect: 247 */ } + +/* + * C code with a long history that has existed in pre-C90 times already often + * uses 'pointer to char' where modern code would use 'pointer to void'. + * Since 'char' is the most general underlying type, there is nothing wrong + * with casting to it. An example for this type of code is X11. + * + * Casting to 'pointer to char' may also be used by programmers who don't know + * about endianness, but that's not something lint can do anything about. The + * code for these two use cases looks exactly the same, so lint errs on the + * side of fewer false positive warnings here. (after fixing the FIXME below) + */ +char * +cast_to_char_pointer(struct Other *arg) +{ + return (char *)arg; /* expect: 247 *//* FIXME */ +} + +/* + * In traditional C there was 'unsigned char' as well, so the same reasoning + * as for plain 'char' applies here. + */ +unsigned char * +cast_to_unsigned_char_pointer(struct Other *arg) +{ + return (unsigned char *)arg; /* expect: 247 *//* FIXME */ +} + +/* + * Traditional C does not have the type specifier 'signed', which means that + * this type cannot be used by old code. Therefore warn about this. All code + * that triggers this warning should do the intermediate cast via 'void + * pointer'. + */ +signed char * +cast_to_signed_char_pointer(struct Other *arg) +{ + return (signed char *)arg; /* expect: 247 */ +} + +char * +cast_to_void_pointer_then_to_char_pointer(struct Other *arg) +{ + return (char *)(void *)arg; +} Index: src/tests/usr.bin/xlint/lint1/msg_247.exp diff -u src/tests/usr.bin/xlint/lint1/msg_247.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_247.exp:1.4 --- src/tests/usr.bin/xlint/lint1/msg_247.exp:1.3 Sun Mar 14 22:24:24 2021 +++ src/tests/usr.bin/xlint/lint1/msg_247.exp Fri Mar 26 16:19:43 2021 @@ -1 +1,4 @@ msg_247.c(31): warning: pointer cast from 'pointer to struct Other' to 'pointer to struct ' may be troublesome [247] +msg_247.c(48): warning: pointer cast from 'pointer to struct Other' to 'pointer to char' may be troublesome [247] +msg_247.c(58): warning: pointer cast from 'pointer to struct Other' to 'pointer to unsigned char' may be troublesome [247] +msg_247.c(70): warning: pointer cast from 'pointer to struct Other' to 'pointer to signed char' may be troublesome [247]
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 16:19:43 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_247.c msg_247.exp Log Message: tests/lint: add tests for warning about cast to character types To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_247.c cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_247.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 16:05:19 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: remove redundant '%prec' from grammar for compound literals No change to the resulting binary. To generate a diff of this commit: cvs rdiff -u -r1.200 -r1.201 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.200 src/usr.bin/xlint/lint1/cgram.y:1.201 --- src/usr.bin/xlint/lint1/cgram.y:1.200 Thu Mar 25 21:51:55 2021 +++ src/usr.bin/xlint/lint1/cgram.y Fri Mar 26 16:05:19 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.200 2021/03/25 21:51:55 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.201 2021/03/26 16:05:19 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.200 2021/03/25 21:51:55 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.201 2021/03/26 16:05:19 rillig Exp $"); #endif #include @@ -1996,7 +1996,7 @@ term: | T_LPAREN type_name T_RPAREN term %prec T_UNARY { $$ = cast($4, $2); } - | T_LPAREN type_name T_RPAREN %prec T_UNARY { + | T_LPAREN type_name T_RPAREN { /* C99 6.5.2.5 "Compound literals" */ sym_t *tmp = mktempsym($2); begin_initialization(tmp); cgram_declare(tmp, true, NULL);
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Mar 26 16:05:19 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: remove redundant '%prec' from grammar for compound literals No change to the resulting binary. To generate a diff of this commit: cvs rdiff -u -r1.200 -r1.201 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.
CVS commit: src/sys/dev/nvmm
Module Name:src Committed By: reinoud Date: Fri Mar 26 15:59:53 UTC 2021 Modified Files: src/sys/dev/nvmm: nvmm.c nvmm.h nvmm_internal.h src/sys/dev/nvmm/x86: nvmm_x86.h nvmm_x86_svm.c nvmm_x86_vmx.c Log Message: Implement nvmm_vcpu::stop, a race-free exit from nvmm_vcpu_run() without signals. This introduces a new kernel and userland NVMM version indicating this support. Patch by Kamil Rytarowski and committed on his request. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/nvmm/nvmm.c cvs rdiff -u -r1.15 -r1.16 src/sys/dev/nvmm/nvmm.h cvs rdiff -u -r1.19 -r1.20 src/sys/dev/nvmm/nvmm_internal.h cvs rdiff -u -r1.20 -r1.21 src/sys/dev/nvmm/x86/nvmm_x86.h cvs rdiff -u -r1.82 -r1.83 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.81 -r1.82 src/sys/dev/nvmm/x86/nvmm_x86_vmx.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/nvmm/nvmm.c diff -u src/sys/dev/nvmm/nvmm.c:1.41 src/sys/dev/nvmm/nvmm.c:1.42 --- src/sys/dev/nvmm/nvmm.c:1.41 Tue Sep 8 16:58:38 2020 +++ src/sys/dev/nvmm/nvmm.c Fri Mar 26 15:59:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm.c,v 1.41 2020/09/08 16:58:38 maxv Exp $ */ +/* $NetBSD: nvmm.c,v 1.42 2021/03/26 15:59:53 reinoud Exp $ */ /* * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.41 2020/09/08 16:58:38 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.42 2021/03/26 15:59:53 reinoud Exp $"); #include #include @@ -574,8 +574,7 @@ nvmm_do_vcpu_run(struct nvmm_machine *ma while (1) { /* Got a signal? Or pending resched? Leave. */ - if (__predict_false(nvmm_return_needed())) { - exit->reason = NVMM_VCPU_EXIT_NONE; + if (__predict_false(nvmm_return_needed(vcpu, exit))) { return 0; } @@ -620,6 +619,7 @@ nvmm_vcpu_run(struct nvmm_owner *owner, out: nvmm_machine_put(mach); + vcpu->comm->stop = 0; return error; } Index: src/sys/dev/nvmm/nvmm.h diff -u src/sys/dev/nvmm/nvmm.h:1.15 src/sys/dev/nvmm/nvmm.h:1.16 --- src/sys/dev/nvmm/nvmm.h:1.15 Sat Sep 5 07:22:25 2020 +++ src/sys/dev/nvmm/nvmm.h Fri Mar 26 15:59:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm.h,v 1.15 2020/09/05 07:22:25 maxv Exp $ */ +/* $NetBSD: nvmm.h,v 1.16 2021/03/26 15:59:53 reinoud Exp $ */ /* * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net @@ -47,7 +47,12 @@ typedef uint32_t nvmm_cpuid_t; #include #endif -#define NVMM_KERN_VERSION 1 +#define NVMM_KERN_VERSION 2 + +/* + * Version 1 - Initial release in NetBSD 9.0. + * Version 2 - Added nvmm_vcpu::stop. + */ struct nvmm_capability { uint32_t version; @@ -80,6 +85,9 @@ struct nvmm_comm_page { /* Event. */ bool event_commit; struct nvmm_vcpu_event event; + + /* Race-free exit from nvmm_vcpu_run() without signals. */ + volatile int stop; }; /* Index: src/sys/dev/nvmm/nvmm_internal.h diff -u src/sys/dev/nvmm/nvmm_internal.h:1.19 src/sys/dev/nvmm/nvmm_internal.h:1.20 --- src/sys/dev/nvmm/nvmm_internal.h:1.19 Sun Sep 6 02:18:53 2020 +++ src/sys/dev/nvmm/nvmm_internal.h Fri Mar 26 15:59:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_internal.h,v 1.19 2020/09/06 02:18:53 riastradh Exp $ */ +/* $NetBSD: nvmm_internal.h,v 1.20 2021/03/26 15:59:53 reinoud Exp $ */ /* * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net @@ -136,14 +136,22 @@ extern const struct nvmm_impl nvmm_x86_v #endif static inline bool -nvmm_return_needed(void) +nvmm_return_needed(struct nvmm_cpu *vcpu, struct nvmm_vcpu_exit *exit) { + if (preempt_needed()) { + exit->reason = NVMM_VCPU_EXIT_NONE; return true; } if (curlwp->l_flag & LW_USERRET) { + exit->reason = NVMM_VCPU_EXIT_NONE; + return true; + } + if (vcpu->comm->stop) { + exit->reason = NVMM_VCPU_EXIT_STOPPED; return true; } + return false; } Index: src/sys/dev/nvmm/x86/nvmm_x86.h diff -u src/sys/dev/nvmm/x86/nvmm_x86.h:1.20 src/sys/dev/nvmm/x86/nvmm_x86.h:1.21 --- src/sys/dev/nvmm/x86/nvmm_x86.h:1.20 Sat Sep 5 07:22:26 2020 +++ src/sys/dev/nvmm/x86/nvmm_x86.h Fri Mar 26 15:59:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86.h,v 1.20 2020/09/05 07:22:26 maxv Exp $ */ +/* $NetBSD: nvmm_x86.h,v 1.21 2021/03/26 15:59:53 reinoud Exp $ */ /* * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net @@ -74,6 +74,7 @@ struct nvmm_x86_exit_invalid { /* Generic. */ #define NVMM_VCPU_EXIT_NONE 0xULL +#define NVMM_VCPU_EXIT_STOPPED 0xFFFEULL #define NVMM_VCPU_EXIT_INVALID 0xULL /* x86: operations. */ #define NVMM_VCPU_EXIT_MEMORY 0x0001ULL Index: src/sys/dev/nvmm/x86/nvmm_x86_svm.c diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.82 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.83 --- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.82 Sat Oct 24 07:14:30 2020 +++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c Fri Mar 26 15:59:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86_svm.c,v 1.82
CVS commit: src/sys/dev/nvmm
Module Name:src Committed By: reinoud Date: Fri Mar 26 15:59:53 UTC 2021 Modified Files: src/sys/dev/nvmm: nvmm.c nvmm.h nvmm_internal.h src/sys/dev/nvmm/x86: nvmm_x86.h nvmm_x86_svm.c nvmm_x86_vmx.c Log Message: Implement nvmm_vcpu::stop, a race-free exit from nvmm_vcpu_run() without signals. This introduces a new kernel and userland NVMM version indicating this support. Patch by Kamil Rytarowski and committed on his request. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/nvmm/nvmm.c cvs rdiff -u -r1.15 -r1.16 src/sys/dev/nvmm/nvmm.h cvs rdiff -u -r1.19 -r1.20 src/sys/dev/nvmm/nvmm_internal.h cvs rdiff -u -r1.20 -r1.21 src/sys/dev/nvmm/x86/nvmm_x86.h cvs rdiff -u -r1.82 -r1.83 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.81 -r1.82 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Fri Mar 26 10:35:08 UTC 2021 Modified Files: src/sys/lib/libsa: tftp.c Log Message: Twiddle also for data transfer for seek. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/lib/libsa/tftp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/tftp.c diff -u src/sys/lib/libsa/tftp.c:1.36 src/sys/lib/libsa/tftp.c:1.37 --- src/sys/lib/libsa/tftp.c:1.36 Sun Mar 31 20:08:45 2019 +++ src/sys/lib/libsa/tftp.c Fri Mar 26 10:35:08 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tftp.c,v 1.36 2019/03/31 20:08:45 christos Exp $ */ +/* $NetBSD: tftp.c,v 1.37 2021/03/26 10:35:08 rin Exp $ */ /* * Copyright (c) 1996 @@ -288,11 +288,6 @@ tftp_read(struct open_file *f, void *add int needblock; size_t count; -#if !defined(LIBSA_NO_TWIDDLE) - if (!(tc++ % 16)) - twiddle(); -#endif - needblock = tftpfile->off / SEGSIZE + 1; if (tftpfile->currblock > needblock) { /* seek backwards */ @@ -306,6 +301,11 @@ tftp_read(struct open_file *f, void *add while (tftpfile->currblock < needblock) { int res; +#if !defined(LIBSA_NO_TWIDDLE) + if (!(tc++ % 16)) +twiddle(); +#endif + res = tftp_getnextblock(tftpfile); if (res) { /* no answer */ #ifdef DEBUG
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Fri Mar 26 10:35:08 UTC 2021 Modified Files: src/sys/lib/libsa: tftp.c Log Message: Twiddle also for data transfer for seek. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/lib/libsa/tftp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Fri Mar 26 09:35:18 UTC 2021 Modified Files: src/sys/uvm: uvm_pglist.c Log Message: in uvm_pglistalloc_contig_aggressive(), avoid looking forward past the end of the target range of the physseg. fixes PR 56074. To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/sys/uvm/uvm_pglist.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/uvm/uvm_pglist.c diff -u src/sys/uvm/uvm_pglist.c:1.87 src/sys/uvm/uvm_pglist.c:1.88 --- src/sys/uvm/uvm_pglist.c:1.87 Wed Mar 24 06:37:27 2021 +++ src/sys/uvm/uvm_pglist.c Fri Mar 26 09:35:18 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_pglist.c,v 1.87 2021/03/24 06:37:27 skrll Exp $ */ +/* $NetBSD: uvm_pglist.c,v 1.88 2021/03/26 09:35:18 chs Exp $ */ /*- * Copyright (c) 1997, 2019 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_pglist.c,v 1.87 2021/03/24 06:37:27 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_pglist.c,v 1.88 2021/03/26 09:35:18 chs Exp $"); #include #include @@ -401,6 +401,9 @@ uvm_pglistalloc_contig_aggressive(int nu * Look forward for any remaining pages. */ + if (spa + ptoa(num) > rhi) { + continue; + } for (; run < num; run++) { pg = PHYS_TO_VM_PAGE(spa + ptoa(run)); if ((pg->flags & PG_PGLCA) == 0) {
CVS commit: src/sys/uvm
Module Name:src Committed By: chs Date: Fri Mar 26 09:35:18 UTC 2021 Modified Files: src/sys/uvm: uvm_pglist.c Log Message: in uvm_pglistalloc_contig_aggressive(), avoid looking forward past the end of the target range of the physseg. fixes PR 56074. To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/sys/uvm/uvm_pglist.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/doc
Module Name:src Committed By: wiz Date: Fri Mar 26 08:21:32 UTC 2021 Modified Files: src/doc: 3RDPARTY Log Message: expat 2.3.0 was released To generate a diff of this commit: cvs rdiff -u -r1.1786 -r1.1787 src/doc/3RDPARTY Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/3RDPARTY diff -u src/doc/3RDPARTY:1.1786 src/doc/3RDPARTY:1.1787 --- src/doc/3RDPARTY:1.1786 Thu Mar 25 18:52:23 2021 +++ src/doc/3RDPARTY Fri Mar 26 08:21:32 2021 @@ -1,4 +1,4 @@ -# $NetBSD: 3RDPARTY,v 1.1786 2021/03/25 18:52:23 christos Exp $ +# $NetBSD: 3RDPARTY,v 1.1787 2021/03/26 08:21:32 wiz Exp $ # # This file contains a list of the software that has been integrated into # NetBSD where we are not the primary maintainer. @@ -408,11 +408,11 @@ Notes: Package: expat Version: 2.2.8 -Current Vers: 2.2.10 +Current Vers: 2.3.0 Maintainer: Expat Project Archive Site: https://github.com/libexpat/libexpat/releases Home Page: http://www.libexpat.org/ -Date: 2020-06-13 +Date: 2021-03-26 Mailing List: expat-disc...@libexpat.org Responsible: mrg License: MIT
CVS commit: src/doc
Module Name:src Committed By: wiz Date: Fri Mar 26 08:21:32 UTC 2021 Modified Files: src/doc: 3RDPARTY Log Message: expat 2.3.0 was released To generate a diff of this commit: cvs rdiff -u -r1.1786 -r1.1787 src/doc/3RDPARTY Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.