changeset: 42:ec7a9e1b5a83
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Tue Mar 06 04:09:20 2007 -0500
summary: Fixed some void pointer arithmatic and fixed some signedness issues.
diff -r 67eac5e46b45 -r ec7a9e1b5a83 ixp.h
--- a/ixp.h Tue Mar 06 03:50:06 2007 -0500
+++ b/ixp.h Tue Mar 06 04:09:20 2007 -0500
@@ -61,18 +61,6 @@ enum { TVERSION = 100,
RWSTAT,
};
-/* borrowed from libc.h of Plan 9 */
-enum { IXP_DMDIR = 0x80000000, /* mode bit for directories */
- IXP_DMAPPEND = 0x40000000, /* mode bit for append only files */
- IXP_DMEXCL = 0x20000000, /* mode bit for exclusive use files */
- IXP_DMMOUNT = 0x10000000, /* mode bit for mounted channel */
- IXP_DMAUTH = 0x08000000, /* mode bit for authentication file */
- IXP_DMTMP = 0x04000000, /* mode bit for non-backed-up file */
- IXP_DMREAD = 0x4<<6, /* mode bit for read permission */
- IXP_DMWRITE = 0x2<<6, /* mode bit for write permission */
- IXP_DMEXEC = 0x1<<6 /* mode bit for execute permission */
-};
-
/* modes */
enum { IXP_OREAD = 0x00,
IXP_OWRITE = 0x01,
diff -r 67eac5e46b45 -r ec7a9e1b5a83 ixpc.c
--- a/ixpc.c Tue Mar 06 03:50:06 2007 -0500
+++ b/ixpc.c Tue Mar 06 04:09:20 2007 -0500
@@ -46,7 +46,7 @@ xcreate(char *file) {
return -1;
}
p++;
- if(ixp_client_create(&c, fid, p, IXP_DMWRITE, IXP_OWRITE) == -1) {
+ if(ixp_client_create(&c, fid, p, P9DMWRITE, P9OWRITE) == -1) {
fprintf(stderr, "ixpc: cannot create file '%s': %s\n", p, c.errstr);
return -1;
}
@@ -75,7 +75,7 @@ xawrite(char *file, uchar mode) {
fprintf(stderr, "ixpc: cannot open file '%s': %s\n", file, c.errstr);
return -1;
}
- if(ixp_client_write(&c, fid, 0, strlen(buffer), buffer) != strlen(buffer))
+ if(ixp_client_write(&c, fid, 0, strlen(buffer), (uchar*)buffer) != strlen(buffer))
fprintf(stderr, "ixpc: cannot write file: %s\n", c.errstr);
return ixp_client_close(&c, fid);
}
@@ -106,7 +106,7 @@ str_of_mode(uint mode) {
str_of_mode(uint mode) {
static char buf[16];
- if(mode & IXP_DMDIR)
+ if(mode & P9DMDIR)
buf[0]='d';
else
buf[0]='-';
@@ -135,7 +135,7 @@ print_stat(Stat *s, int details) {
fprintf(stdout, "%s %s %s %5llu %s %s\n", str_of_mode(s->mode),
s->uid, s->gid, s->length, str_of_time(s->mtime), s->name);
else {
- if(s->mode & IXP_DMDIR)
+ if(s->mode & P9DMDIR)
fprintf(stdout, "%s/\n", s->name);
else
fprintf(stdout, "%s\n", s->name);
@@ -184,19 +184,19 @@ xdir(char *file, int details) {
}
buf = c.ofcall.stat;
ixp_unpack_stat(&buf, NULL, s);
- if(!(s->mode & IXP_DMDIR)) {
+ if(!(s->mode & P9DMDIR)) {
print_stat(s, details);
fflush(stdout);
return 0;
}
/* directory */
- if(ixp_client_open(&c, fid, IXP_OREAD) == -1) {
+ if(ixp_client_open(&c, fid, P9OREAD) == -1) {
fprintf(stderr, "ixpc: cannot open directory '%s': %s\n", file, c.errstr);
return -1;
}
while((count = ixp_client_read(&c, fid, offset, result, IXP_MAX_MSG)) > 0) {
data = ixp_erealloc(data, offset + count);
- memcpy(data + offset, result, count);
+ memcpy((uchar*)data + offset, result, count);
offset += count;
}
if(count == -1) {
@@ -215,7 +215,7 @@ xread(char *file) {
static uchar result[IXP_MAX_MSG];
uvlong offset = 0;
- if(ixp_client_walkopen(&c, fid, file, IXP_OREAD) == -1) {
+ if(ixp_client_walkopen(&c, fid, file, P9OREAD) == -1) {
fprintf(stderr, "ixpc: cannot open file '%s': %s\n", file, c.errstr);
return -1;
}
@@ -279,7 +279,7 @@ main(int argc, char *argv[]) {
else if(!strncmp(cmd, "remove", 7))
ret = xremove(file);
else if(!strncmp(cmd, "write", 6))
- ret = xwrite(file, IXP_OWRITE);
+ ret = xwrite(file, P9OWRITE);
else if(!strncmp(cmd, "xwrite", 7)) {
if(i < argc)
ixp_strlcat(buffer, argv[i++], 1023);
@@ -288,7 +288,7 @@ main(int argc, char *argv[]) {
if(ixp_strlcat(buffer, argv[i++], 1024) > 1023)
break;
}
- ret = xawrite(file, IXP_OWRITE);
+ ret = xawrite(file, P9OWRITE);
}else {
Usage:
ixp_eprint("usage: ixpc [-a <address>] {create | read | ls [-l] | remove | write} <file>\n"
diff -r 67eac5e46b45 -r ec7a9e1b5a83 message.c
--- a/message.c Tue Mar 06 03:50:06 2007 -0500
+++ b/message.c Tue Mar 06 04:09:20 2007 -0500
@@ -28,10 +28,13 @@ ixp_sizeof_stat(Stat * stat) {
uint
ixp_fcall2msg(void *msg, Fcall *fcall, uint msglen) {
- uint i = sizeof(uchar) +
- sizeof(ushort) + sizeof(uint);
- int msize = msglen - i;
- uchar *p = (uchar*)msg + i;
+ int msize;
+ uint i;
+ uchar *p;
+
+ i = sizeof(uchar) + sizeof(ushort) + sizeof(uint);
+ msize = msglen - i;
+ p = (uchar*)msg + i;
switch (fcall->type) {
case TVERSION:
@@ -134,7 +137,9 @@ ixp_msg2fcall(Fcall *fcall, void *msg, u
int msize;
uint i, tsize;
ushort len;
- uchar *p = msg;
+ uchar *p;
+
+ p = msg;
ixp_unpack_prefix(&p, (uint *)&msize, &fcall->type, &fcall->tag);
tsize = msize;
diff -r 67eac5e46b45 -r ec7a9e1b5a83 socket.c
--- a/socket.c Tue Mar 06 03:50:06 2007 -0500
+++ b/socket.c Tue Mar 06 04:09:20 2007 -0500
@@ -90,7 +90,7 @@ create_inet_sock(char *host, char **errs
}
*port = 0;
port++;
- if(sscanf(port, "%d", &prt) != 1) {
+ if(sscanf(port, "%u", &prt) != 1) {
*errstr = "invalid port number";
return -1;
}
diff -r 67eac5e46b45 -r ec7a9e1b5a83 transport.c
--- a/transport.c Tue Mar 06 03:50:06 2007 -0500
+++ b/transport.c Tue Mar 06 04:09:20 2007 -0500
@@ -19,7 +19,7 @@ ixp_send_message(int fd, void *msg, uint
/* send message */
while(num < msize) {
- r = write(fd, msg + num, msize - num);
+ r = write(fd, (uchar*)msg + num, msize - num);
if(r == -1 && errno == EINTR)
continue;
if(r < 1) {
@@ -38,7 +38,7 @@ ixp_recv_data(int fd, void *msg, uint ms
/* receive data */
while(num < msize) {
- r = read(fd, msg + num, msize - num);
+ r = read(fd, (uchar*)msg + num, msize - num);
if(r == -1 && errno == EINTR)
continue;
if(r < 1) {
Received on Tue Mar 06 2007 - 10:09:48 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:56:13 UTC