Message ID | 20220119155741.1766541-5-rostedt@goodmis.org (mailing list archive) |
---|---|
State | Accepted |
Commit | 915e7f58eb59530412595b69e9511c5933014c0c |
Headers | show |
Series | libtracefs: Address the comments that Tzvetomir had for the get affinity functions | expand |
diff --git a/src/tracefs-instance.c b/src/tracefs-instance.c index db51af3818f0..1493938fa445 100644 --- a/src/tracefs-instance.c +++ b/src/tracefs-instance.c @@ -1000,7 +1000,16 @@ static inline int update_cpu_set(int cpus, int cpu_set, int cpu, return 0; CPU_SET_S(cpu_set + cpu, set_size, set); - return 1; + + /* + * It is possible that the passed in set_size is not big enough + * to hold the cpu we just set. If that's the case, do not report + * it as being set. + * + * The CPU_ISSET_S() should return false if the CPU given to it + * is bigger than the set itself. + */ + return CPU_ISSET_S(cpu_set + cpu, set_size, set) ? 1 : 0; } /**