Skip to contentSkip to conversation

xen: Remove trigraphs from comments

PATCH Superseded Michal Orzel 3 participants 7 messages Dec 6, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: Remove trigraphs from comments

MISRA C rule 4.2 states that trigraphs (sequences of two question marks followed by a specified third character [=/'()!<>-]) should not be used. This applies to both code and comments. Thankfully, we do not use them in the code, but still there are some comments where they are accidentally used. Fix it.

---
 xen/arch/x86/x86_emulate/x86_emulate.h |  2 +-
 xen/include/public/arch-x86_64.h       |  2 +-
 xen/include/xen/pci_regs.h             | 12 ++++++------
 3 files changed, 8 insertions(+), 8 deletions(-)
xen/arch/x86/x86_emulate/x86_emulate.h +1 -1
index 4732855c40ed..bb7af967ffee 100644
@@ -228,7 +228,7 @@ struct x86_emulate_ops
      * All functions:
      *  @ctxt:  [IN ] Emulation context info as passed to the emulator.
      * All memory-access functions:
-     *  @seg:   [IN ] Segment being dereferenced (specified as x86_seg_??).
+     *  @seg:   [IN ] Segment being dereferenced (specified as x86_seg_?).
      *  @offset:[IN ] Offset within segment.
      *  @p_data:[IN ] Pointer to i/o data buffer (length is @bytes)
      * Read functions:
xen/include/public/arch-x86_64.h +1 -1
index 5db52de69584..1c3567a20217 100644
@@ -22,5 +22,5 @@
  * A similar callback occurs if the segment selectors are invalid.
  * failsafe_address is used as the value of eip.
  *
- * On x86_64, event_selector and failsafe_selector are ignored (???).
+ * On x86_64, event_selector and failsafe_selector are ignored (?).
  */
xen/include/xen/pci_regs.h +6 -6
index ee8e82be36b4..a90aff1712ba 100644
@@ -246,13 +246,13 @@
 #define  PCI_PM_CTRL_STATE_MASK	0x0003	/* Current power state (D0 to D3) */
 #define  PCI_PM_CTRL_NO_SOFT_RESET	0x0008	/* No reset for D3hot->D0 */
 #define  PCI_PM_CTRL_PME_ENABLE	0x0100	/* PME pin enable */
-#define  PCI_PM_CTRL_DATA_SEL_MASK	0x1e00	/* Data select (??) */
-#define  PCI_PM_CTRL_DATA_SCALE_MASK	0x6000	/* Data scale (??) */
+#define  PCI_PM_CTRL_DATA_SEL_MASK	0x1e00	/* Data select (?) */
+#define  PCI_PM_CTRL_DATA_SCALE_MASK	0x6000	/* Data scale (?) */
 #define  PCI_PM_CTRL_PME_STATUS	0x8000	/* PME pin status */
-#define PCI_PM_PPB_EXTENSIONS	6	/* PPB support extensions (??) */
-#define  PCI_PM_PPB_B2_B3	0x40	/* Stop clock when in D3hot (??) */
-#define  PCI_PM_BPCC_ENABLE	0x80	/* Bus power/clock control enable (??) */
-#define PCI_PM_DATA_REGISTER	7	/* (??) */
+#define PCI_PM_PPB_EXTENSIONS	6	/* PPB support extensions (?) */
+#define  PCI_PM_PPB_B2_B3	0x40	/* Stop clock when in D3hot (?) */
+#define  PCI_PM_BPCC_ENABLE	0x80	/* Bus power/clock control enable (?) */
+#define PCI_PM_DATA_REGISTER	7	/* (?) */
 #define PCI_PM_SIZEOF		8
 
 /* AGP registers */
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Michal Orzel

MISRA C rule 4.2 states that trigraphs (sequences of two question marks followed by a specified third character [=/'()!<>-]) should not be used. This applies to both code and comments. Thankfully, we do not use them in the code, but still there are some comments where they are accidentally used. Fix it.

Quoted 58 lines

---

xen/arch/x86/x86_emulate/x86_emulate.h |  2 +-
xen/include/public/arch-x86_64.h       |  2 +-
xen/include/xen/pci_regs.h             | 12 ++++++------
3 files changed, 8 insertions(+), 8 deletions(-)
xen/arch/x86/x86_emulate/x86_emulate.h +1 -1
index 4732855c40ed..bb7af967ffee 100644
@@ -228,7 +228,7 @@ struct x86_emulate_ops
     * All functions:
     *  @ctxt:  [IN ] Emulation context info as passed to the emulator.
     * All memory-access functions:
-     *  @seg:   [IN ] Segment being dereferenced (specified as x86_seg_??).
+     *  @seg:   [IN ] Segment being dereferenced (specified as x86_seg_?).
     *  @offset:[IN ] Offset within segment.
     *  @p_data:[IN ] Pointer to i/o data buffer (length is @bytes)
     * Read functions:
xen/include/public/arch-x86_64.h +1 -1
index 5db52de69584..1c3567a20217 100644
@@ -22,5 +22,5 @@
 * A similar callback occurs if the segment selectors are invalid.
 * failsafe_address is used as the value of eip.
 *
- * On x86_64, event_selector and failsafe_selector are ignored (???).
+ * On x86_64, event_selector and failsafe_selector are ignored (?).
 */
xen/include/xen/pci_regs.h +6 -6
index ee8e82be36b4..a90aff1712ba 100644
@@ -246,13 +246,13 @@
 #define  PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */
 #define  PCI_PM_CTRL_NO_SOFT_RESET 0x0008 /* No reset for D3hot->D0 */
 #define  PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */
-#define  PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */
-#define  PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */
+#define  PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (?) */
+#define  PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (?) */
 #define  PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */
-#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */
-#define  PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */
-#define  PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */
-#define PCI_PM_DATA_REGISTER 7 /* (??) */
+#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (?) */
+#define  PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (?) */
+#define  PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (?) */
+#define PCI_PM_DATA_REGISTER 7 /* (?) */
 #define PCI_PM_SIZEOF 8
 
 /* AGP registers */
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Michal Orzel

xen/include/public/arch-x86_64.h line 25

Quoted 8 lines · Michal Orzel
xen/include/public/arch-x86_64.h +1 -1
@@ -22,5 +22,5 @@
  * A similar callback occurs if the segment selectors are invalid.
  * failsafe_address is used as the value of eip.
  *
- * On x86_64, event_selector and failsafe_selector are ignored (???).
+ * On x86_64, event_selector and failsafe_selector are ignored (?).

May I ask that this become (?!?) instead?

Quoted 10 lines
xen/include/xen/pci_regs.h +2 -2
@@ -246,13 +246,13 @@
 #define  PCI_PM_CTRL_STATE_MASK	0x0003	/* Current power state (D0 to D3) */
 #define  PCI_PM_CTRL_NO_SOFT_RESET	0x0008	/* No reset for D3hot->D0 */
 #define  PCI_PM_CTRL_PME_ENABLE	0x0100	/* PME pin enable */
-#define  PCI_PM_CTRL_DATA_SEL_MASK	0x1e00	/* Data select (??) */
-#define  PCI_PM_CTRL_DATA_SCALE_MASK	0x6000	/* Data scale (??) */
+#define  PCI_PM_CTRL_DATA_SEL_MASK	0x1e00	/* Data select (?) */
+#define  PCI_PM_CTRL_DATA_SCALE_MASK	0x6000	/* Data scale (?) */

xen/include/xen/pci_regs.h line 256

Quoted 10 lines
xen/include/xen/pci_regs.h +4 -4
 #define  PCI_PM_CTRL_PME_STATUS	0x8000	/* PME pin status */
-#define PCI_PM_PPB_EXTENSIONS	6	/* PPB support extensions (??) */
-#define  PCI_PM_PPB_B2_B3	0x40	/* Stop clock when in D3hot (??) */
-#define  PCI_PM_BPCC_ENABLE	0x80	/* Bus power/clock control enable (??) */
-#define PCI_PM_DATA_REGISTER	7	/* (??) */
+#define PCI_PM_PPB_EXTENSIONS	6	/* PPB support extensions (?) */
+#define  PCI_PM_PPB_B2_B3	0x40	/* Stop clock when in D3hot (?) */
+#define  PCI_PM_BPCC_ENABLE	0x80	/* Bus power/clock control enable (?) */
+#define PCI_PM_DATA_REGISTER	7	/* (?) */
 #define PCI_PM_SIZEOF		8

We've inherited all of these from Linux, and I notice Linux still has it this same way. Ideally Linux would change first, but I'd be okay with a sentence added to the description clarifying that we knowingly accept the divergence.

With the adjustments:

Jan

#3 lore raw

Hi Jan,

Quoted 13 lines · Jan Beulich

xen/include/public/arch-x86_64.h line 25

Quoted 8 lines · Michal Orzel
xen/include/public/arch-x86_64.h +1 -1
@@ -22,5 +22,5 @@
  * A similar callback occurs if the segment selectors are invalid.
  * failsafe_address is used as the value of eip.
  *
- * On x86_64, event_selector and failsafe_selector are ignored (???).
+ * On x86_64, event_selector and failsafe_selector are ignored (?).

May I ask that this become (?!?) instead?

Sure.

Quoted 18 lines
Quoted 18 lines
xen/include/xen/pci_regs.h +4 -6
@@ -246,13 +246,13 @@
 #define  PCI_PM_CTRL_STATE_MASK      0x0003  /* Current power state (D0 to D3) */
 #define  PCI_PM_CTRL_NO_SOFT_RESET   0x0008  /* No reset for D3hot->D0 */
 #define  PCI_PM_CTRL_PME_ENABLE      0x0100  /* PME pin enable */
-#define  PCI_PM_CTRL_DATA_SEL_MASK   0x1e00  /* Data select (??) */
-#define  PCI_PM_CTRL_DATA_SCALE_MASK 0x6000  /* Data scale (??) */
+#define  PCI_PM_CTRL_DATA_SEL_MASK   0x1e00  /* Data select (?) */
+#define  PCI_PM_CTRL_DATA_SCALE_MASK 0x6000  /* Data scale (?) */
 #define  PCI_PM_CTRL_PME_STATUS      0x8000  /* PME pin status */
-#define PCI_PM_PPB_EXTENSIONS        6       /* PPB support extensions (??) */
-#define  PCI_PM_PPB_B2_B3    0x40    /* Stop clock when in D3hot (??) */
-#define  PCI_PM_BPCC_ENABLE  0x80    /* Bus power/clock control enable (??) */
-#define PCI_PM_DATA_REGISTER 7       /* (??) */
+#define PCI_PM_PPB_EXTENSIONS        6       /* PPB support extensions (?) */
+#define  PCI_PM_PPB_B2_B3    0x40    /* Stop clock when in D3hot (?) */
Quoted 8 lines

xen/include/xen/pci_regs.h line 256

Quoted 3 lines
xen/include/xen/pci_regs.h +2 -0
+#define  PCI_PM_BPCC_ENABLE  0x80    /* Bus power/clock control enable (?) */
+#define PCI_PM_DATA_REGISTER 7       /* (?) */
 #define PCI_PM_SIZEOF                8

We've inherited all of these from Linux, and I notice Linux still has it this same way. Ideally Linux would change first, but I'd be okay with a sentence added to the description clarifying that we knowingly accept the divergence.

This file already diverged and we are not in sync with Linux as well.
Also there is no functional change being made by this patch so it is ok
to change Xen and not Linux in this case (which has quite a lot of trigraphs all over the place).

Quoted 5 lines

With the adjustments:

Jan

~Michal

#4 lore raw
Quoted 27 lines · Michal Orzel
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Michal Orzel
xen/include/xen/pci_regs.h +4 -6
@@ -246,13 +246,13 @@
 #define  PCI_PM_CTRL_STATE_MASK      0x0003  /* Current power state (D0 to D3) */
 #define  PCI_PM_CTRL_NO_SOFT_RESET   0x0008  /* No reset for D3hot->D0 */
 #define  PCI_PM_CTRL_PME_ENABLE      0x0100  /* PME pin enable */
-#define  PCI_PM_CTRL_DATA_SEL_MASK   0x1e00  /* Data select (??) */
-#define  PCI_PM_CTRL_DATA_SCALE_MASK 0x6000  /* Data scale (??) */
+#define  PCI_PM_CTRL_DATA_SEL_MASK   0x1e00  /* Data select (?) */
+#define  PCI_PM_CTRL_DATA_SCALE_MASK 0x6000  /* Data scale (?) */
 #define  PCI_PM_CTRL_PME_STATUS      0x8000  /* PME pin status */
-#define PCI_PM_PPB_EXTENSIONS        6       /* PPB support extensions (??) */
-#define  PCI_PM_PPB_B2_B3    0x40    /* Stop clock when in D3hot (??) */
-#define  PCI_PM_BPCC_ENABLE  0x80    /* Bus power/clock control enable (??) */
-#define PCI_PM_DATA_REGISTER 7       /* (??) */
+#define PCI_PM_PPB_EXTENSIONS        6       /* PPB support extensions (?) */
+#define  PCI_PM_PPB_B2_B3    0x40    /* Stop clock when in D3hot (?) */
Quoted 8 lines

xen/include/xen/pci_regs.h line 256

Quoted 3 lines
xen/include/xen/pci_regs.h +2 -0
+#define  PCI_PM_BPCC_ENABLE  0x80    /* Bus power/clock control enable (?) */
+#define PCI_PM_DATA_REGISTER 7       /* (?) */
 #define PCI_PM_SIZEOF                8

We've inherited all of these from Linux, and I notice Linux still has it this same way. Ideally Linux would change first, but I'd be okay with a sentence added to the description clarifying that we knowingly accept the divergence.

Quoted 1 line

This file already diverged and we are not in sync with Linux as well.

Of course - that's the case for the majority of files we've taken from somewhere. But a Linux patch dropping the (??) parts of the comment (perhaps once whoever had put them there convinced themselves that the names of the constants and/or the comments are valid / applicable) would then no longer apply cleanly if we wanted to carry it over. Hence my request for amending the description.

Quoted 2 lines

Also there is no functional change being made by this patch so it is ok
to change Xen and not Linux in this case (which has quite a lot of trigraphs all over the place).

Based on what criteria are you saying this is ok (unconditionally)?

Jan

#5 lore raw
Quoted 30 lines · Jan Beulich
Quoted 27 lines · Michal Orzel
Quoted 26 lines · Jan Beulich
Quoted 10 lines · Michal Orzel
xen/include/xen/pci_regs.h +2 -2
@@ -246,13 +246,13 @@
 #define  PCI_PM_CTRL_STATE_MASK      0x0003  /* Current power state (D0 to D3) */
 #define  PCI_PM_CTRL_NO_SOFT_RESET   0x0008  /* No reset for D3hot->D0 */
 #define  PCI_PM_CTRL_PME_ENABLE      0x0100  /* PME pin enable */
-#define  PCI_PM_CTRL_DATA_SEL_MASK   0x1e00  /* Data select (??) */
-#define  PCI_PM_CTRL_DATA_SCALE_MASK 0x6000  /* Data scale (??) */
+#define  PCI_PM_CTRL_DATA_SEL_MASK   0x1e00  /* Data select (?) */
+#define  PCI_PM_CTRL_DATA_SCALE_MASK 0x6000  /* Data scale (?) */

xen/include/xen/pci_regs.h line 256

Quoted 10 lines
xen/include/xen/pci_regs.h +4 -4
 #define  PCI_PM_CTRL_PME_STATUS      0x8000  /* PME pin status */
-#define PCI_PM_PPB_EXTENSIONS        6       /* PPB support extensions (??) */
-#define  PCI_PM_PPB_B2_B3    0x40    /* Stop clock when in D3hot (??) */
-#define  PCI_PM_BPCC_ENABLE  0x80    /* Bus power/clock control enable (??) */
-#define PCI_PM_DATA_REGISTER 7       /* (??) */
+#define PCI_PM_PPB_EXTENSIONS        6       /* PPB support extensions (?) */
+#define  PCI_PM_PPB_B2_B3    0x40    /* Stop clock when in D3hot (?) */
+#define  PCI_PM_BPCC_ENABLE  0x80    /* Bus power/clock control enable (?) */
+#define PCI_PM_DATA_REGISTER 7       /* (?) */
 #define PCI_PM_SIZEOF                8

We've inherited all of these from Linux, and I notice Linux still has it this same way. Ideally Linux would change first, but I'd be okay with a sentence added to the description clarifying that we knowingly accept the divergence.

Quoted 8 lines
Quoted 1 line

This file already diverged and we are not in sync with Linux as well.

Of course - that's the case for the majority of files we've taken from somewhere. But a Linux patch dropping the (??) parts of the comment (perhaps once whoever had put them there convinced themselves that the names of the constants and/or the comments are valid / applicable) would then no longer apply cleanly if we wanted to carry it over. Hence my request for amending the description.

I'm totally fine to add an extra sentence.

Quoted 5 lines
Quoted 3 lines

Also there is no functional change being made by this patch so it is ok
to change Xen and not Linux in this case (which has quite a lot of trigraphs all over the place).

Based on what criteria are you saying this is ok (unconditionally)?

I said that it is ok to change Xen and not Linux because this file already diverged, so we cannot assume that future backports will apply cleanly. If we change a file that did not diverge, then we are required to modify the origin first and then do the backport.

Quoted 2 lines

Jan

~Michal

#6 lore raw
Quoted 11 lines · Michal Orzel
Quoted 5 lines · Jan Beulich
Quoted 2 lines · Michal Orzel

Also there is no functional change being made by this patch so it is ok
to change Xen and not Linux in this case (which has quite a lot of trigraphs all over the place).

Based on what criteria are you saying this is ok (unconditionally)?

I said that it is ok to change Xen and not Linux because this file already diverged, so we cannot assume that future backports will apply cleanly. If we change a file that did not diverge, then we are required to modify the origin first and then do the backport.

A file might have diverged, yet commits to be pulled in from the original tree may still apply cleanly. That why, in the general case, we aim at limiting the amount of divergence, and we prefer to pull in changes bringing us back closer to the (meanwhile evolved) original file.

Jan