FreeBSD/sys/dev/drm2/drm_drv.c
/**
 * Copy and IOCTL return string to user space
 */
Copy and IOCTL return string to user space
Copy and IOCTL return string to user space
static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
{
	int len;
	len = strlen(value);
	if (len > *buf_len)
		len = *buf_len;
	*buf_len = strlen(value);
	if (len && buf)
		if (copy_to_user(buf, value, len))
			return -EFAULT;
	return 0;
}
static int drm_copy_field ( char * buf , size_t * buf_len , const char * value ) { int len ; len = strlen ( value ) ; if ( len > * buf_len ) len = * buf_len ; * buf_len = strlen ( value ) ; if ( len && buf ) if ( copy_to_user ( buf , value , len ) ) return - EFAULT ; return 0 ; }
Copy and IOCTL return string to user space
Copy and IOCTL return string to user space
/* don't overflow userbuf */ /* let userspace know exact length of driver value (which could be
	 * larger than the userspace-supplied buffer) */ /* finally, try filling in the userbuf */