diff mbox

monitor: switch to plain bool

Message ID 20170908134433.731-1-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu Sept. 8, 2017, 1:44 p.m. UTC
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Razvan Cojocaru <rcojocaru@bitdefender.com>
Cc: Tamas K Lengyel <tamas@tklengyel.com>
---
 xen/arch/arm/monitor.c            |  4 ++--
 xen/arch/x86/hvm/monitor.c        | 10 +++++-----
 xen/common/monitor.c              |  8 ++++----
 xen/include/asm-x86/hvm/monitor.h |  6 +++---
 xen/include/xen/monitor.h         |  2 +-
 5 files changed, 15 insertions(+), 15 deletions(-)

Comments

Andrew Cooper Sept. 8, 2017, 2:11 p.m. UTC | #1
On 08/09/17 14:44, Wei Liu wrote:
> diff --git a/xen/arch/x86/hvm/monitor.c b/xen/arch/x86/hvm/monitor.c
> index a7ccfc4b42..b534dd3043 100644
> --- a/xen/arch/x86/hvm/monitor.c
> +++ b/xen/arch/x86/hvm/monitor.c
> @@ -30,7 +30,7 @@
>  #include <asm/vm_event.h>
>  #include <public/vm_event.h>
>  
> -bool_t hvm_monitor_cr(unsigned int index, unsigned long value, unsigned long old)
> +bool hvm_monitor_cr(unsigned int index, unsigned long value, unsigned long old)
>  {
>      struct vcpu *curr = current;
>      struct arch_domain *ad = &curr->domain->arch;
> @@ -41,7 +41,7 @@ bool_t hvm_monitor_cr(unsigned int index, unsigned long value, unsigned long old
>            value != old) &&
>           (!((value ^ old) & ad->monitor.write_ctrlreg_mask[index])) )
>      {
> -        bool_t sync = !!(ad->monitor.write_ctrlreg_sync & ctrlreg_bitmask);
> +        bool sync = !!(ad->monitor.write_ctrlreg_sync & ctrlreg_bitmask);

You can drop the !! and brackets.

Otherwise, Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Razvan Cojocaru Sept. 8, 2017, 2:13 p.m. UTC | #2
On 08.09.2017 16:44, Wei Liu wrote:
> Signed-off-by: Wei Liu<wei.liu2@citrix.com>
> ---
> Cc: Razvan Cojocaru<rcojocaru@bitdefender.com>
> Cc: Tamas K Lengyel<tamas@tklengyel.com>
> ---
>   xen/arch/arm/monitor.c            |  4 ++--
>   xen/arch/x86/hvm/monitor.c        | 10 +++++-----
>   xen/common/monitor.c              |  8 ++++----
>   xen/include/asm-x86/hvm/monitor.h |  6 +++---
>   xen/include/xen/monitor.h         |  2 +-
>   5 files changed, 15 insertions(+), 15 deletions(-)

Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>


Thanks,
Razvan
Jan Beulich Sept. 8, 2017, 2:14 p.m. UTC | #3
>>> On 08.09.17 at 15:44, <wei.liu2@citrix.com> wrote:
> @@ -41,7 +41,7 @@ bool_t hvm_monitor_cr(unsigned int index, unsigned long value, unsigned long old
>            value != old) &&
>           (!((value ^ old) & ad->monitor.write_ctrlreg_mask[index])) )
>      {
> -        bool_t sync = !!(ad->monitor.write_ctrlreg_sync & ctrlreg_bitmask);
> +        bool sync = !!(ad->monitor.write_ctrlreg_sync & ctrlreg_bitmask);

If you do such conversion, please also get rid of any unnecessary
!! like is being used here (there are very few cases where these
can't be dropped).

Jan
Wei Liu Sept. 8, 2017, 2:18 p.m. UTC | #4
On Fri, Sep 08, 2017 at 08:14:59AM -0600, Jan Beulich wrote:
> >>> On 08.09.17 at 15:44, <wei.liu2@citrix.com> wrote:
> > @@ -41,7 +41,7 @@ bool_t hvm_monitor_cr(unsigned int index, unsigned long value, unsigned long old
> >            value != old) &&
> >           (!((value ^ old) & ad->monitor.write_ctrlreg_mask[index])) )
> >      {
> > -        bool_t sync = !!(ad->monitor.write_ctrlreg_sync & ctrlreg_bitmask);
> > +        bool sync = !!(ad->monitor.write_ctrlreg_sync & ctrlreg_bitmask);
> 
> If you do such conversion, please also get rid of any unnecessary
> !! like is being used here (there are very few cases where these
> can't be dropped).
> 

Sure. I will keep an eye out in the future.
diff mbox

Patch

diff --git a/xen/arch/arm/monitor.c b/xen/arch/arm/monitor.c
index 59ce8f635f..8c4a396e3c 100644
--- a/xen/arch/arm/monitor.c
+++ b/xen/arch/arm/monitor.c
@@ -28,13 +28,13 @@  int arch_monitor_domctl_event(struct domain *d,
                               struct xen_domctl_monitor_op *mop)
 {
     struct arch_domain *ad = &d->arch;
-    bool_t requested_status = (XEN_DOMCTL_MONITOR_OP_ENABLE == mop->op);
+    bool requested_status = (XEN_DOMCTL_MONITOR_OP_ENABLE == mop->op);
 
     switch ( mop->event )
     {
     case XEN_DOMCTL_MONITOR_EVENT_PRIVILEGED_CALL:
     {
-        bool_t old_status = ad->monitor.privileged_call_enabled;
+        bool old_status = ad->monitor.privileged_call_enabled;
 
         if ( unlikely(old_status == requested_status) )
             return -EEXIST;
diff --git a/xen/arch/x86/hvm/monitor.c b/xen/arch/x86/hvm/monitor.c
index a7ccfc4b42..b534dd3043 100644
--- a/xen/arch/x86/hvm/monitor.c
+++ b/xen/arch/x86/hvm/monitor.c
@@ -30,7 +30,7 @@ 
 #include <asm/vm_event.h>
 #include <public/vm_event.h>
 
-bool_t hvm_monitor_cr(unsigned int index, unsigned long value, unsigned long old)
+bool hvm_monitor_cr(unsigned int index, unsigned long value, unsigned long old)
 {
     struct vcpu *curr = current;
     struct arch_domain *ad = &curr->domain->arch;
@@ -41,7 +41,7 @@  bool_t hvm_monitor_cr(unsigned int index, unsigned long value, unsigned long old
           value != old) &&
          (!((value ^ old) & ad->monitor.write_ctrlreg_mask[index])) )
     {
-        bool_t sync = !!(ad->monitor.write_ctrlreg_sync & ctrlreg_bitmask);
+        bool sync = !!(ad->monitor.write_ctrlreg_sync & ctrlreg_bitmask);
 
         vm_event_request_t req = {
             .reason = VM_EVENT_REASON_WRITE_CTRLREG,
@@ -116,7 +116,7 @@  int hvm_monitor_debug(unsigned long rip, enum hvm_monitor_debug_type type,
     struct vcpu *curr = current;
     struct arch_domain *ad = &curr->domain->arch;
     vm_event_request_t req = {};
-    bool_t sync;
+    bool sync;
 
     switch ( type )
     {
@@ -127,7 +127,7 @@  int hvm_monitor_debug(unsigned long rip, enum hvm_monitor_debug_type type,
         req.u.software_breakpoint.gfn = gfn_of_rip(rip);
         req.u.software_breakpoint.type = trap_type;
         req.u.software_breakpoint.insn_length = insn_length;
-        sync = 1;
+        sync = true;
         break;
 
     case HVM_MONITOR_SINGLESTEP_BREAKPOINT:
@@ -135,7 +135,7 @@  int hvm_monitor_debug(unsigned long rip, enum hvm_monitor_debug_type type,
             return 0;
         req.reason = VM_EVENT_REASON_SINGLESTEP;
         req.u.singlestep.gfn = gfn_of_rip(rip);
-        sync = 1;
+        sync = true;
         break;
 
     case HVM_MONITOR_DEBUG_EXCEPTION:
diff --git a/xen/common/monitor.c b/xen/common/monitor.c
index 32d062ca98..c6066830e3 100644
--- a/xen/common/monitor.c
+++ b/xen/common/monitor.c
@@ -31,7 +31,7 @@ 
 int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop)
 {
     int rc;
-    bool_t requested_status = 0;
+    bool requested_status = false;
 
     if ( unlikely(current->domain == d) ) /* no domain_pause() */
         return -EPERM;
@@ -43,7 +43,7 @@  int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop)
     switch ( mop->op )
     {
     case XEN_DOMCTL_MONITOR_OP_ENABLE:
-        requested_status = 1;
+        requested_status = true;
         /* fallthrough */
     case XEN_DOMCTL_MONITOR_OP_DISABLE:
         /* sanity check: avoid left-shift undefined behavior */
@@ -67,7 +67,7 @@  int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop)
     {
     case XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST:
     {
-        bool_t old_status = d->monitor.guest_request_enabled;
+        bool old_status = d->monitor.guest_request_enabled;
 
         if ( unlikely(old_status == requested_status) )
             return -EEXIST;
@@ -88,7 +88,7 @@  int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop)
     return 0;
 }
 
-int monitor_traps(struct vcpu *v, bool_t sync, vm_event_request_t *req)
+int monitor_traps(struct vcpu *v, bool sync, vm_event_request_t *req)
 {
     int rc;
     struct domain *d = v->domain;
diff --git a/xen/include/asm-x86/hvm/monitor.h b/xen/include/asm-x86/hvm/monitor.h
index d9efb3505e..cfd6661016 100644
--- a/xen/include/asm-x86/hvm/monitor.h
+++ b/xen/include/asm-x86/hvm/monitor.h
@@ -31,10 +31,10 @@  enum hvm_monitor_debug_type
 /*
  * Called for current VCPU on crX/MSR changes by guest.
  * The event might not fire if the client has subscribed to it in onchangeonly
- * mode, hence the bool_t return type for control register write events.
+ * mode, hence the bool return type for control register write events.
  */
-bool_t hvm_monitor_cr(unsigned int index, unsigned long value,
-                      unsigned long old);
+bool hvm_monitor_cr(unsigned int index, unsigned long value,
+                    unsigned long old);
 #define hvm_monitor_crX(cr, new, old) \
                         hvm_monitor_cr(VM_EVENT_X86_##cr, new, old)
 void hvm_monitor_msr(unsigned int msr, uint64_t value);
diff --git a/xen/include/xen/monitor.h b/xen/include/xen/monitor.h
index 2171d04490..6b17a93071 100644
--- a/xen/include/xen/monitor.h
+++ b/xen/include/xen/monitor.h
@@ -30,6 +30,6 @@  struct xen_domctl_monitor_op;
 int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *op);
 void monitor_guest_request(void);
 
-int monitor_traps(struct vcpu *v, bool_t sync, vm_event_request_t *req);
+int monitor_traps(struct vcpu *v, bool sync, vm_event_request_t *req);
 
 #endif /* __XEN_MONITOR_H__ */