Copilot commented on code in PR #21720:
URL: https://github.com/apache/nuttx/pull/21720#discussion_r4540604263
##########
include/nuttx/fs/userfs.h:
##########
@@ -158,6 +158,7 @@ enum userfs_resp_e
USERFS_RESP_SYNC,
USERFS_RESP_DUP,
USERFS_RESP_FSTAT,
+ USERFS_RESP_TRUNCATE,
USERFS_RESP_OPENDIR,
USERFS_RESP_CLOSEDIR,
USERFS_RESP_READDIR,
Review Comment:
Inserting `USERFS_RESP_TRUNCATE` in the middle of `enum userfs_resp_e`
shifts the numeric values of all later response codes, which changes the
on-the-wire protocol ABI. To keep the protocol stable (and avoid breaking
older/out-of-tree daemons/clients), consider assigning explicit numeric values
to the response codes (at least from this point forward), or append new
response codes at the end and leave existing numeric values unchanged.
##########
fs/userfs/fs_userfs.c:
##########
@@ -561,6 +565,10 @@ static ssize_t userfs_write(FAR struct file *filep, FAR
const char *buffer,
}
nwritten = resp->nwritten;
+ if (nwritten > 0)
+ {
+ filep->f_pos += nwritten;
Review Comment:
These `f_pos` updates add `ssize_t`-typed values (`nread`/`nwritten`) to
`filep->f_pos` (an `off_t`). To avoid implicit signedness/width conversions
(and associated warnings on some configurations), consider casting to `off_t`
in the addition (e.g., `filep->f_pos += (off_t)nread;` / `(off_t)nwritten;`).
##########
fs/userfs/fs_userfs.c:
##########
@@ -469,6 +469,10 @@ static ssize_t userfs_read(FAR struct file *filep, char
*buffer,
memcpy(buffer, resp->rddata, resp->nread);
nread = resp->nread;
+ if (nread > 0)
+ {
+ filep->f_pos += nread;
Review Comment:
These `f_pos` updates add `ssize_t`-typed values (`nread`/`nwritten`) to
`filep->f_pos` (an `off_t`). To avoid implicit signedness/width conversions
(and associated warnings on some configurations), consider casting to `off_t`
in the addition (e.g., `filep->f_pos += (off_t)nread;` / `(off_t)nwritten;`).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]