* [PATCH 1/5] kvm/kvm_main: Modify the offset type to size_t, which is consistent with the calling function
@ 2022-08-12 10:15 Li kunyu
2022-08-12 10:22 ` [PATCH 2/5] kvm/kvm_main: remove unnecessary (void*) conversions Li kunyu
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Li kunyu @ 2022-08-12 10:15 UTC (permalink / raw)
To: pbonzini; +Cc: kvm, linux-kernel, Li kunyu
The offset variable is called size_t in the calling function.
Considering the number of bits in different architectures (32 and 64
represent different types), change it to a consistent variable.
Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
virt/kvm/kvm_main.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 515dfe9d3bcf..1b9700160eb1 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -5526,7 +5526,7 @@ static const struct file_operations stat_fops_per_vm = {
static int vm_stat_get(void *_offset, u64 *val)
{
- unsigned offset = (long)_offset;
+ size_t offset = (size_t)_offset;
struct kvm *kvm;
u64 tmp_val;
@@ -5542,7 +5542,7 @@ static int vm_stat_get(void *_offset, u64 *val)
static int vm_stat_clear(void *_offset, u64 val)
{
- unsigned offset = (long)_offset;
+ size_t offset = (size_t)_offset;
struct kvm *kvm;
if (val)
@@ -5562,7 +5562,7 @@ DEFINE_SIMPLE_ATTRIBUTE(vm_stat_readonly_fops, vm_stat_get, NULL, "%llu\n");
static int vcpu_stat_get(void *_offset, u64 *val)
{
- unsigned offset = (long)_offset;
+ size_t offset = (size_t)_offset;
struct kvm *kvm;
u64 tmp_val;
@@ -5578,7 +5578,7 @@ static int vcpu_stat_get(void *_offset, u64 *val)
static int vcpu_stat_clear(void *_offset, u64 val)
{
- unsigned offset = (long)_offset;
+ size_t offset = (size_t)_offset;
struct kvm *kvm;
if (val)
--
2.18.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/5] kvm/kvm_main: remove unnecessary (void*) conversions
2022-08-12 10:15 [PATCH 1/5] kvm/kvm_main: Modify the offset type to size_t, which is consistent with the calling function Li kunyu
@ 2022-08-12 10:22 ` Li kunyu
2022-08-12 10:24 ` [PATCH 3/5] kvm/kvm_main: The ops pointer variable does not need to be initialized and assigned, it is first allocated a memory address Li kunyu
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Li kunyu @ 2022-08-12 10:22 UTC (permalink / raw)
To: pbonzini; +Cc: kvm, linux-kernel, Li kunyu
remove unnecessary void* type castings.
Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
virt/kvm/kvm_main.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 1b9700160eb1..80f7934c1f59 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3839,7 +3839,7 @@ static int create_vcpu_fd(struct kvm_vcpu *vcpu)
#ifdef __KVM_HAVE_ARCH_VCPU_DEBUGFS
static int vcpu_get_pid(void *data, u64 *val)
{
- struct kvm_vcpu *vcpu = (struct kvm_vcpu *) data;
+ struct kvm_vcpu *vcpu = data;
*val = pid_nr(rcu_access_pointer(vcpu->pid));
return 0;
}
@@ -5396,8 +5396,7 @@ static int kvm_debugfs_open(struct inode *inode, struct file *file,
int (*get)(void *, u64 *), int (*set)(void *, u64),
const char *fmt)
{
- struct kvm_stat_data *stat_data = (struct kvm_stat_data *)
- inode->i_private;
+ struct kvm_stat_data *stat_data = inode->i_private;
/*
* The debugfs files are a reference to the kvm struct which
@@ -5420,8 +5419,7 @@ static int kvm_debugfs_open(struct inode *inode, struct file *file,
static int kvm_debugfs_release(struct inode *inode, struct file *file)
{
- struct kvm_stat_data *stat_data = (struct kvm_stat_data *)
- inode->i_private;
+ struct kvm_stat_data *stat_data = inode->i_private;
simple_attr_release(inode, file);
kvm_put_kvm(stat_data->kvm);
@@ -5470,7 +5468,7 @@ static int kvm_clear_stat_per_vcpu(struct kvm *kvm, size_t offset)
static int kvm_stat_data_get(void *data, u64 *val)
{
int r = -EFAULT;
- struct kvm_stat_data *stat_data = (struct kvm_stat_data *)data;
+ struct kvm_stat_data *stat_data = data;
switch (stat_data->kind) {
case KVM_STAT_VM:
@@ -5489,7 +5487,7 @@ static int kvm_stat_data_get(void *data, u64 *val)
static int kvm_stat_data_clear(void *data, u64 val)
{
int r = -EFAULT;
- struct kvm_stat_data *stat_data = (struct kvm_stat_data *)data;
+ struct kvm_stat_data *stat_data = data;
if (val)
return -EINVAL;
--
2.18.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/5] kvm/kvm_main: The ops pointer variable does not need to be initialized and assigned, it is first allocated a memory address
2022-08-12 10:15 [PATCH 1/5] kvm/kvm_main: Modify the offset type to size_t, which is consistent with the calling function Li kunyu
2022-08-12 10:22 ` [PATCH 2/5] kvm/kvm_main: remove unnecessary (void*) conversions Li kunyu
@ 2022-08-12 10:24 ` Li kunyu
2022-08-18 23:55 ` Sean Christopherson
2022-08-12 10:30 ` [PATCH 4/5] kvm/kvm_main: The npages variable does not need to be initialized and assigned, it is used after assignment Li kunyu
2022-08-12 10:31 ` [PATCH 5/5] kvm/kvm_main: remove unnecessary (const void*) conversions Li kunyu
3 siblings, 1 reply; 8+ messages in thread
From: Li kunyu @ 2022-08-12 10:24 UTC (permalink / raw)
To: pbonzini; +Cc: kvm, linux-kernel, Li kunyu
The ops pointer variable does not need to be initialized, because it
first allocates a memory address before it is used.
Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
virt/kvm/kvm_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 80f7934c1f59..82f2b90718a9 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -4378,7 +4378,7 @@ void kvm_unregister_device_ops(u32 type)
static int kvm_ioctl_create_device(struct kvm *kvm,
struct kvm_create_device *cd)
{
- const struct kvm_device_ops *ops = NULL;
+ const struct kvm_device_ops *ops;
struct kvm_device *dev;
bool test = cd->flags & KVM_CREATE_DEVICE_TEST;
int type;
--
2.18.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/5] kvm/kvm_main: The npages variable does not need to be initialized and assigned, it is used after assignment
2022-08-12 10:15 [PATCH 1/5] kvm/kvm_main: Modify the offset type to size_t, which is consistent with the calling function Li kunyu
2022-08-12 10:22 ` [PATCH 2/5] kvm/kvm_main: remove unnecessary (void*) conversions Li kunyu
2022-08-12 10:24 ` [PATCH 3/5] kvm/kvm_main: The ops pointer variable does not need to be initialized and assigned, it is first allocated a memory address Li kunyu
@ 2022-08-12 10:30 ` Li kunyu
2022-08-18 23:51 ` Sean Christopherson
2022-08-12 10:31 ` [PATCH 5/5] kvm/kvm_main: remove unnecessary (const void*) conversions Li kunyu
3 siblings, 1 reply; 8+ messages in thread
From: Li kunyu @ 2022-08-12 10:30 UTC (permalink / raw)
To: pbonzini; +Cc: kvm, linux-kernel, Li kunyu
The npages variable does not need to be initialized and assigned, it is
first assigned before it is used.
Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
virt/kvm/kvm_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 82f2b90718a9..f047799bf19b 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2516,7 +2516,7 @@ static int hva_to_pfn_slow(unsigned long addr, bool *async, bool write_fault,
{
unsigned int flags = FOLL_HWPOISON;
struct page *page;
- int npages = 0;
+ int npages;
might_sleep();
--
2.18.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/5] kvm/kvm_main: remove unnecessary (const void*) conversions
2022-08-12 10:15 [PATCH 1/5] kvm/kvm_main: Modify the offset type to size_t, which is consistent with the calling function Li kunyu
` (2 preceding siblings ...)
2022-08-12 10:30 ` [PATCH 4/5] kvm/kvm_main: The npages variable does not need to be initialized and assigned, it is used after assignment Li kunyu
@ 2022-08-12 10:31 ` Li kunyu
3 siblings, 0 replies; 8+ messages in thread
From: Li kunyu @ 2022-08-12 10:31 UTC (permalink / raw)
To: pbonzini; +Cc: kvm, linux-kernel, Li kunyu
Casting from a pointer of type void * to a pointer of type const void *
does not require a cast.
Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
virt/kvm/kvm_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index f047799bf19b..01883ecd8cc4 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3278,7 +3278,7 @@ EXPORT_SYMBOL_GPL(kvm_read_guest_cached);
int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len)
{
- const void *zero_page = (const void *) __va(page_to_phys(ZERO_PAGE(0)));
+ const void *zero_page = __va(page_to_phys(ZERO_PAGE(0)));
gfn_t gfn = gpa >> PAGE_SHIFT;
int seg;
int offset = offset_in_page(gpa);
--
2.18.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 4/5] kvm/kvm_main: The npages variable does not need to be initialized and assigned, it is used after assignment
2022-08-12 10:30 ` [PATCH 4/5] kvm/kvm_main: The npages variable does not need to be initialized and assigned, it is used after assignment Li kunyu
@ 2022-08-18 23:51 ` Sean Christopherson
2022-08-19 1:32 ` Li kunyu
0 siblings, 1 reply; 8+ messages in thread
From: Sean Christopherson @ 2022-08-18 23:51 UTC (permalink / raw)
To: Li kunyu; +Cc: pbonzini, kvm, linux-kernel
Please use "KVM: " for the shortlog scope, and write an actual shortlog. E.g.
KVM: Drop unnecessary initialization of "npages" in hva_to_pfn_slow()
On Fri, Aug 12, 2022, Li kunyu wrote:
> The npages variable does not need to be initialized and assigned, it is
> first assigned before it is used.
>
> Signed-off-by: Li kunyu <kunyu@nfschina.com>
> ---
With a proper shortlog,
Reviewed-by: Sean Christopherson <seanjc@google.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/5] kvm/kvm_main: The ops pointer variable does not need to be initialized and assigned, it is first allocated a memory address
2022-08-12 10:24 ` [PATCH 3/5] kvm/kvm_main: The ops pointer variable does not need to be initialized and assigned, it is first allocated a memory address Li kunyu
@ 2022-08-18 23:55 ` Sean Christopherson
0 siblings, 0 replies; 8+ messages in thread
From: Sean Christopherson @ 2022-08-18 23:55 UTC (permalink / raw)
To: Li kunyu; +Cc: pbonzini, kvm, linux-kernel
Needs a proper shortlog.
On Fri, Aug 12, 2022, Li kunyu wrote:
> The ops pointer variable does not need to be initialized, because it
> first allocates a memory address before it is used.
>
> Signed-off-by: Li kunyu <kunyu@nfschina.com>
> ---
Again, with a fixed shortlog,
Reviewed-by: Sean Christopherson <seanjc@google.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 4/5] kvm/kvm_main: The npages variable does not need to be initialized and assigned, it is used after assignment
2022-08-18 23:51 ` Sean Christopherson
@ 2022-08-19 1:32 ` Li kunyu
0 siblings, 0 replies; 8+ messages in thread
From: Li kunyu @ 2022-08-19 1:32 UTC (permalink / raw)
To: seanjc; +Cc: kunyu, kvm, linux-kernel, pbonzini
thanks, re-send these two patches after modification.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-08-19 1:33 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-12 10:15 [PATCH 1/5] kvm/kvm_main: Modify the offset type to size_t, which is consistent with the calling function Li kunyu
2022-08-12 10:22 ` [PATCH 2/5] kvm/kvm_main: remove unnecessary (void*) conversions Li kunyu
2022-08-12 10:24 ` [PATCH 3/5] kvm/kvm_main: The ops pointer variable does not need to be initialized and assigned, it is first allocated a memory address Li kunyu
2022-08-18 23:55 ` Sean Christopherson
2022-08-12 10:30 ` [PATCH 4/5] kvm/kvm_main: The npages variable does not need to be initialized and assigned, it is used after assignment Li kunyu
2022-08-18 23:51 ` Sean Christopherson
2022-08-19 1:32 ` Li kunyu
2022-08-12 10:31 ` [PATCH 5/5] kvm/kvm_main: remove unnecessary (const void*) conversions Li kunyu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.