[Cbe-oss-dev] [PATCH] libspe2: cast assist call off_t arguments to int
Patrick Mansfield
patmans at us.ibm.com
Wed Jul 18 04:19:52 EST 2007
The cast of assist call arguments from 32 bit unsigned int (in
argn->slot[m]) to an off_t 64 bit signed value are incorrect with 64 bit
libspe, and some casts are missing for the newer assist calls.
This patch casts all off_t assist call arguments to int.
lseek is the worst, without this change it gives incorrect behaviour for
negative offsets.
Only large or negative values for lseek and lockf (negative value is an
error) were tested.
Signed-off-by: Patrick Mansfield <patmans at us.ibm.com>
Index: quilt-libspe2/spebase/default_posix1_handler.c
===================================================================
--- quilt-libspe2.orig/spebase/default_posix1_handler.c
+++ quilt-libspe2/spebase/default_posix1_handler.c
@@ -660,7 +660,7 @@ int default_posix1_handler_lseek(char *l
DEBUG_PRINTF("%s\n", __func__);
fildes = arg0->slot[0];
- offset = (off_t) arg1->slot[0];
+ offset = (int) arg1->slot[0];
whence = arg2->slot[0];
rc = lseek(fildes, offset, whence);
PUT_LS_RC(rc, 0, 0, errno);
@@ -688,7 +688,7 @@ int default_posix1_handler_ftruncate(cha
DEBUG_PRINTF("%s\n", __func__);
fd = arg0->slot[0];
- length = (off_t) arg1->slot[0];
+ length = (int) arg1->slot[0];
rc = ftruncate(fd, length);
PUT_LS_RC(rc, 0, 0, errno);
return 0;
@@ -753,7 +753,7 @@ int default_posix1_handler_mmap(char *ls
prot = arg2->slot[0];
flags = arg3->slot[0];
fd = arg4->slot[0];
- offset = (off_t) arg5->slot[0];
+ offset = (int) arg5->slot[0];
mmap_addr = mmap((void *) ((unsigned long) start.all64),
length, prot, flags, fd, offset);
if (mmap_addr == MAP_FAILED) {
@@ -1790,7 +1790,7 @@ int default_posix1_handler_lockf(char *l
DEBUG_PRINTF("%s\n", __func__);
fd = arg0->slot[0];
cmd = arg1->slot[0];
- len = (off_t) arg2->slot[0];
+ len = (int) arg2->slot[0];
rc = lockf(fd, cmd, len);
PUT_LS_RC(rc, 0, 0, errno);
return 0;
@@ -1814,7 +1814,7 @@ int default_posix1_handler_truncate(char
DEBUG_PRINTF("%s\n", __func__);
path = GET_LS_PTR(arg0->slot[0]);
- length = arg1->slot[0];
+ length = (int) arg1->slot[0];
rc = truncate(path, length);
PUT_LS_RC(rc, 0, 0, errno);
return 0;
@@ -1986,7 +1986,7 @@ int default_posix1_handler_seekdir(char
DEBUG_PRINTF("%s\n", __func__);
dir = spe_reg128toptr(arg0);
- offset = arg1->slot[0];
+ offset = (int) arg1->slot[0];
seekdir(dir, offset);
PUT_LS_RC(0, 0, 0, 0);
return 0;
@@ -2133,7 +2133,7 @@ int default_posix1_handler_pread(char *l
fd = arg0->slot[0];
buf = GET_LS_PTR(arg1->slot[0]);
count = arg2->slot[0];
- offset = arg3->slot[0];
+ offset = (int) arg3->slot[0];
rc = pread(fd, buf, count, offset);
PUT_LS_RC(rc, 0, 0, errno);
return 0;
@@ -2162,7 +2162,7 @@ int default_posix1_handler_pwrite(char *
fd = arg0->slot[0];
buf = GET_LS_PTR(arg1->slot[0]);
count = arg2->slot[0];
- offset = arg3->slot[0];
+ offset = (int) arg3->slot[0];
sz = pwrite(fd, buf, count, offset);
rc = sz;
PUT_LS_RC(rc, 0, 0, errno);
More information about the cbe-oss-dev
mailing list