Skip to content

Commit

Permalink
x86/hw_breakpoints: Make default case in hw_breakpoint_arch_parse() r…
Browse files Browse the repository at this point in the history
…eturn an error

When building with -Wsometimes-uninitialized, Clang warns:

arch/x86/kernel/hw_breakpoint.c:355:2: warning: variable 'align' is used
uninitialized whenever switch default is taken
[-Wsometimes-uninitialized]

The default cannot be reached because arch_build_bp_info() initializes
hw->len to one of the specified cases. Nevertheless the warning is valid
and returning -EINVAL makes sure that this cannot be broken by future
modifications.

Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: clang-built-linux@googlegroups.com
Link: ClangBuiltLinux/linux#392
Link: https://lkml.kernel.org/r/20190307212756.4648-1-natechancellor@gmail.com
  • Loading branch information
nathanchance authored and Thomas Gleixner committed Mar 22, 2019
1 parent 4fe64a6 commit e898e69
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions arch/x86/kernel/hw_breakpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ int hw_breakpoint_arch_parse(struct perf_event *bp,
#endif
default:
WARN_ON_ONCE(1);
return -EINVAL;
}

/*
Expand Down

0 comments on commit e898e69

Please sign in to comment.