lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5d8a5f7f-be7a-265c-855d-7cb4fae9019e@redhat.com>
Date:   Mon, 23 Jan 2017 20:22:12 +0100
From:   Thomas Huth <thuth@...hat.com>
To:     SF Markus Elfring <elfring@...rs.sourceforge.net>,
        kvm@...r.kernel.org, kvm-ppc@...r.kernel.org,
        linuxppc-dev@...ts.ozlabs.org, Alexander Graf <agraf@...e.com>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Michael Ellerman <mpe@...erman.id.au>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Radim Krčmář <rkrcmar@...hat.com>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: Re: [PATCH 05/11] KVM: PPC: Book3S HV: Adjust nine checks for null
 pointers

On 20.01.2017 19:23, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@...rs.sourceforge.net>
> Date: Fri, 20 Jan 2017 11:25:48 +0100
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> The script "checkpatch.pl" pointed information out like the following.
> 
> Comparison to NULL could be written …

That's maybe ok for new code / if the code has to be touched anyway ...
but for existing code, this sounds very much like unnecessary code-churn
to me (e.g. it hides more important information with "git blame").

 Thomas


> 
> Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
> ---
>  arch/powerpc/kvm/book3s_hv.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index cfc7699d05df..3122998f6a32 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -458,7 +458,7 @@ static unsigned long do_h_register_vpa(struct kvm_vcpu *vcpu,
>  
>  		/* convert logical addr to kernel addr and read length */
>  		va = kvmppc_pin_guest_page(kvm, vpa, &nb);
> -		if (va == NULL)
> +		if (!va)
>  			return H_PARAMETER;
>  		if (subfunc == H_VPA_REG_VPA)
>  			len = be16_to_cpu(((struct reg_vpa *)va)->length.hword);
> @@ -1591,8 +1591,7 @@ static struct kvmppc_vcore *kvmppc_vcore_create(struct kvm *kvm, int core)
>  	struct kvmppc_vcore *vcore;
>  
>  	vcore = kzalloc(sizeof(struct kvmppc_vcore), GFP_KERNEL);
> -
> -	if (vcore == NULL)
> +	if (!vcore)
>  		return NULL;
>  
>  	spin_lock_init(&vcore->lock);
> @@ -2221,7 +2220,7 @@ static void collect_piggybacks(struct core_info *cip, int target_threads)
>  		prepare_threads(pvc);
>  		if (!pvc->n_runnable) {
>  			list_del_init(&pvc->preempt_list);
> -			if (pvc->runner == NULL) {
> +			if (!pvc->runner) {
>  				pvc->vcore_state = VCORE_INACTIVE;
>  				kvmppc_core_end_stolen(pvc);
>  			}
> @@ -2287,7 +2286,7 @@ static void post_guest_process(struct kvmppc_vcore *vc, bool is_master)
>  		} else {
>  			vc->vcore_state = VCORE_INACTIVE;
>  		}
> -		if (vc->n_runnable > 0 && vc->runner == NULL) {
> +		if (vc->n_runnable > 0 && !vc->runner) {
>  			/* make sure there's a candidate runner awake */
>  			i = -1;
>  			vcpu = next_runnable_thread(vc, &i);
> @@ -2786,7 +2785,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
>  
>  	while (vcpu->arch.state == KVMPPC_VCPU_RUNNABLE &&
>  	       !signal_pending(current)) {
> -		if (vc->vcore_state == VCORE_PREEMPT && vc->runner == NULL)
> +		if (vc->vcore_state == VCORE_PREEMPT && !vc->runner)
>  			kvmppc_vcore_end_preempt(vc);
>  
>  		if (vc->vcore_state != VCORE_INACTIVE) {
> @@ -2833,7 +2832,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
>  		vc->vcore_state == VCORE_PIGGYBACK))
>  		kvmppc_wait_for_exec(vc, vcpu, TASK_UNINTERRUPTIBLE);
>  
> -	if (vc->vcore_state == VCORE_PREEMPT && vc->runner == NULL)
> +	if (vc->vcore_state == VCORE_PREEMPT && !vc->runner)
>  		kvmppc_vcore_end_preempt(vc);
>  
>  	if (vcpu->arch.state == KVMPPC_VCPU_RUNNABLE) {
> @@ -3203,7 +3202,7 @@ void kvmppc_alloc_host_rm_ops(void)
>  	int size;
>  
>  	/* Not the first time here ? */
> -	if (kvmppc_host_rm_ops_hv != NULL)
> +	if (kvmppc_host_rm_ops_hv)
>  		return;
>  
>  	ops = kzalloc(sizeof(struct kvmppc_host_rm_ops), GFP_KERNEL);
> @@ -3430,10 +3429,10 @@ static int kvmppc_set_passthru_irq(struct kvm *kvm, int host_irq, int guest_gsi)
>  	mutex_lock(&kvm->lock);
>  
>  	pimap = kvm->arch.pimap;
> -	if (pimap == NULL) {
> +	if (!pimap) {
>  		/* First call, allocate structure to hold IRQ map */
>  		pimap = kvmppc_alloc_pimap();
> -		if (pimap == NULL) {
> +		if (!pimap) {
>  			mutex_unlock(&kvm->lock);
>  			return -ENOMEM;
>  		}
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ