The return types of read(2) and write(2) are actually ssize_t and not int.
This causes a compilation error on clang, but just a warning on gcc.
I can't create a pull request so here's a diff:
diff --git a/src/dj.c b/src/dj.c
index d5bd59c..8a982fa 100644
--- a/src/dj.c
+++ b/src/dj.c
@@ -199,7 +199,7 @@ Io_fdopen(struct Io *io, char *fn){
* be set to zero to indicate the seek occurred. */
static int
Io_fdseek(struct Io *io){
- int (*op)(int, void *, size_t);
+ ssize_t (*op)(int, void *, size_t);
if(!fdisstd(io->fd) && lseek(io->fd, io->seek, SEEK_SET) != -1)
return -1;
@@ -209,7 +209,7 @@ Io_fdseek(struct Io *io){
* likewise, because the parameters to read or write are going to be
* the same either way, just use a function pointer to keep track of
* the intended operation. */
- op = (int (*)(int, void *, size_t))&write;
+ op = (ssize_t (*)(int, void *, size_t))&write;
/* Function pointer casts are risky; this works because the difference
* is in the second parameter and only that write(2) makes the buffer
* const whereas read(2) does not. To avoid even the slightest
The return types of `read(2)` and `write(2)` are actually `ssize_t` and not `int`.
This causes a compilation error on clang, but just a warning on gcc.
I can't create a pull request so here's a diff:
```diff
diff --git a/src/dj.c b/src/dj.c
index d5bd59c..8a982fa 100644
--- a/src/dj.c
+++ b/src/dj.c
@@ -199,7 +199,7 @@ Io_fdopen(struct Io *io, char *fn){
* be set to zero to indicate the seek occurred. */
static int
Io_fdseek(struct Io *io){
- int (*op)(int, void *, size_t);
+ ssize_t (*op)(int, void *, size_t);
if(!fdisstd(io->fd) && lseek(io->fd, io->seek, SEEK_SET) != -1)
return -1;
@@ -209,7 +209,7 @@ Io_fdseek(struct Io *io){
* likewise, because the parameters to read or write are going to be
* the same either way, just use a function pointer to keep track of
* the intended operation. */
- op = (int (*)(int, void *, size_t))&write;
+ op = (ssize_t (*)(int, void *, size_t))&write;
/* Function pointer casts are risky; this works because the difference
* is in the second parameter and only that write(2) makes the buffer
* const whereas read(2) does not. To avoid even the slightest
```
I should just drop the function pointer magic and use an if - working around type differences there (on which this is further elaborated in the surrounding comments) has caused me enough grief as-is.
I should just drop the function pointer magic and use an `if` - working around type differences there (on which this is further elaborated in the surrounding comments) has caused me enough grief as-is.
trinity
added the bug label 2024-02-18 13:41:26 -07:00
trinity
self-assigned this 2024-02-18 13:41:31 -07:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
The return types of
read(2)andwrite(2)are actuallyssize_tand notint.This causes a compilation error on clang, but just a warning on gcc.
I can't create a pull request so here's a diff:
I should just drop the function pointer magic and use an
if- working around type differences there (on which this is further elaborated in the surrounding comments) has caused me enough grief as-is.On a side note - you can't create a pull request? Is this issue on your end or ours?
Could you test the pull request and confirm it builds?