Skip to contentSkip to conversation

Wsometimes-uninitialized warning

DISCUSSION Will Deacon 1 participant 1 message Sep 17, 2018 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 25 lines · Sodagudi Prasad

Hi All,

I have observed compile time issues with modules incremental compilation using clang.
I referred to following clang documentation about this warning.
http://releases.llvm.org/3.2/tools/clang/docs/ReleaseNotes.html

But in kernel code, PERCPU_OP macro default case is not reachable to throw this -Wsometimes-uninitialized warning.
BUILD_BUG() is getting used for the default cases of the PERCPU_OP macro. Have you observed -Wsometimes-uninitialized warnings with clang when compiling 4.14.6?

/arch/arm64/include/asm/percpu.h:102:1: note: variable 'ret' is declared here
/arch/arm64/include/asm/percpu.h:52:2: note: expanded from macro 'PERCPU_OP'

        unsigned long loop, ret;                                        \
        ^

/arch/arm64/include/asm/percpu.h:103:1: error: variable 'ret' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized]
PERCPU_OP(and, and)
^~~~~~~~~~~~~~~~~~~
/arch/arm64/include/asm/percpu.h:95:2: note: expanded from macro 'PERCPU_OP'

Quoted 4 lines
        default:                                                        \

Do you have any suggestions/comments?

FWIW, I had a go at rewriting that file last week:

https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/commit/?h=pcpu&id=126c36f538d494d0342ba8e95013936b85d7c5e2

With that, the switch statement disappears altogether.

Will