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] [thread-next>] [day] [month] [year] [list]
Message-ID: <7a2ef915bd08a1c0277b9633e20905c0ca62c568.camel@perches.com>
Date:   Fri, 02 Jul 2021 09:56:51 -0700
From:   Joe Perches <joe@...ches.com>
To:     Mark Rutland <mark.rutland@....com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Zhu Lingshan <lingshan.zhu@...el.com>, wanpengli@...cent.com,
        Like Xu <like.xu@...ux.intel.com>, eranian@...gle.com,
        weijiang.yang@...el.com, Guo Ren <guoren@...nel.org>,
        linux-riscv@...ts.infradead.org, Will Deacon <will@...nel.org>,
        kvmarm@...ts.cs.columbia.edu, kan.liang@...ux.intel.com,
        ak@...ux.intel.com, kvm@...r.kernel.org,
        Marc Zyngier <maz@...nel.org>, joro@...tes.org, x86@...nel.org,
        linux-csky@...r.kernel.org, wei.w.wang@...el.com,
        xen-devel@...ts.xenproject.org, liuxiangdong5@...wei.com,
        bp@...en8.de, Paul Walmsley <paul.walmsley@...ive.com>,
        Boris Ostrovsky <boris.ostrovsky@...cle.com>,
        linux-arm-kernel@...ts.infradead.org, jmattson@...gle.com,
        like.xu.linux@...il.com, Nick Hu <nickhu@...estech.com>,
        seanjc@...gle.com, linux-kernel@...r.kernel.org,
        pbonzini@...hat.com, vkuznets@...hat.com
Subject: Re: [PATCH V7 01/18] perf/core: Use static_call to optimize
 perf_guest_info_callbacks

On Fri, 2021-07-02 at 17:38 +0100, Mark Rutland wrote:
> On Fri, Jul 02, 2021 at 09:00:22AM -0700, Joe Perches wrote:
> > On Fri, 2021-07-02 at 13:22 +0200, Peter Zijlstra wrote:
> > > On Tue, Jun 22, 2021 at 05:42:49PM +0800, Zhu Lingshan wrote:
[]
> > > > +	if (perf_guest_cbs && perf_guest_cbs->handle_intel_pt_intr)
> > > > +		static_call_update(x86_guest_handle_intel_pt_intr,
> > > > +				   perf_guest_cbs->handle_intel_pt_intr);
> > > > +}
> > > 
> > > Coding style wants { } on that last if().
> > 
> > That's just your personal preference.
> > 
> > The coding-style document doesn't require that.
> > 
> > It just says single statement.  It's not the number of
> > vertical lines or characters required for the statement.
> > 
> > ----------------------------------
> > 
> > Do not unnecessarily use braces where a single statement will do.
> > 
> > .. code-block:: c
> > 
> > 	if (condition)
> > 		action();
> > 
> > and
> > 
> > .. code-block:: none
> > 
> > 	if (condition)
> > 		do_this();
> > 	else
> > 		do_that();
> > 
> > This does not apply if only one branch of a conditional statement is a single
> > statement; in the latter case use braces in both branches:
> 
> Immediately after this, we say:
> 
> > Also, use braces when a loop contains more than a single simple statement:
> > 
> > .. code-block:: c
> > 
> >         while (condition) {
> >                 if (test)
> >                         do_something();
> >         }
> > 
> 
> ... and while that says "a loop", the principle is obviously supposed to
> apply to conditionals too; structurally they're no different. We should
> just fix the documentation to say "a loop or conditional", or something
> to that effect.

<shrug>  Maybe.

I think there are _way_ too many existing obvious uses where the
statement that follows a conditional is multi-line.

	if (foo)
		printk(fmt,
		       args...);

where the braces wouldn't add anything other than more vertical space.

I don't much care one way or another other than Peter's somewhat ambiguous
use of the phrase "coding style".

checkpatch doesn't emit a message either way.
-----------------------------------------
$ cat t_multiline.c
// SPDX-License-Identifier: GPL-2.0-only

void foo(void)
{
	if (foo) {
		pr_info(fmt,
			args);
	}

	if (foo)
		pr_info(fmt,
			args);

	if (foo)
		pr_info(fmt, args);
}

$ ./scripts/checkpatch.pl -f --strict t_multiline.c
total: 0 errors, 0 warnings, 0 checks, 16 lines checked

t_multiline.c has no obvious style problems and is ready for submission.
-----------------------------------------

cheers, Joe


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ