Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9FE1AC433EF for ; Sat, 19 Mar 2022 07:40:33 +0000 (UTC) Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94.2) (envelope-from ) id 1nVThQ-0004x2-FG for kernelnewbies@archiver.kernel.org; Sat, 19 Mar 2022 03:40:32 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nVTfh-0002ut-MW for kernelnewbies@kernelnewbies.org; Sat, 19 Mar 2022 03:38:45 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 755ED5C011C; Sat, 19 Mar 2022 03:38:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sat, 19 Mar 2022 03:38:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; bh=7MRTYkVvFvz5FnWPoXHDWozYf9twohjeqSzpAU wR0VU=; b=Wj+8s3Gp/d0IQzj6U6I2CM851d8w7DkMPq4lZdzP5OzXw4+KUlZ1WS NowGScYyPsm2OqwfAXGB4HeUMK72LQ8fJ0OzsxFxqRbZCoO+LcXoJypI+4QCmT8d hbFXPgvccqCm8bds6NNtPRmY55/ZAUAqIwNmMWFQ81D9gfa9Hk/Y0iXBLC2UbU3C kto2ZtnLM/3c4d5b04pE5iGndQp1TKGQ3QlwL+CbSyADgiGJIv/81F1UG8ibGuH1 9+KDu1Qh0lLYSXgiQijxn0JDrMWsbelxs11nzBpoZMmGYIISyzovF0L2n6B81nUa yqir13KQoBEqeJzYJOWgO9gUwt3a/jAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=7MRTYkVvFvz5FnWPo XHDWozYf9twohjeqSzpAUwR0VU=; b=jjPFA3jNuPPI65+GyonjC3WpvgDdnY84V 5FINgEpsiaAwb1donQjKEZcpQ+aBEDeYUrtNC8Z/IAekk5OhEfu1A+CMpf6ewdUZ mGUtvuCzAnAxAC9wBlUBBkkSJUOt5xurzd4HSFNNAKUEX5VfZNsc+PR1NDVx+Itf pTxuz+MoT2GpVqlKhm6o4K+BffLTHvBNf+CswmEudHCcx7n7KrVLfKcjvc0cyU34 yQOF89O7aYFcSoLwe91Re1yG8ZyAt5x7K2yauWITLqaC18N7e6EPFNkRr79hkNL+ HjHS5GKsmNZ13cQGbDjubdtq7JlUj0JaawA/p+UvXvOVexl62MYzg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudefjedguddtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepifhrvghg ucfmjfcuoehgrhgvgheskhhrohgrhhdrtghomheqnecuggftrfgrthhtvghrnhepveeuhe ejgfffgfeivddukedvkedtleelleeghfeljeeiueeggeevueduudekvdetnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepghhrvghgsehkrhhorg hhrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 19 Mar 2022 03:38:42 -0400 (EDT) Date: Sat, 19 Mar 2022 08:38:40 +0100 From: Greg KH To: Philipp Hortmann Subject: Re: What to do with macros with do while (0) body Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces+kernelnewbies=archiver.kernel.org@kernelnewbies.org On Sat, Mar 19, 2022 at 08:25:34AM +0100, Philipp Hortmann wrote: > Hi all, > > please support me in what to do with the below macro as checkpatch seems to > hate them. > > In this case the macro is unused. Just remove macro? Yes. > When the macro is used how to remove this checkpatch message: > CHECK: Macro argument reuse 'iobase' - possible side-effects? > Even when iobase is just used in this macro this message does not go away. > > I do prefer to make a function out of such macros but what is kernel > standard? Making it a function please. > CHECK: Avoid CamelCase: > #864: FILE: drivers/staging/vt6655/mac.h:864: > +#define MACvWriteCRC16_128(iobase, byRegOfs, wCRC) \ > > CHECK: Avoid CamelCase: > #864: FILE: drivers/staging/vt6655/mac.h:864: > +#define MACvWriteCRC16_128(iobase, byRegOfs, wCRC) \ > > CHECK: Macro argument reuse 'iobase' - possible side-effects? > #864: FILE: drivers/staging/vt6655/mac.h:864: > +#define MACvWriteCRC16_128(iobase, byRegOfs, wCRC) \ > +do { \ > + VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 1); \ > + VNSvOutPortW(iobase + byRegOfs, wCRC); \ > + VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 0); \ > +} while (0) checkpatch is right here, this is a horrid macro and can cause problems if used incorrectly. Make this a function. thanks, greg k-h _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies