userspace: add const qualifiers to user copy fns
The source data is never modified. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
4a8e4de0f1
commit
526807c33b
|
@ -189,7 +189,7 @@ static inline size_t z_user_string_nlen(const char *src, size_t maxlen,
|
||||||
* @return An allocated buffer with the data copied within it, or NULL
|
* @return An allocated buffer with the data copied within it, or NULL
|
||||||
* if some error condition occurred
|
* if some error condition occurred
|
||||||
*/
|
*/
|
||||||
extern void *z_user_alloc_from_copy(void *src, size_t size);
|
extern void *z_user_alloc_from_copy(const void *src, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Copy data from user mode
|
* @brief Copy data from user mode
|
||||||
|
@ -204,7 +204,7 @@ extern void *z_user_alloc_from_copy(void *src, size_t size);
|
||||||
* @retval 0 On success
|
* @retval 0 On success
|
||||||
* @retval EFAULT On memory access error
|
* @retval EFAULT On memory access error
|
||||||
*/
|
*/
|
||||||
extern int z_user_from_copy(void *dst, void *src, size_t size);
|
extern int z_user_from_copy(void *dst, const void *src, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Copy data to user mode
|
* @brief Copy data to user mode
|
||||||
|
@ -219,7 +219,7 @@ extern int z_user_from_copy(void *dst, void *src, size_t size);
|
||||||
* @retval 0 On success
|
* @retval 0 On success
|
||||||
* @retval EFAULT On memory access error
|
* @retval EFAULT On memory access error
|
||||||
*/
|
*/
|
||||||
extern int z_user_to_copy(void *dst, void *src, size_t size);
|
extern int z_user_to_copy(void *dst, const void *src, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Copy a C string from userspace into a resource pool allocation
|
* @brief Copy a C string from userspace into a resource pool allocation
|
||||||
|
@ -235,7 +235,7 @@ extern int z_user_to_copy(void *dst, void *src, size_t size);
|
||||||
* @param maxlen Maximum size of the string including trailing NULL
|
* @param maxlen Maximum size of the string including trailing NULL
|
||||||
* @return The duplicated string, or NULL if an error occurred.
|
* @return The duplicated string, or NULL if an error occurred.
|
||||||
*/
|
*/
|
||||||
extern char *z_user_string_alloc_copy(char *src, size_t maxlen);
|
extern char *z_user_string_alloc_copy(const char *src, size_t maxlen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Copy a C string from userspace into a provided buffer
|
* @brief Copy a C string from userspace into a provided buffer
|
||||||
|
@ -253,7 +253,7 @@ extern char *z_user_string_alloc_copy(char *src, size_t maxlen);
|
||||||
* to maxlen
|
* to maxlen
|
||||||
* @retval EFAULT On memory access error
|
* @retval EFAULT On memory access error
|
||||||
*/
|
*/
|
||||||
extern int z_user_string_copy(char *dst, char *src, size_t maxlen);
|
extern int z_user_string_copy(char *dst, const char *src, size_t maxlen);
|
||||||
|
|
||||||
#define Z_OOPS(expr) \
|
#define Z_OOPS(expr) \
|
||||||
do { \
|
do { \
|
||||||
|
|
|
@ -632,7 +632,7 @@ void z_object_uninit(void *obj)
|
||||||
/*
|
/*
|
||||||
* Copy to/from helper functions used in syscall handlers
|
* Copy to/from helper functions used in syscall handlers
|
||||||
*/
|
*/
|
||||||
void *z_user_alloc_from_copy(void *src, size_t size)
|
void *z_user_alloc_from_copy(const void *src, size_t size)
|
||||||
{
|
{
|
||||||
void *dst = NULL;
|
void *dst = NULL;
|
||||||
k_spinlock_key_t key = k_spin_lock(&ucopy_lock);
|
k_spinlock_key_t key = k_spin_lock(&ucopy_lock);
|
||||||
|
@ -654,7 +654,7 @@ out_err:
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int user_copy(void *dst, void *src, size_t size, bool to_user)
|
static int user_copy(void *dst, const void *src, size_t size, bool to_user)
|
||||||
{
|
{
|
||||||
int ret = EFAULT;
|
int ret = EFAULT;
|
||||||
k_spinlock_key_t key = k_spin_lock(&ucopy_lock);
|
k_spinlock_key_t key = k_spin_lock(&ucopy_lock);
|
||||||
|
@ -672,17 +672,17 @@ out_err:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int z_user_from_copy(void *dst, void *src, size_t size)
|
int z_user_from_copy(void *dst, const void *src, size_t size)
|
||||||
{
|
{
|
||||||
return user_copy(dst, src, size, false);
|
return user_copy(dst, src, size, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int z_user_to_copy(void *dst, void *src, size_t size)
|
int z_user_to_copy(void *dst, const void *src, size_t size)
|
||||||
{
|
{
|
||||||
return user_copy(dst, src, size, true);
|
return user_copy(dst, src, size, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *z_user_string_alloc_copy(char *src, size_t maxlen)
|
char *z_user_string_alloc_copy(const char *src, size_t maxlen)
|
||||||
{
|
{
|
||||||
unsigned long actual_len;
|
unsigned long actual_len;
|
||||||
int err;
|
int err;
|
||||||
|
@ -709,7 +709,7 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int z_user_string_copy(char *dst, char *src, size_t maxlen)
|
int z_user_string_copy(char *dst, const char *src, size_t maxlen)
|
||||||
{
|
{
|
||||||
unsigned long actual_len;
|
unsigned long actual_len;
|
||||||
int ret, err;
|
int ret, err;
|
||||||
|
|
Loading…
Reference in a new issue