Skip to contentSkip to conversation

x86/mm: Clean up p2m_finish_type_change return value

PATCH Superseded Alexandru Stefan ISAILA 2 participants 3 messages Jan 16, 2019

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mm: Clean up p2m_finish_type_change return value

Changed the return value of 1 to 0 so now p2m_finish_type_change returns 0 for success or <0 for error.

---
 xen/arch/x86/mm/p2m.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
xen/arch/x86/mm/p2m.c +4 -8
index d14ce57dd5..ae6459fa53 100644
@@ -1178,6 +1178,7 @@ int p2m_finish_type_change(struct domain *d,
 
     if ( rc < 0 )
         goto out;
+    rc = 0;
 
 #ifdef CONFIG_HVM
     if ( unlikely(altp2m_active(d)) )
@@ -1188,19 +1189,14 @@ int p2m_finish_type_change(struct domain *d,
             if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) )
             {
                 struct p2m_domain *altp2m = d->arch.altp2m_p2m[i];
-                int rc1;
 
                 p2m_lock(altp2m);
-                rc1 = finish_type_change(altp2m, first_gfn, max_nr);
+                rc = finish_type_change(altp2m, first_gfn, max_nr);
                 p2m_unlock(altp2m);
 
-                if ( rc1 < 0 )
-                {
-                    rc = rc1;
+                if ( rc < 0 )
                     goto out;
-                }
-
-                rc |= rc1;
+                rc = 0;
             }
     }
 #endif
Signature · 7 lines
2.17.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 16.01.19 at 16:13, <[email protected]> wrote:

Changed the return value of 1 to 0 so now p2m_finish_type_change returns 0 for success or <0 for error.

This is a valid alternative return value model. Both have their merits. Hence if you want to change from one to the other, you should give a reason.

xen/arch/x86/mm/p2m.c int p2m_finish_type_change(struct domain *d, · line 1181

Quoted 7 lines
xen/arch/x86/mm/p2m.c +1 -0
@@ -1178,6 +1178,7 @@ int p2m_finish_type_change(struct domain *d,
 
     if ( rc < 0 )
         goto out;
+    rc = 0;

Instead of this and ...

Quoted 10 lines
xen/arch/x86/mm/p2m.c +1 -2
@@ -1188,19 +1189,14 @@ int p2m_finish_type_change(struct domain *d,
             if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) )
             {
                 struct p2m_domain *altp2m = d->arch.altp2m_p2m[i];
-                int rc1;
 
                 p2m_lock(altp2m);
-                rc1 = finish_type_change(altp2m, first_gfn, max_nr);
+                rc = finish_type_change(altp2m, first_gfn, max_nr);
                 p2m_unlock(altp2m);

xen/arch/x86/mm/p2m.c int p2m_finish_type_change(struct domain *d, · line 1199

Quoted 10 lines
xen/arch/x86/mm/p2m.c +2 -6
 
-                if ( rc1 < 0 )
-                {
-                    rc = rc1;
+                if ( rc < 0 )
                     goto out;
-                }
-
-                rc |= rc1;
+                rc = 0;

... this, why don't you simply set "rc" to zero once ...

xen/arch/x86/mm/p2m.c int p2m_finish_type_change(struct domain *d, · line 1202

Quoted 3 lines
xen/arch/x86/mm/p2m.c +0 -0
             }
     }
 #endif

... below here (but ahead of the "out" label)?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 7 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 16.01.19 at 16:13, <[email protected]> wrote:

Changed the return value of 1 to 0 so now p2m_finish_type_change returns 0 for success or <0 for error.

This is a valid alternative return value model. Both have their merits. Hence if you want to change from one to the other, you should give a reason.

This was done after a discussion with George
https://lists.xenproject.org/archives/html/xen-devel/2019-01/msg00740.html

I will update the patch comment with this reason.

Quoted 34 lines

xen/arch/x86/mm/p2m.c int p2m_finish_type_change(struct domain *d, · line 1181

Quoted 8 lines
xen/arch/x86/mm/p2m.c +1 -0
@@ -1178,6 +1178,7 @@ int p2m_finish_type_change(struct domain *d,
 
      if ( rc < 0 )
          goto out;
+    rc = 0;

Instead of this and ...

Quoted 10 lines
xen/arch/x86/mm/p2m.c +1 -2
@@ -1188,19 +1189,14 @@ int p2m_finish_type_change(struct domain *d,
              if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) )
              {
                  struct p2m_domain *altp2m = d->arch.altp2m_p2m[i];
-                int rc1;
 
                  p2m_lock(altp2m);
-                rc1 = finish_type_change(altp2m, first_gfn, max_nr);
+                rc = finish_type_change(altp2m, first_gfn, max_nr);
                  p2m_unlock(altp2m);

xen/arch/x86/mm/p2m.c int p2m_finish_type_change(struct domain *d, · line 1199

Quoted 10 lines
xen/arch/x86/mm/p2m.c +2 -6
 
-                if ( rc1 < 0 )
-                {
-                    rc = rc1;
+                if ( rc < 0 )
                      goto out;
-                }
-
-                rc |= rc1;
+                rc = 0;

... this, why don't you simply set "rc" to zero once ...

Quoted 5 lines

xen/arch/x86/mm/p2m.c int p2m_finish_type_change(struct domain *d, · line 1202

Quoted 3 lines
xen/arch/x86/mm/p2m.c +0 -0
              }
      }
  #endif

... below here (but ahead of the "out" label)?

I will move the rc = 0 there in v2.

Thanks,
Alex

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel