kvm/kvm_main: Modify the offset type to size_t, which is consistent with the calling function
PATCH 1/5 kvm/kvm_main: Modify the offset type to size_t, which is consistent with the calling function
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.
--- virt/kvm/kvm_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
virt/kvm/kvm_main.c +4 -4
@@ -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)
Signature · 1 line
2.18.2
PATCH 2/5 kvm/kvm_main: remove unnecessary (void*) conversions
remove unnecessary void* type castings.
--- virt/kvm/kvm_main.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
virt/kvm/kvm_main.c +5 -7
@@ -3839,7 +3839,7 @@ static int create_vcpu_fd(struct kvm_vcpu *vcpu)#ifdef __KVM_HAVE_ARCH_VCPU_DEBUGFSstatic 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 ;
Signature · 1 line
2.18.2
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
In reply to Li kunyuThe ops pointer variable does not need to be initialized, because it first allocates a memory address before it is used.
--- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/kvm_main.c +1 -1
@@ -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;
Signature · 1 line
2.18.2
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
Needs a proper shortlog.
Quoted 5 lines · 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 <[email protected]>---
Again, with a fixed shortlog,
PATCH 4/5 kvm/kvm_main: The npages variable does not need to be initialized and assigned, it is used after assignment
In reply to Li kunyuThe npages variable does not need to be initialized and assigned, it is first assigned before it is used.
--- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/kvm_main.c +1 -1
@@ -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 ();
Signature · 1 line
2.18.2
Re: [PATCH 4/5] kvm/kvm_main: The npages variable does not need to be initialized and assigned, it is used after assignment
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()
Quoted 5 lines · 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 <[email protected]>---
With a proper shortlog,
Re: [PATCH 4/5] kvm/kvm_main: The npages variable does not need to be initialized and assigned, it is used after assignment
thanks, re-send these two patches after modification.
PATCH 5/5 kvm/kvm_main: remove unnecessary (const void*) conversions
In reply to Li kunyuCasting from a pointer of type void * to a pointer of type const void * does not require a cast.
--- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/kvm_main.c +1 -1
@@ -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);
Signature · 1 line
2.18.2