瀏覽代碼

base: get rid of the ssize_t requirement and use ptrdiff_t instead.

master
Sam Hocevar 10 年之前
父節點
當前提交
ef23ae4bf0
共有 10 個文件被更改,包括 19 次插入15 次删除
  1. +4
    -3
      neercs/old/client.c
  2. +2
    -1
      neercs/old/grab.c
  3. +1
    -1
      neercs/old/mini-client.c
  4. +1
    -1
      neercs/old/mini-server.c
  5. +1
    -1
      neercs/old/mini-socket.c
  6. +1
    -1
      neercs/old/mini-socket.h
  7. +2
    -2
      neercs/old/mytrace.c
  8. +2
    -1
      neercs/old/screens.c
  9. +4
    -3
      neercs/old/server.c
  10. +1
    -1
      neercs/term/pty.cpp

+ 4
- 3
neercs/old/client.c 查看文件

@@ -21,6 +21,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
@@ -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 */


+ 2
- 1
neercs/old/grab.c 查看文件

@@ -26,6 +26,7 @@
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
@@ -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';


+ 1
- 1
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;



+ 1
- 1
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)


+ 1
- 1
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);


+ 1
- 1
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);


+ 2
- 2
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);



+ 2
- 1
neercs/old/screens.c 查看文件

@@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/wait.h>
@@ -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,


+ 4
- 3
neercs/old/server.c 查看文件

@@ -21,6 +21,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
@@ -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 */


+ 1
- 1
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)


Loading…
取消
儲存