CVS commit: src/external/cddl/osnet/usr.bin/ctfconvert

2020-02-08 Thread Santhosh Raju
Module Name:src
Committed By:   fox
Date:   Sun Feb  9 07:55:13 UTC 2020

Modified Files:
src/external/cddl/osnet/usr.bin/ctfconvert: Makefile

Log Message:
external/cddl/osnet: Suppress -Werror=stringop-truncation error.

Add GCC_NO_STRINGOP_TRUNCATION dwarf.c to prevent build failure.

Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag.

Reviewed by: kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/usr.bin/ctfconvert/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.bin/ctfconvert/Makefile
diff -u src/external/cddl/osnet/usr.bin/ctfconvert/Makefile:1.8 src/external/cddl/osnet/usr.bin/ctfconvert/Makefile:1.9
--- src/external/cddl/osnet/usr.bin/ctfconvert/Makefile:1.8	Mon May 28 21:05:11 2018
+++ src/external/cddl/osnet/usr.bin/ctfconvert/Makefile	Sun Feb  9 07:55:13 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.8 2018/05/28 21:05:11 chs Exp $
+#	$NetBSD: Makefile,v 1.9 2020/02/09 07:55:13 fox Exp $
 
 # $FreeBSD: head/cddl/usr.bin/ctfconvert/Makefile 314654 2017-03-04 11:30:04Z ngie $
 
@@ -34,6 +34,7 @@ SRCS=		alist.c \
 		traverse.c \
 		util.c
 
+COPTS.dwarf.c +=	${GCC_NO_STRINGOP_TRUNCATION}
 COPTS.st_parse.c +=	-Wno-format-nonliteral
 COPTS.util.c +=		-Wno-format-nonliteral
 



CVS commit: src/external/bsd/ipf/bin/ipsend

2020-02-08 Thread Santhosh Raju
Module Name:src
Committed By:   fox
Date:   Sun Feb  9 07:51:20 UTC 2020

Modified Files:
src/external/bsd/ipf/bin/ipsend: Makefile

Log Message:
external/bsd/ipf: Suppress -Werror=maybe-uninitialized error.

Add -Wno-error=maybe-uninitialized in ipsopt.c to prevent build failure.

Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag.

Reviewed by: kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/ipf/bin/ipsend/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/bsd/ipf/bin/ipsend/Makefile
diff -u src/external/bsd/ipf/bin/ipsend/Makefile:1.3 src/external/bsd/ipf/bin/ipsend/Makefile:1.4
--- src/external/bsd/ipf/bin/ipsend/Makefile:1.3	Wed Jan  2 15:50:34 2013
+++ src/external/bsd/ipf/bin/ipsend/Makefile	Sun Feb  9 07:51:20 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2013/01/02 15:50:34 dsl Exp $
+#	$NetBSD: Makefile,v 1.4 2020/02/09 07:51:20 fox Exp $
 
 .include 
 .include "../Makefile.inc"
@@ -25,6 +25,8 @@ DPSRCS+=	iplang_y.h
 .PATH:		${UDIST}/ipsend \
 		${UDIST}/iplang
 
+COPTS.ipsopt.c+=	-Wno-error=maybe-uninitialized
+
 iplang_y.c: iplang_y.y
 	${_MKTARGET_CREATE}
 	${YACC} -d ${.ALLSRC}



CVS commit: src/external/bsd/ipf/bin/ipmon

2020-02-08 Thread Santhosh Raju
Module Name:src
Committed By:   fox
Date:   Sun Feb  9 07:47:50 UTC 2020

Modified Files:
src/external/bsd/ipf/bin/ipmon: Makefile

Log Message:
external/bsd/ipf: Suppress -Werror=format-overflow= error.

Add -Wno-error=format-overflow in ipmon.c to prevent build failure.

Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag.

Reviewed by: kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/bsd/ipf/bin/ipmon/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/bsd/ipf/bin/ipmon/Makefile
diff -u src/external/bsd/ipf/bin/ipmon/Makefile:1.1 src/external/bsd/ipf/bin/ipmon/Makefile:1.2
--- src/external/bsd/ipf/bin/ipmon/Makefile:1.1	Fri Mar 23 21:29:45 2012
+++ src/external/bsd/ipf/bin/ipmon/Makefile	Sun Feb  9 07:47:50 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1 2012/03/23 21:29:45 christos Exp $
+#	$NetBSD: Makefile,v 1.2 2020/02/09 07:47:50 fox Exp $
 
 PROG=		ipmon
 SRCS=		ipmon.c ipmon_y.c ipmon_l.c
@@ -11,6 +11,8 @@ DPSRCS+=	ipmon_l.h ipmon_y.h
 CLEANFILES+=	ipmon_y.c ipmon_y.h
 CLEANFILES+=	ipmon_l.c ipmon_l.h
 
+COPTS.ipmon.c+=	-Wno-error=format-overflow
+
 ipmon_y.c: ipmon_y.y
 	${_MKTARGET_CREATE}
 	${YACC} -d ${.ALLSRC}



CVS commit: src/share/mk

2020-02-08 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Feb  8 21:16:53 UTC 2020

Modified Files:
src/share/mk: sys.mk

Log Message:
Don't special case aarch64 and add -fomit-frame-pointer to builds.

This behaviour is probably due to a past behaviour of clang, where it
always emitted frame pointer code.
This is no longer true for clang on netbsd, and I don't think it was true
for GCC.

Meanwhile, this flag bleeds into pkgsrc where it breaks random packages,
requiring workarounds like lang/ruby*-base/hacks.mk.


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.143 src/share/mk/sys.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/sys.mk
diff -u src/share/mk/sys.mk:1.142 src/share/mk/sys.mk:1.143
--- src/share/mk/sys.mk:1.142	Wed Jan  8 22:04:24 2020
+++ src/share/mk/sys.mk	Sat Feb  8 21:16:53 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: sys.mk,v 1.142 2020/01/08 22:04:24 christos Exp $
+#	$NetBSD: sys.mk,v 1.143 2020/02/08 21:16:53 maya Exp $
 #	@(#)sys.mk	8.2 (Berkeley) 3/21/94
 #
 # This file contains the basic rules for make(1) and is read first
@@ -33,8 +33,6 @@ DBG?=	-Os -freorder-blocks
 DBG?=	-O2 -fno-reorder-blocks
 .elif ${MACHINE_ARCH} == "coldfire"
 DBG?=	-O1
-.elif !empty(MACHINE_ARCH:Maarch64*)
-DBG?=	-O2 ${"${.TARGET:M*.po}" == "":? -fomit-frame-pointer:}
 .else
 DBG?=	-O2
 .endif



CVS commit: xsrc/local/programs/xsetwallpaper

2020-02-08 Thread Jared D. McNeill
Module Name:xsrc
Committed By:   jmcneill
Date:   Sat Feb  8 20:29:30 UTC 2020

Modified Files:
xsrc/local/programs/xsetwallpaper: xsetwallpaper.c

Log Message:
Add -s flag to scale image to root window size.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 xsrc/local/programs/xsetwallpaper/xsetwallpaper.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/local/programs/xsetwallpaper/xsetwallpaper.c
diff -u xsrc/local/programs/xsetwallpaper/xsetwallpaper.c:1.2 xsrc/local/programs/xsetwallpaper/xsetwallpaper.c:1.3
--- xsrc/local/programs/xsetwallpaper/xsetwallpaper.c:1.2	Sat Mar 24 19:43:31 2018
+++ xsrc/local/programs/xsetwallpaper/xsetwallpaper.c	Sat Feb  8 20:29:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: xsetwallpaper.c,v 1.2 2018/03/24 19:43:31 jmcneill Exp $ */
+/* $NetBSD: xsetwallpaper.c,v 1.3 2020/02/08 20:29:30 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: xsetwallpaper.c,v 1.2 2018/03/24 19:43:31 jmcneill Exp $");
+__RCSID("$NetBSD: xsetwallpaper.c,v 1.3 2020/02/08 20:29:30 jmcneill Exp $");
 
 #include 
 
@@ -41,10 +41,12 @@ __RCSID("$NetBSD: xsetwallpaper.c,v 1.2 
 
 #define DEFAULT_FILL_COLOR	"#00"
 
+static uint8_t *	resize_nn(const uint8_t *, int, int, int, int);
+
 static void
 usage(const char *pn)
 {
-	fprintf(stderr, "usage: %s [-f fillcolor] filename\n", pn);
+	fprintf(stderr, "usage: %s [-f fillcolor] [-s] filename\n", pn);
 	exit(EXIT_FAILURE);
 }
 
@@ -60,6 +62,7 @@ main(int argc, char *argv[])
 	int imagew, imageh, imagebpp;
 	int ch, i;
 	int screen, default_depth, byte_order;
+	int scale = 0;
 	Display *display;
 	Colormap colormap;
 	XImage *image;
@@ -68,11 +71,14 @@ main(int argc, char *argv[])
 	Window window;
 	GC gc;
 
-	while ((ch = getopt(argc, argv, "f:h")) != -1) {
+	while ((ch = getopt(argc, argv, "f:sh")) != -1) {
 		switch (ch) {
 		case 'f':
 			fill_color = optarg;
 			break;
+		case 's':
+			scale = 1;
+			break;
 		case 'h':
 		default:
 			usage(pn);
@@ -133,6 +139,14 @@ main(int argc, char *argv[])
 
 	XSync(display, False);
 
+	if (scale) {
+		data = resize_nn(data, imagew, imageh, root_width, root_height);
+		if (data == NULL)
+			err(EXIT_FAILURE, "couldn't resize image\n");
+		imagew = root_width;
+		imageh = root_height;
+	}
+
 	/* Parse the fill colour and allocate it */
 	if (!XParseColor(display, colormap, fill_color, )) {
 		errx(EXIT_FAILURE, "couldn't parse color '%s'", fill_color);
@@ -196,3 +210,26 @@ main(int argc, char *argv[])
 
 	return EXIT_SUCCESS;
 }
+
+static uint8_t *
+resize_nn(const uint8_t *data, int src_w, int src_h, int dst_w, int dst_h)
+{
+	const uint32_t *src;
+	uint32_t *dst;
+	int src_x, src_y, dst_x, dst_y;
+
+	src = (const uint32_t *)data;
+	dst = malloc(src_w * src_h * 4);
+	if (dst == NULL)
+		return NULL;
+
+	for (dst_y = 0; dst_y < dst_h; dst_y++) {
+		src_y = dst_y * src_h / dst_h;
+		for (dst_x = 0; dst_x < dst_w; dst_x++) {
+			src_x = dst_x * src_w / dst_w;
+			dst[dst_y * dst_w + dst_x] = src[src_y * src_w + src_x];
+		}
+	}
+
+	return (uint8_t *)dst;
+}



CVS commit: src/tests/lib/libc/c063

2020-02-08 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Feb  8 19:58:37 UTC 2020

Modified Files:
src/tests/lib/libc/c063: t_o_search.c

Log Message:
O_SEARCH tests: expect revoke +x failure on NFS

Patch by Kyle Evans (FreeBSD)

PR misc/54946


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/c063/t_o_search.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/c063/t_o_search.c
diff -u src/tests/lib/libc/c063/t_o_search.c:1.9 src/tests/lib/libc/c063/t_o_search.c:1.10
--- src/tests/lib/libc/c063/t_o_search.c:1.9	Thu Feb  6 12:18:06 2020
+++ src/tests/lib/libc/c063/t_o_search.c	Sat Feb  8 19:58:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_o_search.c,v 1.9 2020/02/06 12:18:06 martin Exp $ */
+/*	$NetBSD: t_o_search.c,v 1.10 2020/02/08 19:58:36 kamil Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,11 +29,13 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_o_search.c,v 1.9 2020/02/06 12:18:06 martin Exp $");
+__RCSID("$NetBSD: t_o_search.c,v 1.10 2020/02/08 19:58:36 kamil Exp $");
 
 #include 
 
 #include 
+#include 
+#include 
 #include 
 
 #include 
@@ -55,6 +57,11 @@ __RCSID("$NetBSD: t_o_search.c,v 1.9 202
 #define USE_O_SEARCH
 #endif
 
+#ifdef __FreeBSD__
+#define	statvfs		statfs
+#define	fstatvfs	fstatfs
+#endif
+
 #define DIR "dir"
 #define FILE "dir/o_search"
 #define BASEFILE "o_search"
@@ -311,8 +318,9 @@ ATF_TC_HEAD(o_search_revokex, tc)
 }
 ATF_TC_BODY(o_search_revokex, tc)
 {
-	int dfd, fd;
+	struct statvfs vst;
 	struct stat sb;
+	int dfd, fd;
 
 	ATF_REQUIRE(mkdir(DIR, 0755) == 0);
 	ATF_REQUIRE((fd = open(FILE, O_CREAT|O_RDWR, 0644)) != -1);
@@ -322,6 +330,11 @@ ATF_TC_BODY(o_search_revokex, tc)
 
 	/* Drop permissions. The kernel must still not check the exec bit. */
 	ATF_REQUIRE(chmod(DIR, ) == 0);
+
+	fstatvfs(dfd, );
+	if (strcmp(vst.f_fstypename, "nfs") == 0)
+		atf_tc_expect_fail("NFS protocol cannot observe O_SEARCH semantics");
+
 	ATF_REQUIRE(fstatat(dfd, BASEFILE, , 0) == 0);
 
 	ATF_REQUIRE(close(dfd) == 0);



CVS commit: src/lib/libpthread

2020-02-08 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Feb  8 17:06:03 UTC 2020

Modified Files:
src/lib/libpthread: pthread.c

Log Message:
Change the behavior of pthread_equal()

On error when not aborting, do not return EINVAL as it has a side effect
of being interpreted as matching threads. For invalid threads return
unmatched.

Check pthreads for NULL, before accessing pt_magic field. This avoids
faults on comparision with a NULL pointer.

This behavior is in the scope of UB, but should be easier to deal with
buggy software.


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/lib/libpthread/pthread.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libpthread/pthread.c
diff -u src/lib/libpthread/pthread.c:1.163 src/lib/libpthread/pthread.c:1.164
--- src/lib/libpthread/pthread.c:1.163	Wed Feb  5 14:56:04 2020
+++ src/lib/libpthread/pthread.c	Sat Feb  8 17:06:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pthread.c,v 1.163 2020/02/05 14:56:04 ryoon Exp $	*/
+/*	$NetBSD: pthread.c,v 1.164 2020/02/08 17:06:03 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008, 2020
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: pthread.c,v 1.163 2020/02/05 14:56:04 ryoon Exp $");
+__RCSID("$NetBSD: pthread.c,v 1.164 2020/02/08 17:06:03 kamil Exp $");
 
 #define	__EXPOSE_STACK	1
 
@@ -770,11 +770,11 @@ pthread_equal(pthread_t t1, pthread_t t2
 	if (__predict_false(__uselibcstub))
 		return __libc_thr_equal_stub(t1, t2);
 
-	pthread__error(EINVAL, "Invalid thread",
-	t1->pt_magic == PT_MAGIC);
+	pthread__error(0, "Invalid thread",
+	(t1 != NULL) && (t1->pt_magic == PT_MAGIC));
 
-	pthread__error(EINVAL, "Invalid thread",
-	t2->pt_magic == PT_MAGIC);
+	pthread__error(0, "Invalid thread",
+	(t2 != NULL) && (t2->pt_magic == PT_MAGIC));
 
 	/* Nothing special here. */
 	return (t1 == t2);



CVS commit: src/sys/arch/i386/stand/efiboot

2020-02-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb  8 14:35:47 UTC 2020

Modified Files:
src/sys/arch/i386/stand/efiboot: eficons.c

Log Message:
Fix a few bugs related to the framebuffer:
 - If a GOP mode wasn't explicitly requested, the bootloader was passing
   fb info to the kernel even if the console was in text mode! This
   results in garbled console output on at least ThinkPad T420 and
   likely many others. If a mode isn't specified, default to 800x600.
 - The "gop" command was incorrectly parsing video modes in the form
   WxHxD as WxWxD.
 - Allow a short form WxH for the "gop" command to select any mode with
   the target dimensions.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/efiboot/eficons.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/i386/stand/efiboot/eficons.c
diff -u src/sys/arch/i386/stand/efiboot/eficons.c:1.7 src/sys/arch/i386/stand/efiboot/eficons.c:1.8
--- src/sys/arch/i386/stand/efiboot/eficons.c:1.7	Fri Sep 13 02:19:45 2019
+++ src/sys/arch/i386/stand/efiboot/eficons.c	Sat Feb  8 14:35:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: eficons.c,v 1.7 2019/09/13 02:19:45 manu Exp $	*/
+/*	$NetBSD: eficons.c,v 1.8 2020/02/08 14:35:47 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -34,6 +34,10 @@
 #include "bootinfo.h"
 #include "vbe.h"
 
+#ifndef DEFAULT_GOP_MODE
+#define DEFAULT_GOP_MODE	"800x600"
+#endif
+
 extern struct x86_boot_params boot_params;
 
 struct btinfo_console btinfo_console;
@@ -71,6 +75,8 @@ static int efi_com_putc(int);
 static int efi_com_status(int);
 static int efi_com_waitforinputevent(uint64_t);
 
+static int efi_find_gop_mode(char *);
+
 static int iodev;
 static int (*internal_getchar)(void) = efi_cons_getc;
 static int (*internal_putchar)(int) = efi_cons_putc;
@@ -415,46 +421,36 @@ bi_framebuffer(void)
 	EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info;
 	struct btinfo_framebuffer fb;
 	INT32 bestmode = -1;
+	UINTN sz;
 
-	if (efi_gop == NULL) {
-		framebuffer_configure(NULL);
-		return;
-	}
+	if (efi_gop == NULL)
+		goto nofb;
 
 	if (efi_gop_mode >= 0) {
 		bestmode = efi_gop_mode;
 	} else {
-#if 0
-		UINT64 res, bestres = 0;
-		UINTN sz;
-		UINT32 i;
-
-		/* XXX EDID? EFI_EDID_DISCOVERED_PROTOCOL */
-		for (i = 0; i < efi_gop->Mode->MaxMode; i++) {
-			status = uefi_call_wrapper(efi_gop->QueryMode, 4,
-			efi_gop, i, , );
-			if (EFI_ERROR(status))
-continue;
+		/* If a mode has not been selected, choose a default */
+		bestmode = efi_find_gop_mode(DEFAULT_GOP_MODE);
+	}
+	if (bestmode == -1)
+		goto nofb;
 
-			res = (UINT64)info->HorizontalResolution *
-			(UINT64)info->VerticalResolution *
-			(UINT64)getdepth(info);
-			if (res > bestres) {
-bestmode = i;
-bestres = res;
-			}
-		}
-#endif
+	status = uefi_call_wrapper(efi_gop->SetMode, 2, efi_gop,
+	bestmode);
+	if (EFI_ERROR(status) || efi_gop->Mode->Mode != bestmode) {
+		printf("GOP setmode failed: %" PRIxMAX "\n",
+		(uintmax_t)status);
+		goto nofb;
 	}
-	if (bestmode >= 0) {
-		status = uefi_call_wrapper(efi_gop->SetMode, 2, efi_gop,
-		bestmode);
-		if (EFI_ERROR(status) || efi_gop->Mode->Mode != bestmode)
-			printf("GOP setmode failed: %" PRIxMAX "\n",
-			(uintmax_t)status);
+
+	status = uefi_call_wrapper(efi_gop->QueryMode, 4,
+	efi_gop, bestmode, , );
+	if (EFI_ERROR(status)) {
+		printf("GOP querymode failed: %" PRIxMAX "\n",
+		(uintmax_t)status);
+		goto nofb;
 	}
 
-	info = efi_gop->Mode->Info;
 	memset(, 0, sizeof(fb));
 	fb.physaddr = efi_gop->Mode->FrameBufferBase;
 	fb.flags = 0;
@@ -499,6 +495,10 @@ bi_framebuffer(void)
 	}
 
 	framebuffer_configure();
+	return;
+
+nofb:
+	framebuffer_configure(NULL);
 }
 
 int
@@ -658,10 +658,16 @@ efi_find_gop_mode(char *arg)
 
 		snprintf(mode, sizeof(mode), "%lux%lux%u",
 		(long)info->HorizontalResolution,
-		(long)info->HorizontalResolution,
+		(long)info->VerticalResolution,
 		depth);
 		if (strcmp(arg, mode) == 0)
 			return i;
+
+		snprintf(mode, sizeof(mode), "%lux%lu",
+		(long)info->HorizontalResolution,
+		(long)info->VerticalResolution);
+		if (strcmp(arg, mode) == 0)
+			return i;
 	}
 	return -1;
 }



CVS commit: src

2020-02-08 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Feb  8 14:17:30 UTC 2020

Modified Files:
src/share/man/man4: route.4
src/sys/net: route.h rtsock_shared.c

Log Message:
route(4): add RO_MISSFILTER socket option

This allows filtering of specific RTM_MISS destination sockaddrs.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/share/man/man4/route.4
cvs rdiff -u -r1.125 -r1.126 src/sys/net/route.h
cvs rdiff -u -r1.12 -r1.13 src/sys/net/rtsock_shared.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man4/route.4
diff -u src/share/man/man4/route.4:1.32 src/share/man/man4/route.4:1.33
--- src/share/man/man4/route.4:1.32	Sun Jul  1 22:27:43 2018
+++ src/share/man/man4/route.4	Sat Feb  8 14:17:30 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: route.4,v 1.32 2018/07/01 22:27:43 christos Exp $
+.\"	$NetBSD: route.4,v 1.33 2020/02/08 14:17:30 roy Exp $
 .\"
 .\" Copyright (c) 1990, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)route.4	8.6 (Berkeley) 4/19/94
 .\"
-.Dd July 11, 2018
+.Dd February 4, 2020
 .Dt ROUTE 4
 .Os
 .Sh NAME
@@ -191,6 +191,35 @@ if (setsockopt(routefd, PF_ROUTE, RO_MSG
 	err(1, "setsockopt(RO_MSGFILTER)");
 .Ed
 .Pp
+A process can specify which RTM_MISS destination addresses it's interested in
+by passing an array of struct sockaddr to the
+.Xr setsockopt 2
+call with the
+.Dv RO_MISSFILTER
+option at the
+.Dv PF_ROUTE
+level.
+For example, to only get RTM_MISS messages for specific destinations:
+.Bd -literal -offset indent
+char buf[1024] = { '\\0' }, *cp = buf;
+struct sockaddr_in sin = {
+	.sin_family = AF_INET,
+	.sin_len = sizeof(sin),
+};
+
+inet_aton("192.168.0.1", _addr);
+memcpy(cp, , sin.sin_len);
+cp += RT_ROUNDUP(sin.sin_len);
+
+inet_aton("192.168.0.2", _addr);
+memcpy(cp, , sin.sin_len);
+cp += RT_ROUNDUP(sin.sin_len);
+
+if (setsockopt(routefd, PF_ROUTE, RO_MISSFILTER,
+, (socklen_t)(cp - buf)) == -1)
+	err(1, "setsockopt(RO_MISSFILTER)");
+.Ed
+.Pp
 If a route is in use when it is deleted,
 the routing entry will be marked down and removed from the routing table,
 but the resources associated with it will not

Index: src/sys/net/route.h
diff -u src/sys/net/route.h:1.125 src/sys/net/route.h:1.126
--- src/sys/net/route.h:1.125	Thu Sep 19 04:08:29 2019
+++ src/sys/net/route.h	Sat Feb  8 14:17:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.h,v 1.125 2019/09/19 04:08:29 ozaki-r Exp $	*/
+/*	$NetBSD: route.h,v 1.126 2020/02/08 14:17:30 roy Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -270,6 +270,9 @@ struct rt_msghdr {
  * setsockopt defines used for the filtering.
  */
 #define	RO_MSGFILTER	1	/* array of which rtm_type to send to client */
+#define	RO_MISSFILTER	2	/* array of sockaddrs to match miss dst */
+
+#define	RO_FILTSA_MAX	30	/* maximum number of sockaddrs per filter */
 
 #define RTV_MTU		0x1	/* init or lock _mtu */
 #define RTV_HOPCOUNT	0x2	/* init or lock _hopcount */

Index: src/sys/net/rtsock_shared.c
diff -u src/sys/net/rtsock_shared.c:1.12 src/sys/net/rtsock_shared.c:1.13
--- src/sys/net/rtsock_shared.c:1.12	Wed Jan 29 04:35:13 2020
+++ src/sys/net/rtsock_shared.c	Sat Feb  8 14:17:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtsock_shared.c,v 1.12 2020/01/29 04:35:13 thorpej Exp $	*/
+/*	$NetBSD: rtsock_shared.c,v 1.13 2020/02/08 14:17:30 roy Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtsock_shared.c,v 1.12 2020/01/29 04:35:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock_shared.c,v 1.13 2020/02/08 14:17:30 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -169,6 +169,8 @@ struct routecb {
 	struct rawcb	rocb_rcb;
 	unsigned int	rocb_msgfilter;
 #define	RTMSGFILTER(m)	(1U << (m))
+	char		*rocb_missfilter;
+	size_t		rocb_missfilterlen;
 };
 #define sotoroutecb(so)	((struct routecb *)(so)->so_pcb)
 
@@ -218,7 +220,7 @@ COMPATNAME(route_filter)(struct mbuf *m,
 		return ENOPROTOOPT;
 
 	/* If no filter set, just return. */
-	if (rop->rocb_msgfilter == 0)
+	if (rop->rocb_msgfilter == 0 && rop->rocb_missfilterlen == 0)
 		return 0;
 
 	/* Ensure we can access rtm_type */
@@ -230,9 +232,27 @@ COMPATNAME(route_filter)(struct mbuf *m,
 	if (rtm->rtm_type >= sizeof(rop->rocb_msgfilter) * CHAR_BIT)
 		return EINVAL;
 	/* If the rtm type is filtered out, return a positive. */
-	if (!(rop->rocb_msgfilter & RTMSGFILTER(rtm->rtm_type)))
+	if (rop->rocb_msgfilter != 0 &&
+	!(rop->rocb_msgfilter & RTMSGFILTER(rtm->rtm_type)))
 		return EEXIST;
 
+	if (rop->rocb_missfilterlen != 0 && rtm->rtm_type == RTM_MISS) {
+		__CTASSERT(RTA_DST == 1);
+		struct sockaddr *sa, *dst = (struct sockaddr *)(rtm + 1);
+		char *cp = rop->rocb_missfilter;
+		char *ep = cp + rop->rocb_missfilterlen;
+
+		while (cp < ep) {
+			sa = (struct sockaddr *)cp;
+			if (sa->sa_len == 

CVS commit: src/usr.bin/login

2020-02-08 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Feb  8 13:44:35 UTC 2020

Modified Files:
src/usr.bin/login: login_pam.c

Log Message:
Avoid use-after-free bug in PAM environment

Traditional BSD putenv(3) was creating an internal copy of the passed
argument. Unfortunately this was causing memory leaks and was changed by
POSIX to not allocate.

Adapt the putenv(3) usage to modern POSIX (and NetBSD) semantics.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/login/login_pam.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/login/login_pam.c
diff -u src/usr.bin/login/login_pam.c:1.25 src/usr.bin/login/login_pam.c:1.26
--- src/usr.bin/login/login_pam.c:1.25	Thu Oct 29 11:31:52 2015
+++ src/usr.bin/login/login_pam.c	Sat Feb  8 13:44:35 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: login_pam.c,v 1.25 2015/10/29 11:31:52 shm Exp $   */
+/* $NetBSD: login_pam.c,v 1.26 2020/02/08 13:44:35 kamil Exp $   */
 
 /*-
  * Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)login.c	8.4 (Berkeley) 4/2/94";
 #endif
-__RCSID("$NetBSD: login_pam.c,v 1.25 2015/10/29 11:31:52 shm Exp $");
+__RCSID("$NetBSD: login_pam.c,v 1.26 2020/02/08 13:44:35 kamil Exp $");
 #endif /* not lint */
 
 /*
@@ -602,8 +602,8 @@ skip_auth:
 		char **envitem;
 
 		for (envitem = pamenv; *envitem; envitem++) {
-			putenv(*envitem);
-			free(*envitem);
+			if (putenv(*envitem) == -1)
+free(*envitem);
 		}
 
 		free(pamenv);



CVS commit: src/usr.bin/tftp

2020-02-08 Thread Santhosh Raju
Module Name:src
Committed By:   fox
Date:   Sat Feb  8 13:33:56 UTC 2020

Modified Files:
src/usr.bin/tftp: Makefile

Log Message:
user.bin/tftp: Suppress -Werror=format-overflow error.

Add -Wno-error=format-overflow tftp.c to prevent build failure.

Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag.

Reviewed by: kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/tftp/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/tftp/Makefile
diff -u src/usr.bin/tftp/Makefile:1.12 src/usr.bin/tftp/Makefile:1.13
--- src/usr.bin/tftp/Makefile:1.12	Fri Oct  4 09:47:28 2019
+++ src/usr.bin/tftp/Makefile	Sat Feb  8 13:33:56 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.12 2019/10/04 09:47:28 mrg Exp $
+#	$NetBSD: Makefile,v 1.13 2020/02/08 13:33:56 fox Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
 WARNS?=2
@@ -9,5 +9,6 @@ PROG=	tftp
 SRCS=	main.c tftp.c tftpsubs.c
 
 COPTS.tftp.c+=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} == 8:? -Wno-array-bounds :}
+COPTS.tftp.c+=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} == 8:? -Wno-error=format-overflow :}
 
 .include 



CVS commit: src/usr.bin/mkubootimage

2020-02-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sat Feb  8 13:27:01 UTC 2020

Modified Files:
src/usr.bin/mkubootimage: mkubootimage.c

Log Message:
arm64_image_header->image_size must be included size of arm64_image_header.

with -u option, image_size should be binary (file) size (header included).
without -u option, image_size should be binary (file) size + header size.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/mkubootimage/mkubootimage.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/mkubootimage/mkubootimage.c
diff -u src/usr.bin/mkubootimage/mkubootimage.c:1.29 src/usr.bin/mkubootimage/mkubootimage.c:1.30
--- src/usr.bin/mkubootimage/mkubootimage.c:1.29	Wed Jan  1 11:48:36 2020
+++ src/usr.bin/mkubootimage/mkubootimage.c	Sat Feb  8 13:27:00 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: mkubootimage.c,v 1.29 2020/01/01 11:48:36 martin Exp $ */
+/* $NetBSD: mkubootimage.c,v 1.30 2020/02/08 13:27:00 ryo Exp $ */
 
 /*-
  * Copyright (c) 2010 Jared D. McNeill 
@@ -30,7 +30,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: mkubootimage.c,v 1.29 2020/01/01 11:48:36 martin Exp $");
+__RCSID("$NetBSD: mkubootimage.c,v 1.30 2020/02/08 13:27:00 ryo Exp $");
 
 #include 
 #include 
@@ -389,7 +389,7 @@ generate_header_arm64(struct arm64_image
 #endif
 
 	const uint64_t dsize = update_image ?
-	   (uint64_t)st.st_size - sizeof(*hdr) : (uint64_t)st.st_size;
+	(uint64_t)st.st_size : (uint64_t)st.st_size + sizeof(*hdr);
 
 	memset(hdr, 0, sizeof(*hdr));
 	hdr->code0 = htole32(ARM64_CODE0);



CVS commit: src/external/bsd/ntp/bin/ntpd

2020-02-08 Thread Santhosh Raju
Module Name:src
Committed By:   fox
Date:   Sat Feb  8 13:20:10 UTC 2020

Modified Files:
src/external/bsd/ntp/bin/ntpd: Makefile

Log Message:
external/bsd/ntp: Suppress -Werror=stringop-truncation error.

Add GCC_NO_STRINGOP_TRUNCATION to refclock_jjy.c to prevent build failure.

Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag.

Reviewed by: kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/external/bsd/ntp/bin/ntpd/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/bsd/ntp/bin/ntpd/Makefile
diff -u src/external/bsd/ntp/bin/ntpd/Makefile:1.24 src/external/bsd/ntp/bin/ntpd/Makefile:1.25
--- src/external/bsd/ntp/bin/ntpd/Makefile:1.24	Sun Oct 13 07:28:07 2019
+++ src/external/bsd/ntp/bin/ntpd/Makefile	Sat Feb  8 13:20:10 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.24 2019/10/13 07:28:07 mrg Exp $
+#	$NetBSD: Makefile,v 1.25 2020/02/08 13:20:10 fox Exp $
 
 .include 
 
@@ -95,6 +95,7 @@ COPTS.ntp_control.c+=  -Wno-error=maybe-
 COPTS.ntp_loopfilter.c+=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} == 8:? -Wno-error=restrict :}
 COPTS.ntp_loopfilter.c+=	${GCC_NO_FORMAT_TRUNCATION}
 COPTS.ntp_crypto.c+=		${GCC_NO_FORMAT_TRUNCATION}
+COPTS.refclock_jjy.c+=		${GCC_NO_STRINGOP_TRUNCATION}
 COPTS.refclock_parse.c+=	${GCC_NO_FORMAT_TRUNCATION}
 COPTS.refclock_leitch.c+=	${GCC_NO_FORMAT_TRUNCATION}
 COPTS.refclock_neoclock4x.c+=	${GCC_NO_FORMAT_TRUNCATION}



CVS commit: src/usr.sbin/fstyp

2020-02-08 Thread Santhosh Raju
Module Name:src
Committed By:   fox
Date:   Sat Feb  8 12:56:56 UTC 2020

Modified Files:
src/usr.sbin/fstyp: exfat.c

Log Message:
usr.sbin/fstyp: Fix -Werror=conversion error.

Type cast the size_t to uint32_t to prevent implicit type conversion errors.

Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag.

Reviewed by: kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/fstyp/exfat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/fstyp/exfat.c
diff -u src/usr.sbin/fstyp/exfat.c:1.2 src/usr.sbin/fstyp/exfat.c:1.3
--- src/usr.sbin/fstyp/exfat.c:1.2	Sat Dec 28 08:00:08 2019
+++ src/usr.sbin/fstyp/exfat.c	Sat Feb  8 12:56:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: exfat.c,v 1.2 2019/12/28 08:00:08 tkusumi Exp $	*/
+/*	$NetBSD: exfat.c,v 1.3 2020/02/08 12:56:56 fox Exp $	*/
 
 /*
  * Copyright (c) 2017 Conrad Meyer 
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: exfat.c,v 1.2 2019/12/28 08:00:08 tkusumi Exp $");
+__RCSID("$NetBSD: exfat.c,v 1.3 2020/02/08 12:56:56 fox Exp $");
 
 #include 
 #include 
@@ -250,7 +250,7 @@ exfat_fat_next(FILE *fp, const struct ex
 
 	fat_offset_sect = le32toh(ev->ev_fat_offset);
 	clsect = fat_offset_sect + (cluster / (BPS / (uint32_t)sizeof(cluster)));
-	clsectoff = (cluster % (BPS / sizeof(cluster)));
+	clsectoff = (cluster % (BPS / (uint32_t)sizeof(cluster)));
 
 	/* XXX This is pretty wasteful without a block cache for the FAT. */
 	fatsect = read_sect(fp, clsect, BPS);



CVS commit: src/usr.bin/talk

2020-02-08 Thread Santhosh Raju
Module Name:src
Committed By:   fox
Date:   Sat Feb  8 12:53:29 UTC 2020

Modified Files:
src/usr.bin/talk: Makefile

Log Message:
usr.bin/talk: Suppress -Werror=stringop-truncation error.

Add GCC_NO_STRINGOP_TRUNCATION to get_names.c to prevent build failure.

Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag.

Reviewed by: kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/talk/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/talk/Makefile
diff -u src/usr.bin/talk/Makefile:1.8 src/usr.bin/talk/Makefile:1.9
--- src/usr.bin/talk/Makefile:1.8	Sat Feb  6 23:45:26 2010
+++ src/usr.bin/talk/Makefile	Sat Feb  8 12:53:29 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.8 2010/02/06 23:45:26 he Exp $
+#	$NetBSD: Makefile,v 1.9 2020/02/08 12:53:29 fox Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
 USE_FORT?= yes	# network client
@@ -9,4 +9,6 @@ LDADD=	-lcurses -lterminfo -lutil
 SRCS=	ctl.c ctl_transact.c display.c get_addrs.c get_names.c \
 	init_disp.c invite.c io.c look_up.c msgs.c talk.c
 
+COPTS.get_names.c+=	${GCC_NO_STRINGOP_TRUNCATION}
+
 .include 



CVS commit: src/external/bsd/dhcpcd/dist/src

2020-02-08 Thread Santhosh Raju
Module Name:src
Committed By:   fox
Date:   Sat Feb  8 12:17:16 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c

Log Message:
external/bsd/dhcpcd: Fix a -Wconversion warning.

Type cast uint16_t to size_t to prevent implicit type conversion.

Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag.
gcc version 8.3.0

Reviewed by: roy@, kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/external/bsd/dhcpcd/dist/src/dhcp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.32 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.33
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.32	Mon Jan 27 20:42:56 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Sat Feb  8 12:17:16 2020
@@ -3307,7 +3307,7 @@ is_packet_udp_bootp(void *packet, size_t
 	memcpy(, (char *)ip + ip_hlen, sizeof(udp));
 	if (ntohs(udp.uh_ulen) < sizeof(udp))
 		return false;
-	if (ip_hlen + ntohs(udp.uh_ulen) > plen)
+	if (ip_hlen + (size_t)ntohs(udp.uh_ulen) > plen)
 		return false;
 
 	/* Check it's to and from the right ports. */



CVS commit: src/usr.bin/env

2020-02-08 Thread Leonardo Taccari
Module Name:src
Committed By:   leot
Date:   Sat Feb  8 11:10:08 UTC 2020

Modified Files:
src/usr.bin/env: env.1

Log Message:
Fix a typo (extra `s')


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/env/env.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/env/env.1
diff -u src/usr.bin/env/env.1:1.14 src/usr.bin/env/env.1:1.15
--- src/usr.bin/env/env.1:1.14	Sat Feb  8 11:02:07 2020
+++ src/usr.bin/env/env.1	Sat Feb  8 11:10:08 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: env.1,v 1.14 2020/02/08 11:02:07 kamil Exp $
+.\"	$NetBSD: env.1,v 1.15 2020/02/08 11:10:08 leot Exp $
 .\"
 .\" Copyright (c) 1980, 1990 The Regents of the University of California.
 .\" All rights reserved.
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"	from: @(#)printenv.1	6.7 (Berkeley) 7/28/91
-.\"	$NetBSD: env.1,v 1.14 2020/02/08 11:02:07 kamil Exp $
+.\"	$NetBSD: env.1,v 1.15 2020/02/08 11:10:08 leot Exp $
 .\"
 .Dd February 8, 2020
 .Dt ENV 1
@@ -158,7 +158,7 @@ The
 .Fl u
 and
 .Fl 0
-optionss first appeared in
+options first appeared in
 .Nx 10 .
 .Sh BUGS
 .Nm



CVS commit: src/usr.bin/env

2020-02-08 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Feb  8 11:02:07 UTC 2020

Modified Files:
src/usr.bin/env: env.1 env.c

Log Message:
Implement env(1) -0

-0  End each output line with NUL, not newline.

FreeBSD and GNU env(1) implement -0 which is used in 3rd party scripts.

This change is based on the FreeBSD code.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/env/env.1
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/env/env.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/env/env.1
diff -u src/usr.bin/env/env.1:1.13 src/usr.bin/env/env.1:1.14
--- src/usr.bin/env/env.1:1.13	Sat Feb  8 10:30:22 2020
+++ src/usr.bin/env/env.1	Sat Feb  8 11:02:07 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: env.1,v 1.13 2020/02/08 10:30:22 kamil Exp $
+.\"	$NetBSD: env.1,v 1.14 2020/02/08 11:02:07 kamil Exp $
 .\"
 .\" Copyright (c) 1980, 1990 The Regents of the University of California.
 .\" All rights reserved.
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"	from: @(#)printenv.1	6.7 (Berkeley) 7/28/91
-.\"	$NetBSD: env.1,v 1.13 2020/02/08 10:30:22 kamil Exp $
+.\"	$NetBSD: env.1,v 1.14 2020/02/08 11:02:07 kamil Exp $
 .\"
 .Dd February 8, 2020
 .Dt ENV 1
@@ -40,7 +40,7 @@
 .Nd set and print environment
 .Sh SYNOPSIS
 .Nm
-.Op Fl i
+.Op Fl 0i
 .Op Fl u Ar name
 .Op Ar name=value ...
 .Oo
@@ -86,10 +86,17 @@ If no
 .Ar utility
 is specified,
 .Nm
-prints out the names and values
-of the variables in the environment, with one
+prints out the names and values of the variables in the environment.
+Each
 .Ar name=value
-pair per line.
+pair is separated by a new line unless
+.Fl 0
+is specified, in which case name/value pairs are separated by NUL.
+Both
+.Fl 0
+and
+.Ar utility
+must not be specified together.
 .Sh EXIT STATUS
 .Nm
 exits with one of the following values:
@@ -111,6 +118,11 @@ was invoked, but failed in some way;
 see its manual page for more information.
 In this case the exit code is returned by the utility itself, not
 .Nm .
+.It 125
+.Ar utility
+was specified together with the
+.Fl 0
+option.
 .It 126
 .Ar utility
 was found, but could not be invoked.
@@ -125,7 +137,9 @@ option has been deprecated but is still 
 .Pp
 The
 .Fl u
-option is a non-standard extension.
+and
+.Fl 0
+options are non-standard extensions.
 .Sh SEE ALSO
 .Xr execvp 3 ,
 .Xr environ 7
@@ -142,7 +156,9 @@ command appeared in
 .Pp
 The
 .Fl u
-option first appeared in
+and
+.Fl 0
+optionss first appeared in
 .Nx 10 .
 .Sh BUGS
 .Nm

Index: src/usr.bin/env/env.c
diff -u src/usr.bin/env/env.c:1.22 src/usr.bin/env/env.c:1.23
--- src/usr.bin/env/env.c:1.22	Sat Feb  8 10:36:02 2020
+++ src/usr.bin/env/env.c	Sat Feb  8 11:02:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: env.c,v 1.22 2020/02/08 10:36:02 kamil Exp $	*/
+/*	$NetBSD: env.c,v 1.23 2020/02/08 11:02:07 kamil Exp $	*/
 /*
  * Copyright (c) 1988, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -36,7 +36,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 
 #ifndef lint
 /*static char sccsid[] = "@(#)env.c	8.3 (Berkeley) 4/2/94";*/
-__RCSID("$NetBSD: env.c,v 1.22 2020/02/08 10:36:02 kamil Exp $");
+__RCSID("$NetBSD: env.c,v 1.23 2020/02/08 11:02:07 kamil Exp $");
 #endif /* not lint */
 
 #include 
@@ -54,15 +54,19 @@ extern char **environ;
 int
 main(int argc, char **argv)
 {
-	char **ep;
+	char **ep, term;
 	char *cleanenv[1];
 	int ch;
 
 	setprogname(*argv);
 	(void)setlocale(LC_ALL, "");
 
-	while ((ch = getopt(argc, argv, "-iu:")) != -1)
+	term = '\n';
+	while ((ch = getopt(argc, argv, "-0iu:")) != -1)
 		switch((char)ch) {
+		case '0':
+			term = '\0';
+			break;
 		case '-':			/* obsolete */
 		case 'i':
 			environ = cleanenv;
@@ -82,7 +86,11 @@ main(int argc, char **argv)
 
 	if (*argv) {
 		/* return 127 if the command to be run could not be found; 126
-		   if the command was found but could not be invoked */
+		   if the command was found but could not be invoked; 125 if
+		   -0 was specified with utility.*/
+
+		if (term == '\0')
+			errx(125, "cannot specify command with -0");
 
 		(void)execvp(*argv, argv);
 		err((errno == ENOENT) ? 127 : 126, "%s", *argv);
@@ -90,7 +98,7 @@ main(int argc, char **argv)
 	}
 
 	for (ep = environ; *ep; ep++)
-		(void)printf("%s\n", *ep);
+		(void)printf("%s%c", *ep, term);
 
 	exit(0);
 }
@@ -99,7 +107,7 @@ static void
 usage(void)
 {
 	(void)fprintf(stderr,
-	"Usage: %s [-i] [-u name] [name=value ...] [command]\n",
+	"Usage: %s [-0i] [-u name] [name=value ...] [command]\n",
 	getprogname());
 	exit(1);
 }



CVS commit: src/usr.bin/env

2020-02-08 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Feb  8 10:36:02 UTC 2020

Modified Files:
src/usr.bin/env: env.c

Log Message:
Add CVS Id tag and switch __attribute__ to __dead.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/env/env.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/env/env.c
diff -u src/usr.bin/env/env.c:1.21 src/usr.bin/env/env.c:1.22
--- src/usr.bin/env/env.c:1.21	Sat Feb  8 10:30:22 2020
+++ src/usr.bin/env/env.c	Sat Feb  8 10:36:02 2020
@@ -1,3 +1,4 @@
+/*	$NetBSD: env.c,v 1.22 2020/02/08 10:36:02 kamil Exp $	*/
 /*
  * Copyright (c) 1988, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -35,7 +36,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 
 #ifndef lint
 /*static char sccsid[] = "@(#)env.c	8.3 (Berkeley) 4/2/94";*/
-__RCSID("$NetBSD: env.c,v 1.21 2020/02/08 10:30:22 kamil Exp $");
+__RCSID("$NetBSD: env.c,v 1.22 2020/02/08 10:36:02 kamil Exp $");
 #endif /* not lint */
 
 #include 
@@ -46,7 +47,7 @@ __RCSID("$NetBSD: env.c,v 1.21 2020/02/0
 #include 
 #include 
 
-static void usage(void) __attribute__((__noreturn__));
+static void usage(void) __dead;
 
 extern char **environ;
 



CVS commit: src/usr.bin/env

2020-02-08 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Feb  8 10:30:22 UTC 2020

Modified Files:
src/usr.bin/env: env.1 env.c

Log Message:
Implement env(1) -u

The option '-u name' causes removal of the name environment variable if
it is in the environment.  This is similar to the unset command in sh(1).
The value for name must not include the '=' character.

Add HISTORY section in the man page.

The -u argument is implemented by Linux, FreeBSD and Darwin.
The lack of -u in NetBSD is a cause for a frequent fallout in the LLVM
toolchain test-suite.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/env/env.1
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/env/env.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/env/env.1
diff -u src/usr.bin/env/env.1:1.12 src/usr.bin/env/env.1:1.13
--- src/usr.bin/env/env.1:1.12	Fri Jun  8 18:20:42 2007
+++ src/usr.bin/env/env.1	Sat Feb  8 10:30:22 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: env.1,v 1.12 2007/06/08 18:20:42 wiz Exp $
+.\"	$NetBSD: env.1,v 1.13 2020/02/08 10:30:22 kamil Exp $
 .\"
 .\" Copyright (c) 1980, 1990 The Regents of the University of California.
 .\" All rights reserved.
@@ -30,9 +30,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"	from: @(#)printenv.1	6.7 (Berkeley) 7/28/91
-.\"	$NetBSD: env.1,v 1.12 2007/06/08 18:20:42 wiz Exp $
+.\"	$NetBSD: env.1,v 1.13 2020/02/08 10:30:22 kamil Exp $
 .\"
-.Dd June 8, 2007
+.Dd February 8, 2020
 .Dt ENV 1
 .Os
 .Sh NAME
@@ -41,6 +41,7 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl i
+.Op Fl u Ar name
 .Op Ar name=value ...
 .Oo
 .Ar utility
@@ -66,6 +67,21 @@ causes
 to completely ignore the environment
 it inherits.
 .Pp
+The option
+.Sq Fl u Ar name
+causes removal of the
+.Ar name
+environment variable if it is in the environment.
+This is similar to the
+.Ic unset
+command in
+.Xr sh 1 .
+The value for
+.Ar name
+must not include the
+.Ql =
+character.
+.Pp
 If no
 .Ar utility
 is specified,
@@ -106,6 +122,10 @@ could not be found.
 The historic
 .Fl
 option has been deprecated but is still supported in this implementation.
+.Pp
+The
+.Fl u
+option is a non-standard extension.
 .Sh SEE ALSO
 .Xr execvp 3 ,
 .Xr environ 7
@@ -114,6 +134,16 @@ The
 .Nm
 utility conforms to
 .St -p1003.2-92 .
+.Sh HISTORY
+The
+.Nm
+command appeared in
+.Bx 4.4 .
+.Pp
+The
+.Fl u
+option first appeared in
+.Nx 10 .
 .Sh BUGS
 .Nm
 doesn't handle commands with equal

Index: src/usr.bin/env/env.c
diff -u src/usr.bin/env/env.c:1.20 src/usr.bin/env/env.c:1.21
--- src/usr.bin/env/env.c:1.20	Tue Nov 16 02:53:49 2010
+++ src/usr.bin/env/env.c	Sat Feb  8 10:30:22 2020
@@ -35,7 +35,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 
 #ifndef lint
 /*static char sccsid[] = "@(#)env.c	8.3 (Berkeley) 4/2/94";*/
-__RCSID("$NetBSD: env.c,v 1.20 2010/11/16 02:53:49 christos Exp $");
+__RCSID("$NetBSD: env.c,v 1.21 2020/02/08 10:30:22 kamil Exp $");
 #endif /* not lint */
 
 #include 
@@ -60,13 +60,17 @@ main(int argc, char **argv)
 	setprogname(*argv);
 	(void)setlocale(LC_ALL, "");
 
-	while ((ch = getopt(argc, argv, "-i")) != -1)
+	while ((ch = getopt(argc, argv, "-iu:")) != -1)
 		switch((char)ch) {
 		case '-':			/* obsolete */
 		case 'i':
 			environ = cleanenv;
 			cleanenv[0] = NULL;
 			break;
+		case 'u':
+			if (unsetenv(optarg) == -1)
+errx(EXIT_FAILURE, "unsetenv %s", optarg);
+			break;
 		case '?':
 		default:
 			usage();
@@ -93,7 +97,8 @@ main(int argc, char **argv)
 static void
 usage(void)
 {
-	(void)fprintf(stderr, "Usage: %s [-i] [name=value ...] [command]\n",
+	(void)fprintf(stderr,
+	"Usage: %s [-i] [-u name] [name=value ...] [command]\n",
 	getprogname());
 	exit(1);
 }



CVS commit: src/sys

2020-02-08 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Feb  8 09:05:08 UTC 2020

Modified Files:
src/sys/kern: subr_asan.c
src/sys/sys: asan.h

Log Message:
Sync the codes with reality: partial replaced by mid, and use-after-ret
added.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/kern/subr_asan.c
cvs rdiff -u -r1.12 -r1.13 src/sys/sys/asan.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_asan.c
diff -u src/sys/kern/subr_asan.c:1.17 src/sys/kern/subr_asan.c:1.18
--- src/sys/kern/subr_asan.c:1.17	Sat Jan 25 15:55:33 2020
+++ src/sys/kern/subr_asan.c	Sat Feb  8 09:05:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_asan.c,v 1.17 2020/01/25 15:55:33 maxv Exp $	*/
+/*	$NetBSD: subr_asan.c,v 1.18 2020/02/08 09:05:08 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_asan.c,v 1.17 2020/01/25 15:55:33 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_asan.c,v 1.18 2020/02/08 09:05:08 maxv Exp $");
 
 #include 
 #include 
@@ -176,10 +176,12 @@ kasan_code_name(uint8_t code)
 		return "RedZonePartial";
 	case KASAN_STACK_LEFT:
 		return "StackLeft";
+	case KASAN_STACK_MID:
+		return "StackMiddle";
 	case KASAN_STACK_RIGHT:
 		return "StackRight";
-	case KASAN_STACK_PARTIAL:
-		return "StackPartial";
+	case KASAN_USE_AFTER_RET:
+		return "UseAfterRet";
 	case KASAN_USE_AFTER_SCOPE:
 		return "UseAfterScope";
 	default:

Index: src/sys/sys/asan.h
diff -u src/sys/sys/asan.h:1.12 src/sys/sys/asan.h:1.13
--- src/sys/sys/asan.h:1.12	Thu Nov 14 17:09:23 2019
+++ src/sys/sys/asan.h	Sat Feb  8 09:05:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.h,v 1.12 2019/11/14 17:09:23 maxv Exp $	*/
+/*	$NetBSD: asan.h,v 1.13 2020/02/08 09:05:08 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
 #define KASAN_STACK_LEFT	0xF1
 #define KASAN_STACK_MID		0xF2
 #define KASAN_STACK_RIGHT	0xF3
-#define KASAN_STACK_PARTIAL	0xF4
+#define KASAN_USE_AFTER_RET	0xF5
 #define KASAN_USE_AFTER_SCOPE	0xF8
 
 /* Our redzone values. */



CVS commit: src/sys/dev/usb

2020-02-08 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Feb  8 08:47:27 UTC 2020

Modified Files:
src/sys/dev/usb: usb_subr.c usbdi_util.c usbdi_util.h usbdivar.h

Log Message:
Move three functions into usbdi_util.c, where they belong. No functional
change.


To generate a diff of this commit:
cvs rdiff -u -r1.241 -r1.242 src/sys/dev/usb/usb_subr.c
cvs rdiff -u -r1.77 -r1.78 src/sys/dev/usb/usbdi_util.c
cvs rdiff -u -r1.51 -r1.52 src/sys/dev/usb/usbdi_util.h
cvs rdiff -u -r1.119 -r1.120 src/sys/dev/usb/usbdivar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usb_subr.c
diff -u src/sys/dev/usb/usb_subr.c:1.241 src/sys/dev/usb/usb_subr.c:1.242
--- src/sys/dev/usb/usb_subr.c:1.241	Thu Oct  3 05:20:31 2019
+++ src/sys/dev/usb/usb_subr.c	Sat Feb  8 08:47:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_subr.c,v 1.241 2019/10/03 05:20:31 maxv Exp $	*/
+/*	$NetBSD: usb_subr.c,v 1.242 2020/02/08 08:47:27 maxv Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.241 2019/10/03 05:20:31 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.242 2020/02/08 08:47:27 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -66,7 +66,6 @@ __KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v
 #define	DPRINTF(FMT,A,B,C,D)	USBHIST_LOG(usbdebug,FMT,A,B,C,D)
 #define	DPRINTFN(N,FMT,A,B,C,D)	USBHIST_LOGN(usbdebug,N,FMT,A,B,C,D)
 
-Static usbd_status usbd_set_config(struct usbd_device *, int);
 Static void usbd_devinfo(struct usbd_device *, int, char *, size_t);
 Static int usbd_getnewaddr(struct usbd_bus *);
 Static int usbd_print(void *, const char *);
@@ -113,51 +112,6 @@ usbd_errstr(usbd_status err)
 	}
 }
 
-usbd_status
-usbd_get_string_desc(struct usbd_device *dev, int sindex, int langid,
-		 usb_string_descriptor_t *sdesc, int *sizep)
-{
-	USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
-	usb_device_request_t req;
-	usbd_status err;
-	int actlen;
-
-	/*
-	 * Pass a full-sized buffer to usbd_do_request_len().  At least
-	 * one device has been seen returning additional data beyond the
-	 * provided buffers (2-bytes written shortly after the request
-	 * claims to have completed and returned the 2 byte header,
-	 * corrupting other memory.)
-	 */
-	req.bmRequestType = UT_READ_DEVICE;
-	req.bRequest = UR_GET_DESCRIPTOR;
-	USETW2(req.wValue, UDESC_STRING, sindex);
-	USETW(req.wIndex, langid);
-	USETW(req.wLength, 2);	/* only size byte first */
-	err = usbd_do_request_len(dev, , sizeof(*sdesc), sdesc,
-	USBD_SHORT_XFER_OK, , USBD_DEFAULT_TIMEOUT);
-	if (err)
-		return err;
-
-	if (actlen < 2)
-		return USBD_SHORT_XFER;
-
-	if (sdesc->bLength > sizeof(*sdesc))
-		return USBD_INVAL;
-	USETW(req.wLength, sdesc->bLength);	/* the whole string */
-	err = usbd_do_request_len(dev, , sizeof(*sdesc), sdesc,
-	USBD_SHORT_XFER_OK, , USBD_DEFAULT_TIMEOUT);
-	if (err)
-		return err;
-
-	if (actlen != sdesc->bLength) {
-		DPRINTF("expected %jd, got %jd", sdesc->bLength, actlen, 0, 0);
-	}
-
-	*sizep = actlen;
-	return USBD_NORMAL_COMPLETION;
-}
-
 static void
 usbd_trim_spaces(char *p)
 {
@@ -549,23 +503,6 @@ usbd_free_iface_data(struct usbd_device 
 	}
 }
 
-Static usbd_status
-usbd_set_config(struct usbd_device *dev, int conf)
-{
-	usb_device_request_t req;
-
-	USBHIST_FUNC();
-	USBHIST_CALLARGS(usbdebug, "dev %#jx conf %jd",
-	(uintptr_t)dev, conf, 0, 0);
-
-	req.bmRequestType = UT_WRITE_DEVICE;
-	req.bRequest = UR_SET_CONFIG;
-	USETW(req.wValue, conf);
-	USETW(req.wIndex, 0);
-	USETW(req.wLength, 0);
-	return usbd_do_request(dev, , 0);
-}
-
 usbd_status
 usbd_set_config_no(struct usbd_device *dev, int no, int msg)
 {
@@ -1164,36 +1101,6 @@ usbd_reattach_device(device_t parent, st
 }
 
 /*
- * Get the first 8 bytes of the device descriptor.
- * Do as Windows does: try to read 64 bytes -- there are devices which
- * recognize the initial descriptor fetch (before the control endpoint's
- * MaxPacketSize is known by the host) by exactly this length.
- */
-usbd_status
-usbd_get_initial_ddesc(struct usbd_device *dev, usb_device_descriptor_t *desc)
-{
-	USBHIST_FUNC();
-	USBHIST_CALLARGS(usbdebug, "dev %#jx", (uintptr_t)dev, 0, 0, 0);
-	usb_device_request_t req;
-	char buf[64];
-	int res, actlen;
-
-	req.bmRequestType = UT_READ_DEVICE;
-	req.bRequest = UR_GET_DESCRIPTOR;
-	USETW2(req.wValue, UDESC_DEVICE, 0);
-	USETW(req.wIndex, 0);
-	USETW(req.wLength, 8);
-	res = usbd_do_request_flags(dev, , buf, USBD_SHORT_XFER_OK,
-		, USBD_DEFAULT_TIMEOUT);
-	if (res)
-		return res;
-	if (actlen < 8)
-		return USBD_SHORT_XFER;
-	memcpy(desc, buf, 8);
-	return USBD_NORMAL_COMPLETION;
-}
-
-/*
  * Called when a new device has been put in the powered state,
  * but not yet in the addressed state.
  * Get initial descriptor, set the address, get full descriptor,

Index: src/sys/dev/usb/usbdi_util.c
diff -u 

CVS commit: src/sys/dev/ic

2020-02-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Feb  8 08:23:01 UTC 2020

Modified Files:
src/sys/dev/ic: aic79xx_inline.h

Log Message:
Apply FreeBSD r357300:

 > aic7xxx(4): Fix unintended sign extension in ahd_inq()
 >
 > ahd_inb() returns type uint8_t.  The shift left by untyped 24 implicitly
 > promotes the result to type (signed) int.  Then the binary OR with uint64_t
 > values sign-extends the integer.  If bit 31 of the read value happened to be
 > set, the 64-bit result would have all upper 32 bits set to 1 due to OR.
 > This is clearly not intended.
 >
 > Reported by: Coverity
 > CID: 980473 (old one!)


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/ic/aic79xx_inline.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/aic79xx_inline.h
diff -u src/sys/dev/ic/aic79xx_inline.h:1.22 src/sys/dev/ic/aic79xx_inline.h:1.23
--- src/sys/dev/ic/aic79xx_inline.h:1.22	Sat Apr 27 13:25:09 2013
+++ src/sys/dev/ic/aic79xx_inline.h	Sat Feb  8 08:23:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: aic79xx_inline.h,v 1.22 2013/04/27 13:25:09 kardel Exp $	*/
+/*	$NetBSD: aic79xx_inline.h,v 1.23 2020/02/08 08:23:01 msaitoh Exp $	*/
 
 /*
  * Inline routines shareable across OS platforms.
@@ -548,7 +548,7 @@ ahd_inq(struct ahd_softc *ahd, u_int por
 	return ((ahd_inb(ahd, port))
 	  | (ahd_inb(ahd, port+1) << 8)
 	  | (ahd_inb(ahd, port+2) << 16)
-	  | (ahd_inb(ahd, port+3) << 24)
+	  | (((uint64_t)ahd_inb(ahd, port+3)) << 24)
 	  | (((uint64_t)ahd_inb(ahd, port+4)) << 32)
 	  | (((uint64_t)ahd_inb(ahd, port+5)) << 40)
 	  | (((uint64_t)ahd_inb(ahd, port+6)) << 48)



CVS commit: src/sys/dev/usb

2020-02-08 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Feb  8 08:18:06 UTC 2020

Modified Files:
src/sys/dev/usb: usbdi_util.c usbdi_util.h

Log Message:
Reorder usbdi_util.{c,h}, for clarity. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/usb/usbdi_util.c
cvs rdiff -u -r1.50 -r1.51 src/sys/dev/usb/usbdi_util.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usbdi_util.c
diff -u src/sys/dev/usb/usbdi_util.c:1.76 src/sys/dev/usb/usbdi_util.c:1.77
--- src/sys/dev/usb/usbdi_util.c:1.76	Sat Feb  8 07:53:23 2020
+++ src/sys/dev/usb/usbdi_util.c	Sat Feb  8 08:18:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi_util.c,v 1.76 2020/02/08 07:53:23 maxv Exp $	*/
+/*	$NetBSD: usbdi_util.c,v 1.77 2020/02/08 08:18:06 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.76 2020/02/08 07:53:23 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.77 2020/02/08 08:18:06 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -154,6 +154,8 @@ usbd_get_device_desc(struct usbd_device 
 			 0, USB_DEVICE_DESCRIPTOR_SIZE, d);
 }
 
+/* -- */
+
 usbd_status
 usbd_get_device_status(struct usbd_device *dev, usb_status_t *st)
 {
@@ -184,22 +186,6 @@ usbd_get_hub_status(struct usbd_device *
 }
 
 usbd_status
-usbd_set_address(struct usbd_device *dev, int addr)
-{
-	USBHIST_FUNC();
-	USBHIST_CALLARGS(usbdebug, "dev %#jx addr %jd",
-	(uintptr_t)dev, addr, 0, 0);
-	usb_device_request_t req;
-
-	req.bmRequestType = UT_WRITE_DEVICE;
-	req.bRequest = UR_SET_ADDRESS;
-	USETW(req.wValue, addr);
-	USETW(req.wIndex, 0);
-	USETW(req.wLength, 0);
-	return usbd_do_request(dev, , 0);
-}
-
-usbd_status
 usbd_get_port_status(struct usbd_device *dev, int port, usb_port_status_t *ps)
 {
 	USBHIST_FUNC();
@@ -233,6 +219,8 @@ usbd_get_port_status_ext(struct usbd_dev
 	return usbd_do_request(dev, , pse);
 }
 
+/* -- */
+
 usbd_status
 usbd_clear_hub_feature(struct usbd_device *dev, int sel)
 {
@@ -343,6 +331,62 @@ usbd_clear_endpoint_feature(struct usbd_
 	return usbd_do_request(dev, , 0);
 }
 
+/* -- */
+
+usbd_status
+usbd_get_config(struct usbd_device *dev, uint8_t *conf)
+{
+	USBHIST_FUNC();
+	USBHIST_CALLARGS(usbdebug, "dev %#jx", (uintptr_t)dev, 0, 0, 0);
+	usb_device_request_t req;
+
+	req.bmRequestType = UT_READ_DEVICE;
+	req.bRequest = UR_GET_CONFIG;
+	USETW(req.wValue, 0);
+	USETW(req.wIndex, 0);
+	USETW(req.wLength, 1);
+	return usbd_do_request(dev, , conf);
+}
+
+usbd_status
+usbd_set_address(struct usbd_device *dev, int addr)
+{
+	USBHIST_FUNC();
+	USBHIST_CALLARGS(usbdebug, "dev %#jx addr %jd",
+	(uintptr_t)dev, addr, 0, 0);
+	usb_device_request_t req;
+
+	req.bmRequestType = UT_WRITE_DEVICE;
+	req.bRequest = UR_SET_ADDRESS;
+	USETW(req.wValue, addr);
+	USETW(req.wIndex, 0);
+	USETW(req.wLength, 0);
+	return usbd_do_request(dev, , 0);
+}
+
+usbd_status
+usbd_set_idle(struct usbd_interface *iface, int duration, int id)
+{
+	usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
+	struct usbd_device *dev;
+	usb_device_request_t req;
+
+	USBHIST_FUNC();
+	USBHIST_CALLARGS(usbdebug, "duration %jd id %jd", duration, id, 0, 0);
+
+	if (ifd == NULL)
+		return USBD_IOERROR;
+	usbd_interface2device_handle(iface, );
+	req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
+	req.bRequest = UR_SET_IDLE;
+	USETW2(req.wValue, duration, id);
+	USETW(req.wIndex, ifd->bInterfaceNumber);
+	USETW(req.wLength, 0);
+	return usbd_do_request(dev, , 0);
+}
+
+/* -- */
+
 usbd_status
 usbd_get_protocol(struct usbd_interface *iface, uint8_t *report)
 {
@@ -389,6 +433,8 @@ usbd_set_protocol(struct usbd_interface 
 	return usbd_do_request(dev, , 0);
 }
 
+/* -- */
+
 usbd_status
 usbd_set_report(struct usbd_interface *iface, int type, int id, void *data,
 		int len)
@@ -433,27 +479,6 @@ usbd_get_report(struct usbd_interface *i
 }
 
 usbd_status
-usbd_set_idle(struct usbd_interface *iface, int duration, int id)
-{
-	usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
-	struct usbd_device *dev;
-	usb_device_request_t req;
-
-	USBHIST_FUNC();
-	USBHIST_CALLARGS(usbdebug, "duration %jd id %jd", duration, id, 0, 0);
-
-	if (ifd == NULL)
-		return USBD_IOERROR;
-	usbd_interface2device_handle(iface, );
-	req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
-	req.bRequest = UR_SET_IDLE;
-	USETW2(req.wValue, duration, id);
-	USETW(req.wIndex, ifd->bInterfaceNumber);
-	USETW(req.wLength, 0);
-	return