From ef23ae4bf092e720a1a32e07db397fa3cddc1706 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 16 Jul 2014 17:07:06 +0000 Subject: [PATCH] base: get rid of the ssize_t requirement and use ptrdiff_t instead. --- neercs/old/client.c | 7 ++++--- neercs/old/grab.c | 3 ++- neercs/old/mini-client.c | 2 +- neercs/old/mini-server.c | 2 +- neercs/old/mini-socket.c | 2 +- neercs/old/mini-socket.h | 2 +- neercs/old/mytrace.c | 4 ++-- neercs/old/screens.c | 3 ++- neercs/old/server.c | 7 ++++--- neercs/term/pty.cpp | 2 +- 10 files changed, 19 insertions(+), 15 deletions(-) diff --git a/neercs/old/client.c b/neercs/old/client.c index 5cf5250..f7b3961 100644 --- a/neercs/old/client.c +++ b/neercs/old/client.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -122,7 +123,7 @@ int send_event(caca_event_t ev, struct screen_list *screen_list) } if (bytes) { - ssize_t r; + ptrdiff_t r; buf[bytes] = '\0'; debug("Sending '%s', %d bytes", buf, bytes); r = write(screen_list->comm.socket[SOCK_SERVER], buf, bytes+1); @@ -163,7 +164,7 @@ int mainloop_tick(char **pbuf, struct screen_list *screen_list) { caca_event_t ev; int ret = 0; - ssize_t n; + ptrdiff_t n; if (!screen_list) return 0; if (!*pbuf) @@ -188,7 +189,7 @@ int mainloop_tick(char **pbuf, struct screen_list *screen_list) else if (!strncmp("UPDATE ", *pbuf, 7)) { int x, y; - ssize_t l2 = 0, lb = 0; + ptrdiff_t l2 = 0, lb = 0; char *buf2; size_t l = 0; /* FIXME check the length before calling atoi */ diff --git a/neercs/old/grab.c b/neercs/old/grab.c index cd3501d..35b2385 100644 --- a/neercs/old/grab.c +++ b/neercs/old/grab.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -235,7 +236,7 @@ static int list_process(struct process **process_list) for (j = 0; j < pglob2.gl_pathc; j++) { char path[4096]; - ssize_t l = readlink(pglob2.gl_pathv[j], path, sizeof(path)); + ptrdiff_t l = readlink(pglob2.gl_pathv[j], path, sizeof(path)); if (l <= 0) continue; path[l] = '\0'; diff --git a/neercs/old/mini-client.c b/neercs/old/mini-client.c index 5b234be..5799e9d 100644 --- a/neercs/old/mini-client.c +++ b/neercs/old/mini-client.c @@ -60,7 +60,7 @@ int client_step(void) if (ret > 0) { char buf[BUFSIZ]; - ssize_t bytes = socket_read(insock, buf, BUFSIZ); + ptrdiff_t bytes = socket_read(insock, buf, BUFSIZ); if (bytes <= 0) return 1; diff --git a/neercs/old/mini-server.c b/neercs/old/mini-server.c index 4254b0e..dde21e2 100644 --- a/neercs/old/mini-server.c +++ b/neercs/old/mini-server.c @@ -33,7 +33,7 @@ while (!insock) int server_step(void) { char buf[BUFSIZ]; - ssize_t bytes; + ptrdiff_t bytes; int ret; if (outsock) diff --git a/neercs/old/mini-socket.c b/neercs/old/mini-socket.c index aa3ad94..55eac71 100644 --- a/neercs/old/mini-socket.c +++ b/neercs/old/mini-socket.c @@ -278,7 +278,7 @@ fprintf(stderr, "pid %i sending %i bytes on %s: %s\n", getpid(), (int)strlen(str return ret; } -ssize_t socket_read(nrx_socket_t *sock, void *buf, size_t count) +ptrdiff_t socket_read(nrx_socket_t *sock, void *buf, size_t count) { int ret; ret = read(sock->fd, buf, count); diff --git a/neercs/old/mini-socket.h b/neercs/old/mini-socket.h index bf6ef3a..09c6645 100644 --- a/neercs/old/mini-socket.h +++ b/neercs/old/mini-socket.h @@ -19,6 +19,6 @@ typedef struct nrx_socket nrx_socket_t; nrx_socket_t * socket_open(char const *path, int server); int socket_select(nrx_socket_t *sock, int usecs); int socket_puts(nrx_socket_t *sock, char const *str); -ssize_t socket_read(nrx_socket_t *sock, void *buf, size_t count); +ptrdiff_t socket_read(nrx_socket_t *sock, void *buf, size_t count); void socket_close(nrx_socket_t *socket); diff --git a/neercs/old/mytrace.c b/neercs/old/mytrace.c index c70a99f..b5ea8ae 100644 --- a/neercs/old/mytrace.c +++ b/neercs/old/mytrace.c @@ -331,10 +331,10 @@ int mytrace_exec(struct mytrace *t, char const *command) char *env, *p; long p2, envaddr, argvaddr, envptraddr; char envpath[PATH_MAX + 1]; - ssize_t envsize = 16 * 1024; + ptrdiff_t envsize = 16 * 1024; int ret, fd, l, l2; char *nullp = NULL; - ssize_t r; + ptrdiff_t r; ptrace(PTRACE_SETOPTIONS, t->pid, NULL, PTRACE_O_TRACEEXEC); diff --git a/neercs/old/screens.c b/neercs/old/screens.c index 83e5971..6d48d07 100644 --- a/neercs/old/screens.c +++ b/neercs/old/screens.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -294,7 +295,7 @@ int update_screens_contents(struct screen_list *screen_list) for (;;) { - ssize_t nr; + ptrdiff_t nr; screen_list->screen[i]->buf = realloc(screen_list->screen[i]->buf, diff --git a/neercs/old/server.c b/neercs/old/server.c index 65d0a8b..b59f057 100644 --- a/neercs/old/server.c +++ b/neercs/old/server.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -113,7 +114,7 @@ static int request_refresh(struct screen_list *screen_list) if (screen_list->comm.socket[SOCK_CLIENT]) { size_t bufsize, towrite; - ssize_t written, ret; + ptrdiff_t written, ret; socklen_t optlen = sizeof(bufsize); size_t bytes; void *buf; @@ -149,7 +150,7 @@ static int request_refresh(struct screen_list *screen_list) fcntl(screen_list->comm.socket[SOCK_CLIENT], F_SETFL, 0); while (towrite > 0) { - ssize_t n; + ptrdiff_t n; debug("Wrote %d, %d remaining", written, towrite); n = send_to_client((char *)buf + written, towrite > bufsize ? bufsize : towrite, @@ -197,7 +198,7 @@ static int server_iteration(struct screen_list *screen_list) int eof = 0, refresh; int quit = 0; - ssize_t n; + ptrdiff_t n; char buf[128]; /* Read program output */ diff --git a/neercs/term/pty.cpp b/neercs/term/pty.cpp index 91fd969..751a4cc 100644 --- a/neercs/term/pty.cpp +++ b/neercs/term/pty.cpp @@ -169,7 +169,7 @@ size_t Pty::ReadData(char *data, size_t maxlen) { if (FD_ISSET((int)m_fd, &fdset)) { - ssize_t nr = read((int)m_fd, data, maxlen); + ptrdiff_t nr = read((int)m_fd, data, maxlen); /* Data available but zero-length read: EOF */ if (nr <= 0)