Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/cpuctl Check the return value of cpuset_set(), to p...



details:   https://anonhg.NetBSD.org/src/rev/ac5762f8e78d
branches:  trunk
changeset: 999005:ac5762f8e78d
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat May 11 11:59:21 2019 +0000

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

diffstat:

 usr.sbin/cpuctl/cpuctl.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r 45a13d90d288 -r ac5762f8e78d usr.sbin/cpuctl/cpuctl.c
--- a/usr.sbin/cpuctl/cpuctl.c  Sat May 11 11:53:55 2019 +0000
+++ b/usr.sbin/cpuctl/cpuctl.c  Sat May 11 11:59:21 2019 +0000
@@ -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 @@
                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 @@
                        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 "



Home | Main Index | Thread Index | Old Index