Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp219040imu; Thu, 10 Jan 2019 22:24:19 -0800 (PST) X-Google-Smtp-Source: ALg8bN62VCtH4a5EYMOj5HxKWqsQNB5IuFCmR0s/6nQKtwhnRtWC2oh039JLEW89KYI2gj9Je/ZI X-Received: by 2002:a62:b9a:: with SMTP id 26mr13397382pfl.196.1547187859873; Thu, 10 Jan 2019 22:24:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547187859; cv=none; d=google.com; s=arc-20160816; b=kqnlD3toGFR9Gj3RMrvy+ijjFz1ley9UGHe12qUXTEBiouesU4u7i4fKvXYDCtnKFf LjciRrEcxq1M1EyMTx+IJPFp3GvhcDP5mP2QKntRjD0X65behO7mUhuFbK+bz6jJFg2q 6tWnjhHXguvSNfFxbmOsKLvUCIZ8yU6clPBp2f2YPX/r7FCQCa38haRfuIF/jXOb39L+ f+KiV2mIvHB59zAe3toCVxK+puUmvAZtBw9fnAvnINSoTq/r+3v+K3PgxMZ1v6oq6HDM 9wBoS/VlnvLxMiBTZEIb+nJiPzKuG/dwbUJLAELaHhQ1tHQ9rMq4Tj8VKeYADX0yUpe2 W2Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=NPBtRH4wjGb2lES6CxEzmTjsa9sHbdQz1vhMEgaMEFI=; b=0d847IwHEueDD/fUYL9jMgPxvN99Of5k+1MOviw9AdEL1An9xjnRO+d4RB7p7503Ke wUKnI+LNVmT6+BhyiR485uvP3O3RcTsFMGc7C9UV/4phI4460er5cI+VHYmeVFlrO22C fl0tOA2FJ45e4TwR0lK+7ZlTd7jM5ibHdoBGPK2zA5B4U3tVExwpq/fKKrGfzsSIzyWl OhTPi6tQ+Kx6apw7tz8HMdnr6CjihkRyHAZxtqTMhh1ZjH48dYQD8hr8nUw5T35AHVmX JOxz3nHxB3ivcrHJoHwHDUWjOLdnLpyZ1HMXSRScBoyMwEA+R00F0LlfBiBj7ZUQQx96 ZSZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Md4NgACB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31si7312359plh.274.2019.01.10.22.24.05; Thu, 10 Jan 2019 22:24:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Md4NgACB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730141AbfAKDgN (ORCPT + 99 others); Thu, 10 Jan 2019 22:36:13 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:46234 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727957AbfAKDgN (ORCPT ); Thu, 10 Jan 2019 22:36:13 -0500 Received: by mail-pf1-f196.google.com with SMTP id c73so6268867pfe.13 for ; Thu, 10 Jan 2019 19:36:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=NPBtRH4wjGb2lES6CxEzmTjsa9sHbdQz1vhMEgaMEFI=; b=Md4NgACB5ZFuKd1zg+KHM6J2RJ7bvIMvMi8N1Qu52bANlbxEQ5stf9HbtZO6cs/ENo Ol4xlTuKwXv1YOyIgpadkQHrNVHccgyIWXXI/oGzze4DyJCiBgK/H97Eg8LFFKBc3k2w ykO/0wAqD8+OeXm3E20uwLI7TS2LmctZEFcKdsdH4DRf3gJ4MoSZe3RacROIndgRQ9a7 KwW822TofV57JX7oR1+74nUURup97vh1TNlAYtshmfsxno+s7x/gIc6pn7AdaZufxQ7p +hVLt/Ywh4TdVBMu41D15yg0k+bLbnOctrgLvPayMyAgHbTHx0khHzg1VVchhOWiR03c Ykdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=NPBtRH4wjGb2lES6CxEzmTjsa9sHbdQz1vhMEgaMEFI=; b=UbkWIfs7v4Vmg6eLkgvqa215PjUGeaiyQFLxJ70sxJJOMIvXDF31UydqTchkAhKxn9 5wZ9NWkmIiOqGJVysUOvNLMZRe7q+z3rm7LNmh1TBWQID/cBpppOgO0LjJnyptm7x9Ik ZkNrWnhjWsIGvwjwqvma3Hv4FcDAtJ3zT/f+IhHCMAVKJR1v7/M+qSQKm3pj5WmaXtc0 qFswda0pT9hT0QJdyMjcRjIgO6ULcvZhaJYCpF4C5bINxN3YjB2fzaR9h3nMOcVIAjvb fXClRY2C4SEHaYtpJcDIssuONqMKJtaGGzlpDTafs0jwh6ZmGqYM872lZ289LVOzyjyc xl+Q== X-Gm-Message-State: AJcUukfN6YB1ieTqHUCF6jtpcanWxwxKfZzNIlyNAynL6i1s0SROVE5J x6jFBe+k19lDoPiBxxy9NP4= X-Received: by 2002:a62:5793:: with SMTP id i19mr12955532pfj.49.1547177772144; Thu, 10 Jan 2019 19:36:12 -0800 (PST) Received: from raspberrypi ([218.147.106.184]) by smtp.gmail.com with ESMTPSA id 186sm147536738pga.36.2019.01.10.19.36.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Jan 2019 19:36:11 -0800 (PST) Date: Fri, 11 Jan 2019 03:36:07 +0000 From: Sidong Yang To: Dan Carpenter Cc: Greg Kroah-Hartman , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: vboxvideo: vbox_main: Remove unnecessary local variable Message-ID: <20190111033607.rsuj3yii6yoiksqm@raspberrypi> References: <20190110061347.31326-1-realwakka@gmail.com> <20190110122358.GC1743@kadam> <20190110170023.4vcyws3ktsf2sz3g@raspberrypi> <20190110192942.GF1718@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190110192942.GF1718@kadam> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 10, 2019 at 10:44:08PM +0300, Dan Carpenter wrote: > On Thu, Jan 10, 2019 at 05:00:24PM +0000, Sidong Yang wrote: > > I think you just point out that my code isn't obvious because the > > function returns negative error codes. I agree with you. But what if > > change my code like if(hgsmi_query_conf() != 0). > > > > That's even worse! :P > > You should do comparisons with zero when you are talking about zero > meaning the number zero. In this case, hgsmi_query_conf() returns "zezro > meaning success" not "zero meaning the number zero". How many bytes? > Zero. That is the number zero. > > != zero is a double negative, because NOT and ZERO are negatives. If > double negatives simplified the code we would add four of them instead > of just the one: > > if ((((hgsmi_query_conf() != 0) != 0) != 0) != 0) { > > See? Adding != 0 doesn't make it simpler... > > The other place where != 0 is appropriate besides talking about the > number is when you're using a strcmp() function because it works like > this: > > if (strcmp(a, b) < 0) { <-- means a < b > if (strcmp(a, b) == 0) { <-- means a == b > if (strcmp(a, b) != 0) { <-- means a != b > > regards, > dan carpenter > You're right. that is even worse. I understand and thank you for pointing out. regards, Sidong Yang