Re: Little bug in cyclictest

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

 




On Wed, 14 Aug 2019, Rachid Koucha wrote:

> Hi,
> 
> First of all, many thanks for such useful tools.
> 
> In the source code of cyclictest, I can see a mistake concerning the
> error checking of pthread_setaffinity_np():
> 
> Upon error, pthread functions return an error ant not -1. So, the
> following code:
> 
>     if (par->cpu != -1) {
>         CPU_ZERO(&mask);
>         CPU_SET(par->cpu, &mask);
>         thread = pthread_self();
>         if (pthread_setaffinity_np(thread, sizeof(mask), &mask) == -1)
>             warn("Could not set CPU affinity to CPU #%d\n",
>                  par->cpu);
>     }
> 
> should be fixed as follow:
> 
> int status;
> 
>     if (par->cpu != -1) {
>         CPU_ZERO(&mask);
>         CPU_SET(par->cpu, &mask);
>         thread = pthread_self();
>         if ((status = pthread_setaffinity_np(thread, sizeof(mask), &mask)) != 0)
>             warn("Could not set CPU affinity to CPU #%d: %s (%d)\n",                  par->cpu, strerror(status), status);
>     }
> 
> 
> Regards,
> 

Thanks, that looks correct. Please generate a patch and I'll apply it.

John Kacur

[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux