NetBSD-Bugs archive

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

Re: bin/39955 (cpuctl identifies non-existing CPUs)



The following reply was made to PR bin/39955; it has been noted by GNATS.

From: Christoph Egger <Christoph_Egger%gmx.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost, 
 Thomas Klausner <wiz%NetBSD.org@localhost>
Subject: Re: bin/39955 (cpuctl identifies non-existing CPUs)
Date: Wed, 19 Nov 2008 11:58:54 +0100

 This is a multi-part message in MIME format.
 --------------050206040500020204050609
 Content-Type: text/plain; charset=ISO-8859-15
 Content-Transfer-Encoding: 7bit
 
 
 This diff should fix it.
 
 
 
 --------------050206040500020204050609
 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
  name="cpuctl.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="cpuctl.diff"
 
 Index: usr.sbin/cpuctl/cpuctl.c
 ===================================================================
 RCS file: /cvsroot/src/usr.sbin/cpuctl/cpuctl.c,v
 retrieving revision 1.10
 diff -u -p -r1.10 cpuctl.c
 --- usr.sbin/cpuctl/cpuctl.c   15 Oct 2008 08:22:06 -0000      1.10
 +++ usr.sbin/cpuctl/cpuctl.c   19 Nov 2008 10:52:26 -0000
 @@ -147,11 +147,12 @@ void
  cpu_identify(char **argv)
  {
        char name[32];
 -      int id, np;
 +      u_int id;
 +      long np;
        cpuset_t *cpuset;
  
        id = getcpuid(argv);
 -      snprintf(name, sizeof(name), "cpu%d", id);
 +      snprintf(name, sizeof(name), "cpu%u", id);
  
        np = sysconf(_SC_NPROCESSORS_CONF);
        if (np != 0) {
 @@ -179,10 +180,18 @@ getcpuid(char **argv)
  {
        char *argp;
        u_int id;
 +      long np;
  
 -      id = (int)strtoul(argv[0], &argp, 0);
 +      id = (u_int)strtoul(argv[0], &argp, 0);
        if (*argp != '\0')
                usage();
 +
 +      np = sysconf(_SC_NPROCESSORS_CONF);
 +      if (id >= np) {
 +              err(EXIT_FAILURE, "More than %li CPUs not configured", np);
 +              /* UNREACHED */
 +      }
 +
        return id;
  }
  
 
 --------------050206040500020204050609--
 


Home | Main Index | Thread Index | Old Index