This is an automated email from the ASF dual-hosted git repository.
GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new e103b8997e9 fs/userfs: clean up userfs implementation
e103b8997e9 is described below
commit e103b8997e9cfe9eac0f3fac8dff4105d3ea8663
Author: Xiang Xiao <[email protected]>
AuthorDate: Tue Nov 24 21:40:19 2026 +0800
fs/userfs: clean up userfs implementation
1. Remove unneeded casts: drop (int)nsent, (int)nrecvd,
(unsigned int)nrecvd, (intmax_t)filep->f_pos,
(unsigned long)offset, (FAR void *)priv, and similar
redundant casts. Use %zd and PRIdOFF format specifiers
instead.
2. Merge multi-line DEBUGASSERT into more compact form.
3. Replace sizeof(struct xxx) with sizeof(*variable) or
sizeof(variable) throughout both files for better type
safety. e.g. sizeof(*req), sizeof(*resp), sizeof(*buf),
sizeof(priv->server), sizeof(info->client), etc.
4. Remove duplicate forward declaration of userfs_read.
Signed-off-by: Xiang Xiao <[email protected]>
Signed-off-by: jingfei <[email protected]>
---
fs/userfs/fs_userfs.c | 481 ++++++++++++++++++++----------------------
libs/libc/userfs/lib_userfs.c | 158 +++++++-------
2 files changed, 306 insertions(+), 333 deletions(-)
diff --git a/fs/userfs/fs_userfs.c b/fs/userfs/fs_userfs.c
index 2932563c807..087f1d99be3 100644
--- a/fs/userfs/fs_userfs.c
+++ b/fs/userfs/fs_userfs.c
@@ -31,6 +31,7 @@
#include <sys/stat.h>
#include <sys/socket.h>
+#include <inttypes.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
@@ -102,8 +103,6 @@ struct userfs_state_s
static int userfs_open(FAR struct file *filep, const char *relpath,
int oflags, mode_t mode);
static int userfs_close(FAR struct file *filep);
-static ssize_t userfs_read(FAR struct file *filep, char *buffer,
- size_t buflen);
static ssize_t userfs_read(FAR struct file *filep, FAR char *buffer,
size_t buflen);
static ssize_t userfs_write(FAR struct file *filep, FAR const char *buffer,
@@ -245,8 +244,7 @@ static int userfs_open(FAR struct file *filep, FAR const
char *relpath,
finfo("Open '%s'\n", relpath);
- DEBUGASSERT(
- filep->f_inode != NULL &&
+ DEBUGASSERT(filep->f_inode != NULL &&
filep->f_inode->i_private != NULL);
priv = filep->f_inode->i_private;
@@ -279,12 +277,12 @@ static int userfs_open(FAR struct file *filep, FAR const
char *relpath,
nsent = psock_sendto(&priv->psock, priv->iobuffer,
SIZEOF_USERFS_OPEN_REQUEST_S(pathlen), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -294,14 +292,14 @@ static int userfs_open(FAR struct file *filep, FAR const
char *relpath,
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_open_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -337,8 +335,7 @@ static int userfs_close(FAR struct file *filep)
ssize_t nrecvd;
int ret;
- DEBUGASSERT(
- filep->f_inode != NULL &&
+ DEBUGASSERT(filep->f_inode != NULL &&
filep->f_inode->i_private != NULL);
priv = filep->f_inode->i_private;
@@ -357,14 +354,14 @@ static int userfs_close(FAR struct file *filep)
req->openinfo = filep->f_priv;
nsent = psock_sendto(&priv->psock, priv->iobuffer,
- sizeof(struct userfs_close_request_s), 0,
+ sizeof(*req), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -374,14 +371,14 @@ static int userfs_close(FAR struct file *filep)
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_close_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -422,10 +419,9 @@ static ssize_t userfs_read(FAR struct file *filep, char
*buffer,
ssize_t nread;
int ret;
- finfo("Read %zu bytes from offset %jd\n", buflen, (intmax_t)filep->f_pos);
+ finfo("Read %zu bytes from offset %" PRIdOFF "\n", buflen, filep->f_pos);
- DEBUGASSERT(
- filep->f_inode != NULL &&
+ DEBUGASSERT(filep->f_inode != NULL &&
filep->f_inode->i_private != NULL);
priv = filep->f_inode->i_private;
@@ -445,14 +441,14 @@ static ssize_t userfs_read(FAR struct file *filep, char
*buffer,
req->readlen = buflen;
nsent = psock_sendto(&priv->psock, priv->iobuffer,
- sizeof(struct userfs_read_request_s), 0,
+ sizeof(*req), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -462,14 +458,14 @@ static ssize_t userfs_read(FAR struct file *filep, char
*buffer,
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
if (nrecvd < SIZEOF_USERFS_READ_RESPONSE_S(0))
{
- ferr("ERROR: Response too small: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response too small: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -484,7 +480,7 @@ static ssize_t userfs_read(FAR struct file *filep, char
*buffer,
if (resp->nread > buflen)
{
- ferr("ERROR: Response size too large: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size too large: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -492,7 +488,7 @@ static ssize_t userfs_read(FAR struct file *filep, char
*buffer,
respsize = SIZEOF_USERFS_READ_RESPONSE_S(resp->nread);
if (respsize != nrecvd)
{
- ferr("ERROR: Incorrect response size: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Incorrect response size: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -526,10 +522,9 @@ static ssize_t userfs_write(FAR struct file *filep, FAR
const char *buffer,
ssize_t nwritten;
int ret;
- finfo("Write %zu bytes to offset %jd\n", buflen, (intmax_t)filep->f_pos);
+ finfo("Write %zu bytes to offset %" PRIdOFF "\n", buflen, filep->f_pos);
- DEBUGASSERT(
- filep->f_inode != NULL &&
+ DEBUGASSERT(filep->f_inode != NULL &&
filep->f_inode->i_private != NULL);
priv = filep->f_inode->i_private;
@@ -561,12 +556,12 @@ static ssize_t userfs_write(FAR struct file *filep, FAR
const char *buffer,
nsent = psock_sendto(&priv->psock, priv->iobuffer,
SIZEOF_USERFS_WRITE_REQUEST_S(buflen), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -576,14 +571,14 @@ static ssize_t userfs_write(FAR struct file *filep, FAR
const char *buffer,
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_write_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -621,10 +616,9 @@ static off_t userfs_seek(FAR struct file *filep, off_t
offset, int whence)
off_t off_ret;
int ret;
- finfo("Offset %lu bytes to whence=%d\n", (unsigned long)offset, whence);
+ finfo("Offset %" PRIdOFF " bytes to whence=%d\n", offset, whence);
- DEBUGASSERT(
- filep->f_inode != NULL &&
+ DEBUGASSERT(filep->f_inode != NULL &&
filep->f_inode->i_private != NULL);
priv = filep->f_inode->i_private;
@@ -645,14 +639,14 @@ static off_t userfs_seek(FAR struct file *filep, off_t
offset, int whence)
req->whence = whence;
nsent = psock_sendto(&priv->psock, priv->iobuffer,
- sizeof(struct userfs_seek_request_s), 0,
+ sizeof(*req), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -662,14 +656,14 @@ static off_t userfs_seek(FAR struct file *filep, off_t
offset, int whence)
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_seek_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -826,8 +820,7 @@ static int userfs_ioctl(FAR struct file *filep, int cmd,
unsigned long arg)
}
}
- DEBUGASSERT(
- filep->f_inode != NULL &&
+ DEBUGASSERT(filep->f_inode != NULL &&
filep->f_inode->i_private != NULL);
priv = filep->f_inode->i_private;
@@ -848,14 +841,14 @@ static int userfs_ioctl(FAR struct file *filep, int cmd,
unsigned long arg)
req->arg = arg;
nsent = psock_sendto(&priv->psock, priv->iobuffer,
- sizeof(struct userfs_ioctl_request_s), 0,
+ sizeof(*req), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -865,14 +858,14 @@ static int userfs_ioctl(FAR struct file *filep, int cmd,
unsigned long arg)
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_ioctl_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -993,8 +986,7 @@ static int userfs_sync(FAR struct file *filep)
ssize_t nrecvd;
int ret;
- DEBUGASSERT(
- filep->f_inode != NULL &&
+ DEBUGASSERT(filep->f_inode != NULL &&
filep->f_inode->i_private != NULL);
priv = filep->f_inode->i_private;
@@ -1013,14 +1005,14 @@ static int userfs_sync(FAR struct file *filep)
req->openinfo = filep->f_priv;
nsent = psock_sendto(&priv->psock, priv->iobuffer,
- sizeof(struct userfs_sync_request_s), 0,
+ sizeof(*req), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -1030,14 +1022,14 @@ static int userfs_sync(FAR struct file *filep)
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_sync_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -1096,14 +1088,14 @@ static int userfs_dup(FAR const struct file *oldp, FAR
struct file *newp)
req->openinfo = oldp->f_priv;
nsent = psock_sendto(&priv->psock, priv->iobuffer,
- sizeof(struct userfs_dup_request_s), 0,
+ sizeof(*req), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -1113,14 +1105,14 @@ static int userfs_dup(FAR const struct file *oldp, FAR
struct file *newp)
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_dup_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -1159,8 +1151,7 @@ static int userfs_fstat(FAR const struct file *filep, FAR
struct stat *buf)
ssize_t nrecvd;
int ret;
- DEBUGASSERT(
- filep->f_inode != NULL &&
+ DEBUGASSERT(filep->f_inode != NULL &&
filep->f_inode->i_private != NULL);
priv = filep->f_inode->i_private;
@@ -1179,14 +1170,14 @@ static int userfs_fstat(FAR const struct file *filep,
FAR struct stat *buf)
req->openinfo = filep->f_priv;
nsent = psock_sendto(&priv->psock, priv->iobuffer,
- sizeof(struct userfs_fstat_request_s), 0,
+ sizeof(*req), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -1196,14 +1187,14 @@ static int userfs_fstat(FAR const struct file *filep,
FAR struct stat *buf)
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_fstat_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -1219,7 +1210,7 @@ static int userfs_fstat(FAR const struct file *filep, FAR
struct stat *buf)
/* Return the status of the directory entry */
DEBUGASSERT(buf != NULL);
- memcpy(buf, &resp->buf, sizeof(struct stat));
+ memcpy(buf, &resp->buf, sizeof(*buf));
ret = resp->ret;
nxmutex_unlock(&priv->lock);
@@ -1246,8 +1237,7 @@ static int userfs_fchstat(FAR const struct file *filep,
ssize_t nrecvd;
int ret;
- DEBUGASSERT(
- filep->f_inode != NULL &&
+ DEBUGASSERT(filep->f_inode != NULL &&
filep->f_inode->i_private != NULL);
priv = filep->f_inode->i_private;
@@ -1268,14 +1258,14 @@ static int userfs_fchstat(FAR const struct file *filep,
req->flags = flags;
nsent = psock_sendto(&priv->psock, priv->iobuffer,
- sizeof(struct userfs_fchstat_request_s), 0,
+ sizeof(*req), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -1287,10 +1277,10 @@ static int userfs_fchstat(FAR const struct file *filep,
{
ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_fchstat_response_s))
+ if (nrecvd != sizeof(*resp))
{
ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
@@ -1329,8 +1319,7 @@ static int userfs_truncate(FAR struct file *filep, off_t
length)
ssize_t nrecvd;
int ret;
- DEBUGASSERT(
- filep->f_inode != NULL &&
+ DEBUGASSERT(filep->f_inode != NULL &&
filep->f_inode->i_private != NULL);
priv = filep->f_inode->i_private;
@@ -1350,14 +1339,14 @@ static int userfs_truncate(FAR struct file *filep,
off_t length)
req->length = length;
nsent = psock_sendto(&priv->psock, priv->iobuffer,
- sizeof(struct userfs_truncate_request_s), 0,
+ sizeof(*req), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -1367,14 +1356,14 @@ static int userfs_truncate(FAR struct file *filep,
off_t length)
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_truncate_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -1418,8 +1407,7 @@ static int userfs_opendir(FAR struct inode *mountpt, FAR
const char *relpath,
finfo("relpath: \"%s\"\n", relpath ? relpath : "NULL");
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
/* Check the path length */
@@ -1449,12 +1437,12 @@ static int userfs_opendir(FAR struct inode *mountpt,
FAR const char *relpath,
nsent = psock_sendto(&priv->psock, priv->iobuffer,
SIZEOF_USERFS_OPENDIR_REQUEST_S(pathlen), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -1464,14 +1452,14 @@ static int userfs_opendir(FAR struct inode *mountpt,
FAR const char *relpath,
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_opendir_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -1487,7 +1475,7 @@ static int userfs_opendir(FAR struct inode *mountpt, FAR
const char *relpath,
/* Save the opaque dir reference in struct fs_dirent_s */
DEBUGASSERT(dir != NULL);
- udir = fs_heap_zalloc(sizeof(struct userfs_dir_s));
+ udir = fs_heap_zalloc(sizeof(*udir));
if (udir == NULL)
{
nxmutex_unlock(&priv->lock);
@@ -1522,8 +1510,7 @@ static int userfs_closedir(FAR struct inode *mountpt,
ssize_t nrecvd;
int ret;
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
udir = (FAR struct userfs_dir_s *)dir;
@@ -1542,14 +1529,14 @@ static int userfs_closedir(FAR struct inode *mountpt,
req->dir = udir->dir;
nsent = psock_sendto(&priv->psock, priv->iobuffer,
- sizeof(struct userfs_closedir_request_s), 0,
+ sizeof(*req), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -1559,14 +1546,14 @@ static int userfs_closedir(FAR struct inode *mountpt,
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_closedir_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -1606,8 +1593,7 @@ static int userfs_readdir(FAR struct inode *mountpt,
ssize_t nrecvd;
int ret;
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
udir = (FAR struct userfs_dir_s *)dir;
@@ -1626,14 +1612,14 @@ static int userfs_readdir(FAR struct inode *mountpt,
req->dir = udir->dir;
nsent = psock_sendto(&priv->psock, priv->iobuffer,
- sizeof(struct userfs_readdir_request_s), 0,
+ sizeof(*req), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -1643,14 +1629,14 @@ static int userfs_readdir(FAR struct inode *mountpt,
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_readdir_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -1666,7 +1652,7 @@ static int userfs_readdir(FAR struct inode *mountpt,
/* Return the dirent */
DEBUGASSERT(dir != NULL);
- memcpy(entry, &resp->entry, sizeof(struct dirent));
+ memcpy(entry, &resp->entry, sizeof(*entry));
ret = resp->ret;
nxmutex_unlock(&priv->lock);
@@ -1692,8 +1678,7 @@ static int userfs_rewinddir(FAR struct inode *mountpt,
ssize_t nrecvd;
int ret;
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
udir = (FAR struct userfs_dir_s *)dir;
@@ -1712,14 +1697,14 @@ static int userfs_rewinddir(FAR struct inode *mountpt,
req->dir = udir->dir;
nsent = psock_sendto(&priv->psock, priv->iobuffer,
- sizeof(struct userfs_rewinddir_request_s), 0,
+ sizeof(*req), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -1729,14 +1714,14 @@ static int userfs_rewinddir(FAR struct inode *mountpt,
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_rewinddir_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -1777,7 +1762,7 @@ static int userfs_bind(FAR struct inode *blkdriver, FAR
const void *data,
int ret;
DEBUGASSERT(data != NULL && handle != NULL);
- config = (FAR const struct userfs_config_s *)data;
+ config = data;
/* Allocate an instance of the UserFS state structure */
@@ -1825,7 +1810,7 @@ static int userfs_bind(FAR struct inode *blkdriver, FAR
const void *data,
client.sin_addr.s_addr = HTONL(INADDR_LOOPBACK);
ret = psock_bind(&priv->psock, (FAR struct sockaddr *)&client,
- sizeof(struct sockaddr_in));
+ sizeof(client));
if (ret < 0)
{
ferr("ERROR: bind() failed: %d\n", ret);
@@ -1834,7 +1819,7 @@ static int userfs_bind(FAR struct inode *blkdriver, FAR
const void *data,
/* Mounted! */
- *handle = (FAR void *)priv;
+ *handle = priv;
return OK;
errout_with_psock:
@@ -1880,14 +1865,14 @@ static int userfs_unbind(FAR void *handle, FAR struct
inode **blkdriver,
req->req = USERFS_REQ_DESTROY;
nsent = psock_sendto(&priv->psock, priv->iobuffer,
- sizeof(struct userfs_destroy_request_s), 0,
+ sizeof(*req), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -1897,14 +1882,14 @@ static int userfs_unbind(FAR void *handle, FAR struct
inode **blkdriver,
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_destroy_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -1953,8 +1938,7 @@ static int userfs_statfs(FAR struct inode *mountpt, FAR
struct statfs *buf)
ssize_t nrecvd;
int ret;
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
/* Get exclusive access */
@@ -1971,14 +1955,14 @@ static int userfs_statfs(FAR struct inode *mountpt, FAR
struct statfs *buf)
req->req = USERFS_REQ_STATFS;
nsent = psock_sendto(&priv->psock, priv->iobuffer,
- sizeof(struct userfs_statfs_request_s), 0,
+ sizeof(*req), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -1988,14 +1972,14 @@ static int userfs_statfs(FAR struct inode *mountpt, FAR
struct statfs *buf)
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_statfs_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -2011,7 +1995,7 @@ static int userfs_statfs(FAR struct inode *mountpt, FAR
struct statfs *buf)
/* Return the status of the file system */
DEBUGASSERT(buf != NULL);
- memcpy(buf, &resp->buf, sizeof(struct statfs));
+ memcpy(buf, &resp->buf, sizeof(*buf));
ret = resp->ret;
nxmutex_unlock(&priv->lock);
@@ -2038,8 +2022,7 @@ static int userfs_unlink(FAR struct inode *mountpt,
int pathlen;
int ret;
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
/* Check the path length */
@@ -2069,12 +2052,12 @@ static int userfs_unlink(FAR struct inode *mountpt,
nsent = psock_sendto(&priv->psock, priv->iobuffer,
SIZEOF_USERFS_UNLINK_REQUEST_S(pathlen), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -2084,14 +2067,14 @@ static int userfs_unlink(FAR struct inode *mountpt,
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_unlink_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -2130,8 +2113,7 @@ static int userfs_mkdir(FAR struct inode *mountpt,
int pathlen;
int ret;
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
/* Check the path length */
@@ -2162,12 +2144,12 @@ static int userfs_mkdir(FAR struct inode *mountpt,
nsent = psock_sendto(&priv->psock, priv->iobuffer,
SIZEOF_USERFS_MKDIR_REQUEST_S(pathlen), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -2177,14 +2159,14 @@ static int userfs_mkdir(FAR struct inode *mountpt,
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_mkdir_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -2223,8 +2205,7 @@ static int userfs_rmdir(FAR struct inode *mountpt,
int pathlen;
int ret;
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
/* Check the path length */
@@ -2254,12 +2235,12 @@ static int userfs_rmdir(FAR struct inode *mountpt,
nsent = psock_sendto(&priv->psock, priv->iobuffer,
SIZEOF_USERFS_RMDIR_REQUEST_S(pathlen), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -2269,14 +2250,14 @@ static int userfs_rmdir(FAR struct inode *mountpt,
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_rmdir_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -2318,8 +2299,7 @@ static int userfs_rename(FAR struct inode *mountpt,
ssize_t nrecvd;
int ret;
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
/* The server may not replace an existing newrelpath. EEXIST makes the
@@ -2362,12 +2342,12 @@ static int userfs_rename(FAR struct inode *mountpt,
nsent = psock_sendto(&priv->psock, priv->iobuffer,
SIZEOF_USERFS_RENAME_REQUEST_S(oldpathlen, newpathlen),
0, (FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -2377,14 +2357,14 @@ static int userfs_rename(FAR struct inode *mountpt,
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_rename_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -2423,8 +2403,7 @@ static int userfs_stat(FAR struct inode *mountpt, FAR
const char *relpath,
int pathlen;
int ret;
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
/* Check the path length */
@@ -2454,12 +2433,12 @@ static int userfs_stat(FAR struct inode *mountpt, FAR
const char *relpath,
nsent = psock_sendto(&priv->psock, priv->iobuffer,
SIZEOF_USERFS_STAT_REQUEST_S(pathlen), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
- ferr("ERROR: psock_sendto failed: %d\n", (int)nsent);
+ ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -2469,14 +2448,14 @@ static int userfs_stat(FAR struct inode *mountpt, FAR
const char *relpath,
if (nrecvd < 0)
{
- ferr("ERROR: psock_recvfrom failed: %d\n", (int)nrecvd);
+ ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_stat_response_s))
+ if (nrecvd != sizeof(*resp))
{
- ferr("ERROR: Response size incorrect: %u\n", (unsigned int)nrecvd);
+ ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
return -EIO;
}
@@ -2492,7 +2471,7 @@ static int userfs_stat(FAR struct inode *mountpt, FAR
const char *relpath,
/* Return the directory entry status */
DEBUGASSERT(buf != NULL);
- memcpy(buf, &resp->buf, sizeof(struct stat));
+ memcpy(buf, &resp->buf, sizeof(*buf));
ret = resp->ret;
nxmutex_unlock(&priv->lock);
@@ -2519,8 +2498,7 @@ static int userfs_chstat(FAR struct inode *mountpt, FAR
const char *relpath,
int pathlen;
int ret;
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
/* Check the path length */
@@ -2552,12 +2530,12 @@ static int userfs_chstat(FAR struct inode *mountpt, FAR
const char *relpath,
nsent = psock_sendto(&priv->psock, priv->iobuffer,
SIZEOF_USERFS_CHSTAT_REQUEST_S(pathlen), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -2569,10 +2547,10 @@ static int userfs_chstat(FAR struct inode *mountpt, FAR
const char *relpath,
{
ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_chstat_response_s))
+ if (nrecvd != sizeof(*resp))
{
ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
nxmutex_unlock(&priv->lock);
@@ -2611,8 +2589,7 @@ static int userfs_syncfs(FAR struct inode *mountpt)
ssize_t nrecvd;
int ret;
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
/* Get exclusive access */
@@ -2629,14 +2606,14 @@ static int userfs_syncfs(FAR struct inode *mountpt)
req->req = USERFS_REQ_SYNCFS;
nsent = psock_sendto(&priv->psock, priv->iobuffer,
- sizeof(struct userfs_syncfs_request_s), 0,
+ sizeof(*req), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -2648,10 +2625,10 @@ static int userfs_syncfs(FAR struct inode *mountpt)
if (nrecvd < 0)
{
ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_syncfs_response_s))
+ if (nrecvd != sizeof(*resp))
{
ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
return -EIO;
@@ -2690,8 +2667,7 @@ static int userfs_link(FAR struct inode *mountpt,
ssize_t nrecvd;
int ret;
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
/* Check the path lengths */
@@ -2725,12 +2701,12 @@ static int userfs_link(FAR struct inode *mountpt,
nsent = psock_sendto(&priv->psock, priv->iobuffer,
SIZEOF_USERFS_LINK_REQUEST_S(path1len, path2len),
0, (FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -2742,10 +2718,10 @@ static int userfs_link(FAR struct inode *mountpt,
if (nrecvd < 0)
{
ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_link_response_s))
+ if (nrecvd != sizeof(*resp))
{
ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
return -EIO;
@@ -2782,8 +2758,7 @@ static int userfs_symlink(FAR struct inode *mountpt,
ssize_t nrecvd;
int ret;
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
/* Check the path lengths */
@@ -2817,12 +2792,12 @@ static int userfs_symlink(FAR struct inode *mountpt,
nsent = psock_sendto(&priv->psock, priv->iobuffer,
SIZEOF_USERFS_SYMLINK_REQUEST_S(path1len, path2len),
0, (FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -2834,10 +2809,10 @@ static int userfs_symlink(FAR struct inode *mountpt,
if (nrecvd < 0)
{
ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_symlink_response_s))
+ if (nrecvd != sizeof(*resp))
{
ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
return -EIO;
@@ -2873,8 +2848,7 @@ static ssize_t userfs_readlink(FAR struct inode *mountpt,
int pathlen;
int ret;
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
/* Check the path length */
@@ -2905,7 +2879,7 @@ static ssize_t userfs_readlink(FAR struct inode *mountpt,
nsent = psock_sendto(&priv->psock, priv->iobuffer,
SIZEOF_USERFS_READLINK_REQUEST_S(pathlen + 1), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
ferr("ERROR: psock_sendto failed: %zd\n", nsent);
@@ -2975,8 +2949,7 @@ static int userfs_lstat(FAR struct inode *mountpt,
int pathlen;
int ret;
- DEBUGASSERT(mountpt != NULL &&
- mountpt->i_private != NULL);
+ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
priv = mountpt->i_private;
/* Check the path length */
@@ -3006,12 +2979,12 @@ static int userfs_lstat(FAR struct inode *mountpt,
nsent = psock_sendto(&priv->psock, priv->iobuffer,
SIZEOF_USERFS_LSTAT_REQUEST_S(pathlen + 1), 0,
(FAR struct sockaddr *)&priv->server,
- sizeof(struct sockaddr_in));
+ sizeof(priv->server));
if (nsent < 0)
{
ferr("ERROR: psock_sendto failed: %zd\n", nsent);
nxmutex_unlock(&priv->lock);
- return (int)nsent;
+ return nsent;
}
/* Then get the response from the server */
@@ -3023,10 +2996,10 @@ static int userfs_lstat(FAR struct inode *mountpt,
if (nrecvd < 0)
{
ferr("ERROR: psock_recvfrom failed: %zd\n", nrecvd);
- return (int)nrecvd;
+ return nrecvd;
}
- if (nrecvd != sizeof(struct userfs_lstat_response_s))
+ if (nrecvd != sizeof(*resp))
{
ferr("ERROR: Response size incorrect: %zd\n", nrecvd);
return -EIO;
@@ -3048,7 +3021,7 @@ static int userfs_lstat(FAR struct inode *mountpt,
}
DEBUGASSERT(buf != NULL);
- memcpy(buf, &resp->buf, sizeof(struct stat));
+ memcpy(buf, &resp->buf, sizeof(*buf));
return ret;
}
diff --git a/libs/libc/userfs/lib_userfs.c b/libs/libc/userfs/lib_userfs.c
index 76d727b2fc0..ef66df302b4 100644
--- a/libs/libc/userfs/lib_userfs.c
+++ b/libs/libc/userfs/lib_userfs.c
@@ -154,9 +154,9 @@ static inline int userfs_open_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_OPEN;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_open_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
if (nsent < 0)
{
ret = -get_errno();
@@ -166,7 +166,7 @@ static inline int userfs_open_dispatch(FAR struct
userfs_info_s *info,
/* REVISIT: Partial sends are not supported */
- DEBUGASSERT(nsent == sizeof(struct userfs_open_response_s));
+ DEBUGASSERT(nsent == sizeof(resp));
return OK;
}
@@ -178,7 +178,7 @@ static inline int userfs_close_dispatch(FAR struct
userfs_info_s *info,
/* Verify the request size */
- if (reqlen != sizeof(struct userfs_close_request_s))
+ if (reqlen != sizeof(*req))
{
return -EINVAL;
}
@@ -192,9 +192,9 @@ static inline int userfs_close_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_CLOSE;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_close_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -208,7 +208,7 @@ static inline int userfs_read_dispatch(FAR struct
userfs_info_s *info,
/* Verify the request size */
- if (reqlen != sizeof(struct userfs_read_request_s))
+ if (reqlen != sizeof(*req))
{
return -EINVAL;
}
@@ -233,7 +233,7 @@ static inline int userfs_read_dispatch(FAR struct
userfs_info_s *info,
resplen = SIZEOF_USERFS_READ_RESPONSE_S(resp->nread);
nsent = sendto(info->sockfd, resp, resplen, 0,
(FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -274,9 +274,9 @@ static inline int userfs_write_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_WRITE;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_write_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -288,7 +288,7 @@ static inline int userfs_seek_dispatch(FAR struct
userfs_info_s *info,
/* Verify the request size */
- if (reqlen != sizeof(struct userfs_seek_request_s))
+ if (reqlen != sizeof(*req))
{
return -EINVAL;
}
@@ -303,9 +303,9 @@ static inline int userfs_seek_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_SEEK;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_seek_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -317,7 +317,7 @@ static inline int userfs_ioctl_dispatch(FAR struct
userfs_info_s *info,
/* Verify the request size */
- if (reqlen != sizeof(struct userfs_ioctl_request_s))
+ if (reqlen != sizeof(*req))
{
return -EINVAL;
}
@@ -332,9 +332,9 @@ static inline int userfs_ioctl_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_IOCTL;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_ioctl_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -346,7 +346,7 @@ static inline int userfs_sync_dispatch(FAR struct
userfs_info_s *info,
/* Verify the request size */
- if (reqlen != sizeof(struct userfs_sync_request_s))
+ if (reqlen != sizeof(*req))
{
return -EINVAL;
}
@@ -360,9 +360,9 @@ static inline int userfs_sync_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_SYNC;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_sync_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -374,7 +374,7 @@ static inline int userfs_dup_dispatch(FAR struct
userfs_info_s *info,
/* Verify the request size */
- if (reqlen != sizeof(struct userfs_dup_request_s))
+ if (reqlen != sizeof(*req))
{
return -EINVAL;
}
@@ -389,9 +389,9 @@ static inline int userfs_dup_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_DUP;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_dup_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -403,7 +403,7 @@ static inline int userfs_fstat_dispatch(FAR struct
userfs_info_s *info,
/* Verify the request size */
- if (reqlen != sizeof(struct userfs_fstat_request_s))
+ if (reqlen != sizeof(*req))
{
return -EINVAL;
}
@@ -417,9 +417,9 @@ static inline int userfs_fstat_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_FSTAT;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_fstat_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -431,7 +431,7 @@ static inline int userfs_truncate_dispatch(FAR struct
userfs_info_s *info,
/* Verify the request size */
- if (reqlen != sizeof(struct userfs_truncate_request_s))
+ if (reqlen != sizeof(*req))
{
return -EINVAL;
}
@@ -446,9 +446,9 @@ static inline int userfs_truncate_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_TRUNCATE;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_truncate_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -488,9 +488,9 @@ static inline int userfs_opendir_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_OPENDIR;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_opendir_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -502,7 +502,7 @@ static inline int userfs_closedir_dispatch(FAR struct
userfs_info_s *info,
/* Verify the request size */
- if (reqlen != sizeof(struct userfs_closedir_request_s))
+ if (reqlen != sizeof(*req))
{
return -EINVAL;
}
@@ -516,9 +516,9 @@ static inline int userfs_closedir_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_CLOSEDIR;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_closedir_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -530,7 +530,7 @@ static inline int userfs_readdir_dispatch(FAR struct
userfs_info_s *info,
/* Verify the request size */
- if (reqlen != sizeof(struct userfs_readdir_request_s))
+ if (reqlen != sizeof(*req))
{
return -EINVAL;
}
@@ -544,9 +544,9 @@ static inline int userfs_readdir_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_READDIR;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_readdir_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -558,7 +558,7 @@ static inline int userfs_rewinddir_dispatch(FAR struct
userfs_info_s *info,
/* Verify the request size */
- if (reqlen != sizeof(struct userfs_rewinddir_request_s))
+ if (reqlen != sizeof(*req))
{
return -EINVAL;
}
@@ -572,9 +572,9 @@ static inline int userfs_rewinddir_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_REWINDDIR;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_rewinddir_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -586,7 +586,7 @@ static inline int userfs_statfs_dispatch(FAR struct
userfs_info_s *info,
/* Verify the request size */
- if (reqlen != sizeof(struct userfs_statfs_request_s))
+ if (reqlen != sizeof(*req))
{
return -EINVAL;
}
@@ -594,16 +594,16 @@ static inline int userfs_statfs_dispatch(FAR struct
userfs_info_s *info,
/* Dispatch the request */
DEBUGASSERT(info->userops != NULL && info->userops->statfs != NULL);
- memset(&resp.buf, 0, sizeof(struct statfs));
+ memset(&resp.buf, 0, sizeof(resp.buf));
resp.ret = info->userops->statfs(info->volinfo, &resp.buf);
/* Send the response */
resp.resp = USERFS_RESP_STATFS;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_statfs_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -643,9 +643,9 @@ static inline int userfs_unlink_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_UNLINK;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_unlink_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -685,9 +685,9 @@ static inline int userfs_mkdir_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_MKDIR;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_mkdir_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -727,9 +727,9 @@ static inline int userfs_rmdir_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_RMDIR;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_rmdir_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -783,9 +783,9 @@ static inline int userfs_rename_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_RENAME;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_rename_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -825,9 +825,9 @@ static inline int userfs_stat_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_STAT;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_stat_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -839,7 +839,7 @@ static inline int userfs_destroy_dispatch(FAR struct
userfs_info_s *info,
/* Verify the request size */
- if (reqlen != sizeof(struct userfs_destroy_request_s))
+ if (reqlen != sizeof(*req))
{
return -EINVAL;
}
@@ -853,9 +853,9 @@ static inline int userfs_destroy_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_DESTROY;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_destroy_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
if (nsent < 0)
{
int ret = -get_errno();
@@ -880,7 +880,7 @@ static inline int userfs_fchstat_dispatch(FAR struct
userfs_info_s *info,
/* Verify the request size */
- if (reqlen != sizeof(struct userfs_fchstat_request_s))
+ if (reqlen != sizeof(*req))
{
return -EINVAL;
}
@@ -895,9 +895,9 @@ static inline int userfs_fchstat_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_FCHSTAT;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_fchstat_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -938,9 +938,9 @@ static inline int userfs_chstat_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_CHSTAT;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_chstat_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -980,9 +980,9 @@ static inline int userfs_flock_dispatch(FAR struct
userfs_info_s *info,
/* Send the response */
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_flock_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -1010,9 +1010,9 @@ static inline int userfs_notify_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_NOTIFY;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_notify_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
#endif /* CONFIG_FS_NOTIFY */
@@ -1025,7 +1025,7 @@ static inline int userfs_syncfs_dispatch(FAR struct
userfs_info_s *info,
/* Verify the request size */
- if (reqlen != sizeof(struct userfs_syncfs_request_s))
+ if (reqlen != sizeof(*req))
{
return -EINVAL;
}
@@ -1045,9 +1045,9 @@ static inline int userfs_syncfs_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_SYNCFS;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_syncfs_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -1107,9 +1107,9 @@ static inline int userfs_link_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_LINK;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_link_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -1168,9 +1168,9 @@ static inline int userfs_symlink_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_SYMLINK;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_symlink_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -1230,7 +1230,7 @@ static inline int userfs_readlink_dispatch(FAR struct
userfs_info_s *info,
resp->nread > 0 ? resp->nread : 0);
nsent = sendto(info->sockfd, resp, resplen, 0,
(FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
@@ -1277,9 +1277,9 @@ static inline int userfs_lstat_dispatch(FAR struct
userfs_info_s *info,
resp.resp = USERFS_RESP_LSTAT;
nsent = sendto(info->sockfd, &resp,
- sizeof(struct userfs_lstat_response_s),
+ sizeof(resp),
0, (FAR struct sockaddr *)&info->client,
- sizeof(struct sockaddr_in));
+ sizeof(info->client));
return nsent < 0 ? nsent : OK;
}
#endif /* CONFIG_FS_LINKS */
@@ -1370,7 +1370,7 @@ int userfs_run(FAR const char *mountpt,
/* Mounts the user file system at the provided mount point path. */
- ret = mount(NULL, mountpt, "userfs", 0, (FAR const void *)&config);
+ ret = mount(NULL, mountpt, "userfs", 0, &config);
if (ret < 0)
{
ret = -get_errno();
@@ -1395,7 +1395,7 @@ int userfs_run(FAR const char *mountpt,
server.sin_addr.s_addr = HTONL(INADDR_LOOPBACK);
ret = bind(info->sockfd, (struct sockaddr *)&server,
- sizeof(struct sockaddr_in));
+ sizeof(server));
if (ret < 0)
{
ret = -get_errno();
@@ -1412,7 +1412,7 @@ int userfs_run(FAR const char *mountpt,
/* Receive the next file system request */
finfo("Receiving up %u bytes\n", info->iolen);
- addrlen = sizeof(struct sockaddr_in);
+ addrlen = sizeof(info->client);
nread = recvfrom(info->sockfd, info->iobuffer, info->iolen, 0,
(FAR struct sockaddr *)&info->client,
&addrlen);
@@ -1423,7 +1423,7 @@ int userfs_run(FAR const char *mountpt,
goto errout_with_sockfd;
}
- DEBUGASSERT(addrlen == sizeof(struct sockaddr_in));
+ DEBUGASSERT(addrlen == sizeof(info->client));
/* Process the request according to its request ID */