Message ID | 1462544723-48415-3-git-send-email-roger.pau@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 06/05/16 15:25, Roger Pau Monne wrote: > Because it's undefined behaviour. > > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> > --- > Cc: Andrew Cooper <andrew.cooper3@citrix.com> > --- > include/arch/x86/processor.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/arch/x86/processor.h b/include/arch/x86/processor.h > index c9f253f..841953c 100644 > --- a/include/arch/x86/processor.h > +++ b/include/arch/x86/processor.h > @@ -134,7 +134,7 @@ > /* Segment-based Error Code - supplemental constants. */ > #define X86_EC_TABLE_MASK (3 << 1) > #define X86_EC_SEL_SHIFT 3 > -#define X86_EC_SEL_MASK (-1 << X86_EC_SEL_SHIFT) > +#define X86_EC_SEL_MASK (-1U << X86_EC_SEL_SHIFT) The resulting expression needs to be signed, to DTRT when implicitly promoted. I presume this was clang complaining? Does using the constant (-9) work? ~Andrew
On 06/05/16 15:57, Andrew Cooper wrote: > On 06/05/16 15:25, Roger Pau Monne wrote: >> Because it's undefined behaviour. >> >> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> >> --- >> Cc: Andrew Cooper <andrew.cooper3@citrix.com> >> --- >> include/arch/x86/processor.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/include/arch/x86/processor.h b/include/arch/x86/processor.h >> index c9f253f..841953c 100644 >> --- a/include/arch/x86/processor.h >> +++ b/include/arch/x86/processor.h >> @@ -134,7 +134,7 @@ >> /* Segment-based Error Code - supplemental constants. */ >> #define X86_EC_TABLE_MASK (3 << 1) >> #define X86_EC_SEL_SHIFT 3 >> -#define X86_EC_SEL_MASK (-1 << X86_EC_SEL_SHIFT) >> +#define X86_EC_SEL_MASK (-1U << X86_EC_SEL_SHIFT) > The resulting expression needs to be signed, to DTRT when implicitly > promoted. I presume this was clang complaining? > > Does using the constant (-9) work? Or indeed perhaps ~(1 << X86_EC_SEL_SHIFT) which (iirc) will keep the signed-ness of 1 even through bitwise inversion. ~Andrew
diff --git a/include/arch/x86/processor.h b/include/arch/x86/processor.h index c9f253f..841953c 100644 --- a/include/arch/x86/processor.h +++ b/include/arch/x86/processor.h @@ -134,7 +134,7 @@ /* Segment-based Error Code - supplemental constants. */ #define X86_EC_TABLE_MASK (3 << 1) #define X86_EC_SEL_SHIFT 3 -#define X86_EC_SEL_MASK (-1 << X86_EC_SEL_SHIFT) +#define X86_EC_SEL_MASK (-1U << X86_EC_SEL_SHIFT) #define X86_EC_GDT 0 #define X86_EC_LDT X86_EC_TI
Because it's undefined behaviour. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- Cc: Andrew Cooper <andrew.cooper3@citrix.com> --- include/arch/x86/processor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)