All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Smith" <dpsmith@apertussolutions.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>,
	xen-devel@lists.xenproject.org
Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Subject: Re: [PATCH v4 04/11] xsm: apply coding style
Date: Tue, 7 Sep 2021 09:41:00 -0400	[thread overview]
Message-ID: <ef0d627e-cc1f-4b9a-7695-daa646968c42@apertussolutions.com> (raw)
In-Reply-To: <01c81885-9ea0-3ecf-66b0-009b9e7ba39b@citrix.com>

On 9/6/21 2:17 PM, Andrew Cooper wrote:
> On 03/09/2021 20:06, Daniel P. Smith wrote:
>> Instead of intermixing coding style changes with code changes as they
>> are come upon in this patch set, moving all coding style changes
>> into a single commit. The focus of coding style changes here are,
>>
>>   - move trailing comments to line above
>>   - ensuring line length does not exceed 80 chars
>>   - ensuring proper indentation for 80 char wrapping
>>   - covert u32 type statements to  uint32_t
>>   - remove space between closing and opening parens
>>   - drop extern on function declarations
>>
>> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
>> ---
>>   xen/include/xsm/dummy.h | 173 +++++++++-----
>>   xen/include/xsm/xsm.h   | 494 ++++++++++++++++++++++------------------
>>   xen/xsm/xsm_core.c      |   4 +-
>>   3 files changed, 389 insertions(+), 282 deletions(-)
>>
>> diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h
>> index 214b5408b1..deaf23035e 100644
>> --- a/xen/include/xsm/dummy.h
>> +++ b/xen/include/xsm/dummy.h
>> @@ -69,8 +69,9 @@ void __xsm_action_mismatch_detected(void);
>>   
>>   #endif /* CONFIG_XSM */
>>   
>> -static always_inline int xsm_default_action(
>> -    xsm_default_t action, struct domain *src, struct domain *target)
>> +static always_inline int xsm_default_action(xsm_default_t action,
>> +                                            struct domain *src,
>> +                                            struct domain *target)
> 
> The old code is correct.  We have plenty of examples of this in Xen, and
> I have been adding new ones when appropriate.
> 
> It avoids squashing everything on the RHS and ballooning the line count
> to compensate.  (This isn't a particularly bad example, but we've had
> worse cases in the past).

Based on the past discussions I understood either is acceptable and find 
this version much easier to visually parse myself. With that said, if
the "next line single indent" really is the preferred style by the 
maintainers/community, then I can convert all of these over.

>>   {
>>       switch ( action ) {
>>       case XSM_HOOK:
>> @@ -99,12 +100,13 @@ static always_inline int xsm_default_action(
>>   }
>>   
>>   static XSM_INLINE void xsm_security_domaininfo(struct domain *d,
>> -                                    struct xen_domctl_getdomaininfo *info)
>> +    struct xen_domctl_getdomaininfo *info)
> 
> This doesn't match any styles I'm aware of.  Either struct domain on the
> new line, or the two structs vertically aligned.
> 
> It more obviously highlights why squashing all parameters on the RHS is
> a bad move.

Apologies I let one slip through, though going through over 80-some 
function defs trying to make sure they are all aligned and missing one
I would say is not a bad job.

>> @@ -291,37 +307,41 @@ static XSM_INLINE void xsm_evtchn_close_post(struct evtchn *chn)
>>       return;
>>   }
>>   
>> -static XSM_INLINE int xsm_evtchn_send(XSM_DEFAULT_ARG struct domain *d, struct evtchn *chn)
>> +static XSM_INLINE int xsm_evtchn_send(XSM_DEFAULT_ARG struct domain *d,
>> +                                      struct evtchn *chn)
>>   {
>>       XSM_ASSERT_ACTION(XSM_HOOK);
>>       return xsm_default_action(action, d, NULL);
>>   }
>>   
>> -static XSM_INLINE int xsm_evtchn_status(XSM_DEFAULT_ARG struct domain *d, struct evtchn *chn)
>> +static XSM_INLINE int xsm_evtchn_status(XSM_DEFAULT_ARG struct domain *d,
>> +                                        struct evtchn *chn)
>>   {
>>       XSM_ASSERT_ACTION(XSM_TARGET);
>>       return xsm_default_action(action, current->domain, d);
>>   }
>>   
>> -static XSM_INLINE int xsm_evtchn_reset(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2)
>> +static XSM_INLINE int xsm_evtchn_reset(XSM_DEFAULT_ARG struct domain *d1,
>> +                                       struct domain *d2)
>>   {
>>       XSM_ASSERT_ACTION(XSM_TARGET);
>>       return xsm_default_action(action, d1, d2);
>>   }
>>   
>> -static XSM_INLINE int xsm_alloc_security_evtchns(
>> -    struct evtchn chn[], unsigned int nr)
>> +static XSM_INLINE int xsm_alloc_security_evtchns(struct evtchn chn[],
>> +                                                 unsigned int nr)
> 
> I maintain that this was correct before.

Getting to this point I must say it would be helpful if this could be 
spelled out in CODING_STYLE. Specifically, so that I am clear, if a 
parameter overflows, than all the parameters overflow? Are there 
exceptions such as if overflow doesn't happen until the third of four or 
the fourth parameter. Having a rule set would be much more helpful than 
trying to look for examples elsewhere in code.

>> diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
>> index 9872bae502..8878281eae 100644
>> --- a/xen/include/xsm/xsm.h
>> +++ b/xen/include/xsm/xsm.h
>> @@ -19,7 +19,7 @@
>>   #include <xen/multiboot.h>
>>   
>>   /* policy magic number (defined by XSM_MAGIC) */
>> -typedef u32 xsm_magic_t;
>> +typedef uint32_t xsm_magic_t;
>>   
>>   #ifdef CONFIG_XSM_FLASK
>>   #define XSM_MAGIC 0xf97cff8c
>> @@ -31,158 +31,171 @@ typedef u32 xsm_magic_t;
>>    * default actions of XSM hooks. They should be compiled out otherwise.
>>    */
>>   enum xsm_default {
>> -    XSM_HOOK,     /* Guests can normally access the hypercall */
>> -    XSM_DM_PRIV,  /* Device model can perform on its target domain */
>> -    XSM_TARGET,   /* Can perform on self or your target domain */
>> -    XSM_PRIV,     /* Privileged - normally restricted to dom0 */
>> -    XSM_XS_PRIV,  /* Xenstore domain - can do some privileged operations */
>> -    XSM_OTHER     /* Something more complex */
>> +    /* Guests can normally access the hypercall */
>> +    XSM_HOOK,
>> +    /* Device model can perform on its target domain */
>> +    XSM_DM_PRIV,
>> +    /* Can perform on self or your target domain */
>> +    XSM_TARGET,
>> +    /* Privileged - normally restricted to dom0 */
>> +    XSM_PRIV,
>> +    /* Xenstore domain - can do some privileged operations */
>> +    XSM_XS_PRIV,
>> +    /* Something more complex */
>> +    XSM_OTHER
>>   };
> 
> Why?  This takes a table which was unambiguous to read, and makes it
> ambiguous at a glance.  You want either no change at all, or blank lines
> between comment/constant pairs so you don't need to read to either end
> to figure out how to parse the comments.

I went back to the comment that prompted me to do this and rereading now 
makes me think I took it to literal. Specifically, "...I'd like to 
encourage you to also address other style issues in the newly introduced 
file. Here I'm talking about comment style, requiring /* to be on its 
own line." I took that to include these as well since I am pretty sure I 
have seen elsewhere this kind of commenting. Regardless, looking back I 
  can see how the meaning could have only for other block quotes. 
Honestly I will gladly change it back as I think that is far clearer.

v/r,
dps


  reply	other threads:[~2021-09-07 13:43 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-03 19:06 [PATCH v4 00/11] xsm: refactoring xsm hooks Daniel P. Smith
2021-09-03 19:06 ` [PATCH v4 01/11] xen: Implement xen/alternative-call.h for use in common code Daniel P. Smith
2021-09-06 15:52   ` Jan Beulich
2021-09-06 16:22     ` Andrew Cooper
2021-09-07  6:00       ` Jan Beulich
2021-09-07 13:07         ` Daniel P. Smith
2021-09-03 19:06 ` [PATCH v4 02/11] xsm: remove the ability to disable flask Daniel P. Smith
2021-09-06 17:56   ` Andrew Cooper
2021-09-03 19:06 ` [PATCH v4 03/11] xsm: drop dubious xsm_op_t type Daniel P. Smith
2021-09-06 18:00   ` Andrew Cooper
2021-09-03 19:06 ` [PATCH v4 04/11] xsm: apply coding style Daniel P. Smith
2021-09-06 18:17   ` Andrew Cooper
2021-09-07 13:41     ` Daniel P. Smith [this message]
2021-09-07 13:50       ` Jan Beulich
2021-09-07 14:09         ` Daniel P. Smith
2021-09-07 14:27           ` Jan Beulich
2021-09-07 14:55             ` Daniel P. Smith
2021-09-07 15:01               ` Jan Beulich
2021-09-03 19:06 ` [PATCH v4 05/11] xsm: refactor xsm_ops handling Daniel P. Smith
2021-09-06 18:31   ` Andrew Cooper
2021-09-07 13:44     ` Daniel P. Smith
2021-09-03 19:06 ` [PATCH v4 06/11] xsm: convert xsm_ops hook calls to alternative call Daniel P. Smith
2021-09-03 19:06 ` [PATCH v4 07/11] xsm: decouple xsm header inclusion selection Daniel P. Smith
2021-09-06 18:47   ` Andrew Cooper
2021-09-07 13:52     ` Daniel P. Smith
2021-09-03 19:06 ` [PATCH v4 08/11] xsm: drop generic event channel labeling exclusion Daniel P. Smith
2021-09-09 15:35   ` Jan Beulich
2021-09-09 16:44     ` Daniel P. Smith
2021-09-03 19:06 ` [PATCH v4 09/11] silo: remove circular xsm hook call Daniel P. Smith
2021-09-06 18:55   ` Andrew Cooper
2021-09-07 14:00     ` Daniel P. Smith
2021-09-09 15:45   ` Jan Beulich
2021-09-09 19:14     ` Daniel P. Smith
2021-09-03 19:06 ` [PATCH v4 10/11] kconfig: update xsm config to reflect reality Daniel P. Smith
2021-09-03 19:06 ` [PATCH v4 11/11] xsm: remove alternate xsm hook interface Daniel P. Smith
2021-09-06 19:18   ` Andrew Cooper
2021-09-07 14:03     ` Daniel P. Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ef0d627e-cc1f-4b9a-7695-daa646968c42@apertussolutions.com \
    --to=dpsmith@apertussolutions.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.