buffers.c: fix compilation issue
[ust.git] / libust / buffers.c
index 13660a8910402ad45e163c524aa845d37025a6df..241ca74d4172160000c3dbed8840acf617a90bde 100644 (file)
@@ -45,7 +45,15 @@ static int get_n_cpus(void)
                return n_cpus;
        }
 
-       result = sysconf(_SC_NPROCESSORS_ONLN);
+       /* On Linux, when some processors are offline
+        * _SC_NPROCESSORS_CONF counts the offline
+        * processors, whereas _SC_NPROCESSORS_ONLN
+        * does not. If we used _SC_NPROCESSORS_ONLN,
+        * getcpu() could return a value greater than
+        * this sysconf, in which case the arrays
+        * indexed by processor would overflow.
+        */
+       result = sysconf(_SC_NPROCESSORS_CONF);
        if(result == -1) {
                return -1;
        }
@@ -210,6 +218,7 @@ int ust_buffers_channel_open(struct ust_channel *chan, size_t subbuf_size, size_
        for(; i>=0; i--) {
                ust_buffers_close_buf(chan->buf[i]);
 error:
+               do {} while(0);
        }
 
        kref_put(&chan->kref, ust_buffers_destroy_channel);
This page took 0.040553 seconds and 4 git commands to generate.