kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kvm: kvm_main: Remove unnecessary (void*) conversions
@ 2022-12-13  8:02 Li kunyu
  2022-12-16 16:56 ` Sean Christopherson
  2023-03-24 23:35 ` Sean Christopherson
  0 siblings, 2 replies; 3+ messages in thread
From: Li kunyu @ 2022-12-13  8:02 UTC (permalink / raw)
  To: pbonzini; +Cc: kvm, linux-kernel, Li kunyu

void * pointer assignment does not require a forced replacement.

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 fab4d3790578..1682b269ad4a 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3861,7 +3861,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;
 }
@@ -5445,8 +5445,7 @@ static int kvm_debugfs_open(struct inode *inode, struct file *file,
 			   const char *fmt)
 {
 	int ret;
-	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
@@ -5467,8 +5466,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);
@@ -5517,7 +5515,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:
@@ -5536,7 +5534,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] 3+ messages in thread

* Re: [PATCH] kvm: kvm_main: Remove unnecessary (void*) conversions
  2022-12-13  8:02 [PATCH] kvm: kvm_main: Remove unnecessary (void*) conversions Li kunyu
@ 2022-12-16 16:56 ` Sean Christopherson
  2023-03-24 23:35 ` Sean Christopherson
  1 sibling, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2022-12-16 16:56 UTC (permalink / raw)
  To: Li kunyu; +Cc: pbonzini, kvm, linux-kernel

On Tue, Dec 13, 2022, Li kunyu wrote:
> void * pointer assignment does not require a forced replacement.
> 
> 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 fab4d3790578..1682b269ad4a 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -3861,7 +3861,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));

Unrelated to your patch: doesn't this need proper RCU protection?  E.g. if
KVM_RUN changes vcpu->pid between the read and dereference in pid_nr(), and puts
the last reference to the old pid.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kvm: kvm_main: Remove unnecessary (void*) conversions
  2022-12-13  8:02 [PATCH] kvm: kvm_main: Remove unnecessary (void*) conversions Li kunyu
  2022-12-16 16:56 ` Sean Christopherson
@ 2023-03-24 23:35 ` Sean Christopherson
  1 sibling, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2023-03-24 23:35 UTC (permalink / raw)
  To: Sean Christopherson, pbonzini, Li kunyu; +Cc: kvm, linux-kernel

On Tue, 13 Dec 2022 16:02:36 +0800, Li kunyu wrote:
> void * pointer assignment does not require a forced replacement.
> 
> 

Applied to kvm-x86 generic, thanks!

[1/1] kvm: kvm_main: Remove unnecessary (void*) conversions
      https://github.com/kvm-x86/linux/commit/14aa40a1d05e

--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-24 23:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-13  8:02 [PATCH] kvm: kvm_main: Remove unnecessary (void*) conversions Li kunyu
2022-12-16 16:56 ` Sean Christopherson
2023-03-24 23:35 ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).