Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2382575imu; Thu, 10 Jan 2019 13:12:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN61p8xqHutIvURe2tzdUmodZX3sTeYvgaacudqe7KJvx3jx1P87e7ucT55rqgwUceva7+VX X-Received: by 2002:a62:30c3:: with SMTP id w186mr11853485pfw.39.1547154766164; Thu, 10 Jan 2019 13:12:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547154766; cv=none; d=google.com; s=arc-20160816; b=Pw3Fd7o3VoPXUiRlo7zffGYVn533JbQYLfUYpvaQf+fRmkB2rSPBTgdqNOVzToD6ra 0yvfWk8nzoqOf0uzTq5HV7Aazo1PKuQSBYNvfAGfOa/yDO/snUo2/JAzU8Vc1i6V3Mgm hLzRKoeIIrqwYVe+ZxDV/BSJfatsPI7Dr4bEJF7xxemYVCetiix1jlasaI/hNHCS7hti y8zfDSiT56IeZBD+PsTwzwXxE51u69ehiX9vb5l68XOMU4zkiQuQcm68cfQ47KGs7cCL 5vFv5Q64IlyYJ8bI+BtAO8huVOgzyG/I08RixlfSCEKSuwsWSHNirRA5Y6WzIfzR8VUB UvdQ== 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=S6BmiYnkNetnAUKo8Bj39i5K8Y8JiLyQGKw382HHSZE=; b=OGVtc8XfWQMyseCop0IXfjkaEQds5Ob6AZT5cr7LYfqvzCld3L1Htb6FhS9nO6QMuv tpcjzfvAQiud4gVpKRV3i+CJrZ4zI/QfK/pDawA9wIo6n/FdPiRz0SeubX1qW3TxezDJ FurABrZIEhyVNMMv9Pb09x3uzmu87eYk4ZWMWwo1+xMR4DbMFeTZ/saRyHT22bgYP+dw 6xuC7fle+sg7xDEICFODT0UJPSYOICkRriFYXy1CGgzdSZPITVHlN11tOzOgrB7tMG1e lJzd7DbhFs3uFCNI7EVnghVESWy3/41KtO2mfXQElsrC/PG6YNNcpIgmOyJQAMgphr/L 23Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=nGboNWTI; 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=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 184si33661801pgj.329.2019.01.10.13.12.31; Thu, 10 Jan 2019 13:12:46 -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=@oracle.com header.s=corp-2018-07-02 header.b=nGboNWTI; 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=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728547AbfAJToP (ORCPT + 99 others); Thu, 10 Jan 2019 14:44:15 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:41864 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbfAJToP (ORCPT ); Thu, 10 Jan 2019 14:44:15 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0AJciJJ167136; Thu, 10 Jan 2019 19:44:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=S6BmiYnkNetnAUKo8Bj39i5K8Y8JiLyQGKw382HHSZE=; b=nGboNWTIHL62s+FuGW06Kt5tQKR21L/TxuV90fHD8e6Y2ZrTexatpRu90sHeslLF2nky vg6b8v0+zDBCySxioPYag1aSJXZTpL+IQ/TrOeJEt2Z8m6JpZ9Na5O3Mqnz8AMm/caOH 7IkkaN31SqFGAO2W3izi3xfQmwVxpyezWL1/7fAIqXm8QlFInOhv7GgWQqbLr5SQ/d7E TBuZHJMYAEebCucXj9NUzuI7+Hxc0OIXnw0f2jKkrXy8PsddnLlbN86z+dPyJ2ZWs5CU p2aCEK1J5fLKdHcBR6SefvU3GsibBnjs0lufxnxcPYMzwaw5zqOX1SwCpoh0n73qfzJh 5A== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2ptm0uha1u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jan 2019 19:44:11 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x0AJiA4U016874 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jan 2019 19:44:10 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x0AJi9H2010247; Thu, 10 Jan 2019 19:44:10 GMT Received: from kadam (/41.202.241.51) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 10 Jan 2019 11:44:09 -0800 Date: Thu, 10 Jan 2019 22:44:08 +0300 From: Dan Carpenter To: Sidong Yang 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: <20190110192942.GF1718@kadam> References: <20190110061347.31326-1-realwakka@gmail.com> <20190110122358.GC1743@kadam> <20190110170023.4vcyws3ktsf2sz3g@raspberrypi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190110170023.4vcyws3ktsf2sz3g@raspberrypi> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9132 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901100152 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 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