Skip to contentSkip to conversation

[5267] Swap only altered elements of the grouplist in getgroups() ( Kirill Shutemov).

Qemu-devel Andrzej Zaborowski 1 participant 1 message Sep 20, 2008

lore
Share & tools
lore
#0 lore raw

Revision: 5267

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5267
Author:   balrog
Date:     2008-09-20 02:12:08 +0000 (Sat, 20 Sep 2008)

Log Message:
-----------
Swap only altered elements of the grouplist in getgroups() (Kirill Shutemov).

getgroups() returns the number of supplementary group IDs, so it's unnessary to swap the entire array. It can dramatically speed up the syscall: on recent Linux kernels NGROUPS_MAX=65536.

Modified Paths:
--------------
trunk/linux-user/syscall.c

Modified: trunk/linux-user/syscall.c
===================================================================

linux-user/syscall.c +2 -2
@@ -5253,7 +5253,7 @@
                 target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 2, 0);
                 if (!target_grouplist)
                     goto efault;
-                for(i = 0;i < gidsetsize; i++)
+                for(i = 0;i < ret; i++)
                     target_grouplist[i] = tswap16(grouplist[i]);
                 unlock_user(target_grouplist, arg2, gidsetsize * 2);
             }
@@ -5407,7 +5407,7 @@
                     ret = -TARGET_EFAULT;
                     goto fail;
                 }
-                for(i = 0;i < gidsetsize; i++)
+                for(i = 0;i < ret; i++)
                     target_grouplist[i] = tswap32(grouplist[i]);
                 unlock_user(target_grouplist, arg2, gidsetsize * 4);
             }