guile-devel
[Top][All Lists]
Advanced

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

Bug in scm_getaffinity


From: Eli Zaretskii
Subject: Bug in scm_getaffinity
Date: Wed, 02 Jul 2014 19:30:06 +0300

While working on the MS-Windows emulation of this function, I bumped
into something that looks like a bug in its subroutine:

  static SCM
  cpu_set_to_bitvector (const cpu_set_t *cs)
  {
    SCM bv;
    size_t cpu;

    bv = scm_c_make_bitvector (sizeof (*cs), SCM_BOOL_F);

    for (cpu = 0; cpu < sizeof (*cs); cpu++)
      {
        if (CPU_ISSET (cpu, cs))
          /* XXX: This is inefficient but avoids code duplication.  */
          scm_c_bitvector_set_x (bv, cpu, SCM_BOOL_T);
      }

I think using 'sizeof (*cs)' is incorrect here, we need to use
CPU_SETSIZE instead.  The cpu_set_t data type could be an array of bit
masks, in which case counting only bytes in it is wrong: the result is
too small.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]