Skip to content

Commit

Permalink
unistd, sys.socket: fix unsigned ret type when ssize_t required.
Browse files Browse the repository at this point in the history
Fixes #354, Fixes #361
* ext/posix/sys/socket.c (Precv): Don't try to put a negative result
into an unsigned variable.
* ext/posix/unistd.c (Pread): Likewise.
* NEWS.md (Bugs Fized): Updated.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
  • Loading branch information
gvvaughan committed Jun 17, 2023
1 parent a026233 commit aca258a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

### Bugs Fixed

- `posix.unistd.read` and `posix.sys.socket.recv` no longer
hide the underlying real error by casting a ssize_t result
into an unsigned site_t local.

- Fix a typo in the `lflag` argument name in the termios
table LDocs.

Expand Down
3 changes: 2 additions & 1 deletion ext/posix/sys/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,8 @@ static int
Precv(lua_State *L)
{
int fd = checkint(L, 1);
size_t count = (size_t)checkinteger(L, 2), ret;
size_t count = (size_t)checkinteger(L, 2);
ssize_t ret;
void *ud, *buf;
lua_Alloc lalloc;

Expand Down
3 changes: 2 additions & 1 deletion ext/posix/unistd.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,8 @@ static int
Pread(lua_State *L)
{
int fd = checkint(L, 1);
size_t count = (size_t)checkinteger(L, 2), ret;
size_t count = (size_t)checkinteger(L, 2);
ssize_t ret;
void *ud, *buf;
lua_Alloc lalloc;

Expand Down

0 comments on commit aca258a

Please sign in to comment.