Zack's Kernel News

Zack's Kernel News

Article from Issue 177/2015
Author(s):

Chronicler Zack Brown reports on the latest news, views, dilemmas, and developments within the Linux kernel community.

Bogus GCC Warnings Reveal Real Kernel Problem

Linus Torvalds recently took great pains to explain why even though a particular GCC warning resulted in identifying a true problem with the kernel code, the warning itself was nevertheless bogus and insane. In fact, he said, most of the warnings introduced in GCC 5.1 didn't seem so valuable to him.

The one that had caught his attention, though, was a warning against using a switch statement with a Boolean variable. Presumably, the GCC folks thought that the whole point of switch was to operate on several possible values using a simple coding structure, and thus avoid long if/else/if chains. They may have thought that for a Boolean variable, a simple if statement would be the only appropriate way to go.

In the case of this particular bit of kernel code, said Linus, the warning was good because the switch statement in the kernel used a Boolean variable, whereas the case statements did not. He felt that this would be a perfectly legitimate thing for GCC to issue warnings about. But, if the switch and case statements both used a Boolean variable, he said, it would be a perfectly fine use case, and might even be better than the equivalent if/else in some cases:

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Core Technologies

    Everyone wants to be root, because root can do anything. But in fact, its powers are now split. Learn more in this overview of capability sets.

  • Kernel News

    Chronicler Zack Brown reports on the latest news, views, dilemmas, and developments within the Linux kernel community.

  • Security Lessons: Capabilities

    Granting root access, even temporarily, is rife with danger. Capabilities could help.

  • Kernel News

    Chronicler Zack Brown reports on the latest news, views, dilemmas, and developments within the Linux kernel community.

  • Kernel News

    Chronicler Zack Brown reports on the latest news, views, dilemmas, and developments within the Linux kernel community.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News