Module Name:    src
Committed By:   maxv
Date:           Sat May 11 11:59:22 UTC 2019

Modified Files:
        src/usr.sbin/cpuctl: cpuctl.c

Log Message:
Check the return value of cpuset_set(), to prevent future surprises.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.sbin/cpuctl/cpuctl.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/cpuctl/cpuctl.c
diff -u src/usr.sbin/cpuctl/cpuctl.c:1.29 src/usr.sbin/cpuctl/cpuctl.c:1.30
--- src/usr.sbin/cpuctl/cpuctl.c:1.29	Tue Jan 16 08:23:18 2018
+++ src/usr.sbin/cpuctl/cpuctl.c	Sat May 11 11:59:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpuctl.c,v 1.29 2018/01/16 08:23:18 mrg Exp $	*/
+/*	$NetBSD: cpuctl.c,v 1.30 2019/05/11 11:59:21 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2012, 2015 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #ifndef lint
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: cpuctl.c,v 1.29 2018/01/16 08:23:18 mrg Exp $");
+__RCSID("$NetBSD: cpuctl.c,v 1.30 2019/05/11 11:59:21 maxv Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -239,7 +239,8 @@ cpu_ucode(char **argv)
 		if (cpuset == NULL)
 			err(EXIT_FAILURE, "cpuset_create");
 		cpuset_zero(cpuset);
-		cpuset_set(id, cpuset);
+		if (cpuset_set(id, cpuset) < 0)
+			err(EXIT_FAILURE, "cpuset_set");
 		if (_sched_setaffinity(0, 0, cpuset_size(cpuset), cpuset) < 0) {
 			err(EXIT_FAILURE, "_sched_setaffinity");
 		}
@@ -271,7 +272,8 @@ cpu_identify(char **argv)
 			if (cpuset == NULL)
 				err(EXIT_FAILURE, "cpuset_create");
 			cpuset_zero(cpuset);
-			cpuset_set(id, cpuset);
+			if (cpuset_set(id, cpuset) < 0)
+				err(EXIT_FAILURE, "cpuset_set");
 			if (_sched_setaffinity(0, 0, cpuset_size(cpuset), cpuset) < 0) {
 				if (errno == EPERM) {
 					printf("Cannot bind to target CPU.  Output "

Reply via email to