KVM: x86: remove ignored type attribute
PATCH 1/1 KVM: x86: remove ignored type attribute
The macro insn_fetch marks the 'type' argument as having a specified alignment. Type attributes can only be applied to structs, unions, or enums, but insn_fetch is only ever invoked with integral types, so Clang produces 19 -Wignored-attributes warnings for this source file.
--- arch/x86/kvm/emulate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/emulate.c +1 -1
@@ -900,7 +900,7 @@ static __always_inline int do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt,if (rc !=X86EMUL_CONTINUE ) \ goto done; \ ctxt->_eip +=sizeof (_type); \ - _x = *(_type __aligned(1) *) ctxt->fetch.ptr; \ + _x = *(_type *) ctxt->fetch.ptr; \ ctxt->fetch.ptr +=sizeof (_type); \ _x; \ })
Signature · 1 line
2.11.0
Paolo Bonzini
maintainerQuoted 16 lines · Nick Desaulniers
The macro
insn_fetchmarks the 'type' argument as having a specified alignment. Type attributes can only be applied to structs, unions, or enums, butinsn_fetchis only ever invoked with integral types, so Clang produces 19 -Wignored-attributes warnings for this source file.Signed-off-by Nick Desaulniers <[email protected]>--- arch/x86/kvm/emulate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/kvm/emulate.c +0
-0
arch/x86/kvm/emulate.c static __always_inline int do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt, · line 906
Quoted 8 lines
arch/x86/kvm/emulate.c +1
-1@@ -900,7 +900,7 @@ static __always_inline int do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt,if (rc !=X86EMUL_CONTINUE ) \ goto done; \ ctxt->_eip +=sizeof (_type); \ - _x = *(_type __aligned(1) *) ctxt->fetch.ptr; \ + _x = *(_type *) ctxt->fetch.ptr; \ ctxt->fetch.ptr +=sizeof (_type); \ _x; \ })
Can you make a patch that uses memcpy instead? Both GCC and clang will compile it to a simple load.
Paolo
PATCH v2 1/1 KVM: x86: remove ignored type attribute
In reply to Nick DesaulniersThe macro insn_fetch marks the 'type' argument as having a specified alignment. Type attributes can only be applied to structs, unions, or enums, but insn_fetch is only ever invoked with integral types, so Clang produces 19 -Wignored-attributes warnings for this source file.
---
Changes in v2:
* prefer memcpy
* fix up trailing tabs
arch/x86/kvm/emulate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/emulate.c +1 -1
@@ -900,7 +900,7 @@ static __always_inline int do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt,if (rc !=X86EMUL_CONTINUE ) \ goto done; \ ctxt->_eip +=sizeof (_type); \ - _x = *(_type __aligned(1) *) ctxt->fetch.ptr; \ +memcpy (&_x, ctxt->fetch.ptr,sizeof (_type)); \ ctxt->fetch.ptr +=sizeof (_type); \ _x; \ })
Signature · 1 line
2.11.0
gah, forgot to amend the trailing tab change in.
Do you mind just fixing it up when you merge or shall I send v3?
Paolo Bonzini
maintainerQuoted 20 lines · Nick Desaulniers
The macro
insn_fetchmarks the 'type' argument as having a specified alignment. Type attributes can only be applied to structs, unions, or enums, butinsn_fetchis only ever invoked with integral types, so Clang produces 19 -Wignored-attributes warnings for this source file.Signed-off-by Nick Desaulniers <[email protected]>---
Changes in v2:
* prefer memcpy
* fix up trailing tabsarch/x86/kvm/emulate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/kvm/emulate.c +0
-0
arch/x86/kvm/emulate.c static __always_inline int do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt, · line 906
Quoted 8 lines
arch/x86/kvm/emulate.c +1
-1@@ -900,7 +900,7 @@ static __always_inline int do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt,if (rc !=X86EMUL_CONTINUE ) \ goto done; \ ctxt->_eip +=sizeof (_type); \ - _x = *(_type __aligned(1) *) ctxt->fetch.ptr; \ +memcpy (&_x, ctxt->fetch.ptr,sizeof (_type)); \ ctxt->fetch.ptr +=sizeof (_type); \ _x; \ })
Fixed up the tab and pushed, thanks.
Paolo