diff mbox

[5/6] common/gnttab: gnttab_query_size() cleanup

Message ID 1502800232-26670-6-git-send-email-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Cooper Aug. 15, 2017, 12:30 p.m. UTC
Drop pointless debugging messages, and reduce variable scope.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: George Dunlap <George.Dunlap@eu.citrix.com>
CC: Jan Beulich <JBeulich@suse.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Tim Deegan <tim@xen.org>
CC: Wei Liu <wei.liu2@citrix.com>
---
 xen/common/grant_table.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

Comments

Jan Beulich Aug. 15, 2017, 1:56 p.m. UTC | #1
>>> On 15.08.17 at 14:30, <andrew.cooper3@citrix.com> wrote:
> --- a/xen/common/grant_table.c
> +++ b/xen/common/grant_table.c
> @@ -1731,31 +1731,25 @@ gnttab_query_size(
>      XEN_GUEST_HANDLE_PARAM(gnttab_query_size_t) uop, unsigned int count)
>  {
>      struct gnttab_query_size op;
> -    struct domain *d;
> -    int rc;
> +    struct domain *d = NULL;

There's no need to add an initializer here afaict. Other than that
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan
Andrew Cooper Aug. 15, 2017, 2:06 p.m. UTC | #2
On 15/08/17 14:56, Jan Beulich wrote:
>>>> On 15.08.17 at 14:30, <andrew.cooper3@citrix.com> wrote:
>> --- a/xen/common/grant_table.c
>> +++ b/xen/common/grant_table.c
>> @@ -1731,31 +1731,25 @@ gnttab_query_size(
>>      XEN_GUEST_HANDLE_PARAM(gnttab_query_size_t) uop, unsigned int count)
>>  {
>>      struct gnttab_query_size op;
>> -    struct domain *d;
>> -    int rc;
>> +    struct domain *d = NULL;
> There's no need to add an initializer here afaict.

Oh yes - so there isn't.

>  Other than that
> Reviewed-by: Jan Beulich <jbeulich@suse.com>

Thanks.

~Andrew
diff mbox

Patch

diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index 6ed86f5..615a8b4 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -1731,31 +1731,25 @@  gnttab_query_size(
     XEN_GUEST_HANDLE_PARAM(gnttab_query_size_t) uop, unsigned int count)
 {
     struct gnttab_query_size op;
-    struct domain *d;
-    int rc;
+    struct domain *d = NULL;
 
     if ( count != 1 )
         return -EINVAL;
 
-    if ( unlikely(copy_from_guest(&op, uop, 1) != 0) )
-    {
-        gdprintk(XENLOG_INFO, "Fault while reading gnttab_query_size_t.\n");
+    if ( unlikely(copy_from_guest(&op, uop, 1)) )
         return -EFAULT;
-    }
 
     d = rcu_lock_domain_by_any_id(op.dom);
     if ( d == NULL )
     {
-        gdprintk(XENLOG_INFO, "Bad domid %d.\n", op.dom);
         op.status = GNTST_bad_domain;
-        goto query_out;
+        goto out;
     }
 
-    rc = xsm_grant_query_size(XSM_TARGET, current->domain, d);
-    if ( rc )
+    if ( xsm_grant_query_size(XSM_TARGET, current->domain, d) )
     {
         op.status = GNTST_permission_denied;
-        goto query_out_unlock;
+        goto out;
     }
 
     grant_read_lock(d->grant_table);
@@ -1766,11 +1760,10 @@  gnttab_query_size(
 
     grant_read_unlock(d->grant_table);
 
+ out:
+    if ( d )
+        rcu_unlock_domain(d);
 
- query_out_unlock:
-    rcu_unlock_domain(d);
-
- query_out:
     if ( unlikely(__copy_to_guest(uop, &op, 1)) )
         return -EFAULT;