/* compat_count() counts the number of arguments/envelopes. It is basically a copy of count() from fs/exec.c, except that it works with 32 bit argv and envp pointers.  */
static int compat_count(compat_uptr_t __user *argv, int max)
/* compat_count() counts the number of arguments/envelopes. It is basically a copy of count() from fs/exec.c, except that it works with 32 bit argv and envp pointers.  */
static int compat_count(compat_uptr_t __user *argv, int max)
{
	int i = 0;
	if (argv != NULL) {
		for (;;) {
			compat_uptr_t p;
			if (get_user(p, argv))
				return -EFAULT;
			if (!p)
				break;
			argv++;
			if (i++ >= max)
				return -E2BIG;
		}
	}
	return i;
}