Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1735361pxk; Tue, 1 Sep 2020 06:38:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtMZrn3/MACMG3SS2iJU74QsfVylJy8yj76NFPvfF6CLtNOdvVGh5iR+urw6vNuJKSdDch X-Received: by 2002:a17:906:c0d1:: with SMTP id bn17mr1455424ejb.311.1598967536035; Tue, 01 Sep 2020 06:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598967536; cv=none; d=google.com; s=arc-20160816; b=b22iqLB0xZeJAw8vgMVSqx2fvxA5ixVhK+oci3wTDJnEYMpbu/NyoIJae4SaVff76D UNGEeaVlPHSs5hNKQ1zY7NAfCZcNDircy+EEENMUDsJPGS0c4K4r4oZHQlqWHrRnfsx3 mB65181jsVdJwfKcYOukyG49M40oQwO9qDmuUNh27ncmI7SvPG+15KBjAmFVB4gfTIyW t9CA6lDQZWBA9BO+r6219x/rgsa27CrIUQw1sAU59DDeVQKkVeSPe9X8XnzTAhJsV/mA bx8a3gMtRe97ztCQOXSjFYBowSPCLnVALWWcuOw+diDQw9Z5Mxhh2askhfLDBN7siN8j 8qbg== 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=tncZGQIWIEZ4FEAe9DcScrIAwrizsiWeexR76yy0IIQ=; b=Px9IiAOWfVL+Ha1IhuU1YL69r9q2QMQ5p+WTkygwsv+gGzt2COW3KJJ66/YdUcicmS vKabVlziuUmZq0sy5rzeGSsavLoj7IeL+AHoVD7F/LebXgICGzI1CxQEdQe6L5zPza8M 0z/zNBZSNwGa1MTs0V3LZgDMXpEkU4z0c7riQgYIYtGWuFbPm/tcvz4ReLLyGjkeT11l ga5unnn+LuzVaXslPRd4ThJPkvW7gj1MfQfx/VQqolUDdLSbsCr+DQReHlrBbw7+/432 oOePZqYqkJLqs8KVpN61eh6PjHMAGHHVTnpq0diol3pFkMmOJ2UdJUeqcxVtRPlhIxIm AIpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=dtxeQRgl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id v8si613314ejw.434.2020.09.01.06.38.31; Tue, 01 Sep 2020 06:38:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=dtxeQRgl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728018AbgIANfX (ORCPT + 99 others); Tue, 1 Sep 2020 09:35:23 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57370 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728242AbgIANds (ORCPT ); Tue, 1 Sep 2020 09:33:48 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 081D0l24055238; Tue, 1 Sep 2020 13:33:40 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-2020-01-29; bh=tncZGQIWIEZ4FEAe9DcScrIAwrizsiWeexR76yy0IIQ=; b=dtxeQRglYiDPtopyn3Vtf+9DrDAhfWhdGROhVxPHqIwJhl+iHvMOw0pEd8HhECQCZWQF ho4IaMLRqiDXC6tIsrmGKz45zY/OoxfynnwsJ2jFY3TxlzPhZWJ4hgj2bEKVH7ynT69T tp4XrQYEsma2BgVzqbj90NbaxBhEOsMvNQUfkZ4arjiiMd66kmIAyM/p4apARficfUaI T6MWYgOJyD9uG3nmfiZ76C77214aLORN7A+cyXw68GgBX0s1urhSl0ooCbN248CIpcfY 5vIl2Y00jNd42ORP/PuXcCl/rq42c3YoRGVpekc3tzSlt8Js/wXWn5YGdI6kw0FfYV+R vw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 337eym4960-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 01 Sep 2020 13:33:39 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 081D0eqO076616; Tue, 1 Sep 2020 13:33:39 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 3380x3bv2m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Sep 2020 13:33:39 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 081DXciR002439; Tue, 1 Sep 2020 13:33:38 GMT Received: from kadam (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 01 Sep 2020 06:33:38 -0700 Date: Tue, 1 Sep 2020 16:33:32 +0300 From: Dan Carpenter To: antoniprzybylik Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: gdm724x: gdm_tty: corrected macro by adding brackets Message-ID: <20200901133332.GY8299@kadam> References: <20200901104311.17270-1-antoni.przybylik@wp.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200901104311.17270-1-antoni.przybylik@wp.pl> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9730 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009010113 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9730 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009010113 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 01, 2020 at 12:43:11PM +0200, antoniprzybylik wrote: ^^^^^^^^^^^^^^^ Please, fix your From: header so that it says "Antoni Przybylik". > Such macros are dangerous. Consider following example: > #define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count) > GDM_TTY_READY(a + b) > This macro will be expanded in such a way: > (a + b && a + b->tty_dev && a + b->port.count) > And it will lead to errors. > > Signed-off-by: Antoni Przybylik > --- > drivers/staging/gdm724x/gdm_tty.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c > index 6e813693a766..eab5c75ee5b1 100644 > --- a/drivers/staging/gdm724x/gdm_tty.c > +++ b/drivers/staging/gdm724x/gdm_tty.c > @@ -27,7 +27,7 @@ > > #define MUX_TX_MAX_SIZE 2048 > > -#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count) > +#define GDM_TTY_READY(gdm) ((gdm) && (gdm)->tty_dev && (gdm)->port.count) I cannot imagine a real life example where adding these parentheses will prevent a bug. One idea it to silence this by making dereference ops like this a special case where checkpatch.pl doesn't suggest adding parentheses. regards, dan carpenter