Re: Why doesn't the GCC give any warning to these unused variables in the Linux kernel?

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

 



On Sun, Feb 20, 2022 at 07:39:13AM +0000, Song Zhi wrote:
> Normally, the compiler warns if a variable is declared but is never referenced. In the Linux kernel source code, some unused functions and variables are marked __atrribute__((unused)).
> 
> 
> ==> https://livegrep.com/search/linux?q=__attribute__((unused))
> 
> 
> GCC, on the other hand, does not provide any warnings for these unused and unmarked variables like the integer flags in kernel/sched/idle.c#427<https://elixir.bootlin.com/linux/latest/source/kernel/sched/idle.c#L427> .
> 
> 
> Why?

Because we do not enable that build warning as it is mostly useless for
kernel code due to how different apis work inside the kernel.

Try enabling it yourself and see all of the noise that happens.

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux