NewOS read/write hooks return ssize_t, but on BeOS, they return status_t and

the number of bytes read/written in an argument. Until now, we had a buggy
mix between those two solutions. Courtesy of Jack Burton.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7102 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-03-29 12:41:32 +00:00
parent 264a5adff5
commit 0ca4e4b56d
2 changed files with 22 additions and 20 deletions
@@ -124,21 +124,21 @@ static status_t
mouse_open(const char *name, uint32 flags, void **cookie)
{
*cookie = NULL;
return 0;
return B_OK;
}
static status_t
mouse_close(void * cookie)
{
return 0;
return B_OK;
}
static status_t
static status_t
mouse_freecookie(void * cookie)
{
return 0;
return B_OK;
}
@@ -150,23 +150,23 @@ mouse_freecookie(void * cookie)
* len, buffer size, must be at least the size of the data packet
*/
static ssize_t
static status_t
mouse_read(void *cookie, off_t pos, void *buf, size_t *len)
{
// inform interrupt handler that data is being waited for
in_read = true;
// inform interrupt handler that data is being waited for
in_read = true;
// wait until there is data to read
if(acquire_sem_etc(mouse_sem, 1, B_CAN_INTERRUPT, 0) ==
EINTR) {
return 0;
} // if
// wait until there is data to read
if (acquire_sem_etc(mouse_sem, 1, B_CAN_INTERRUPT, 0) == B_INTERRUPTED) {
*len = 0;
return B_OK;
}
// verify user's buffer is of the right size
if(*len < PACKET_SIZE) {
if (*len < PACKET_SIZE) {
*len = 0;
/* XXX - should return an error here */
return 0;
return B_OK;
}
// copy data to user's buffer
@@ -175,11 +175,11 @@ mouse_read(void *cookie, off_t pos, void *buf, size_t *len)
((char*)buf)[2] = md_read.delta_y;
*len = PACKET_SIZE;
return 0;
return B_OK;
}
static ssize_t
static status_t
mouse_write(void * cookie, off_t pos, const void *buf, size_t *len)
{
*len = 0;
+6 -4
View File
@@ -33,8 +33,8 @@ static const char *sRandomNames[] = {
};
static status_t random_open(const char *name, uint32 flags, void **cookie);
static ssize_t random_read(void *cookie, off_t position, void *_buffer, size_t *_numBytes);
static ssize_t random_write(void *cookie, off_t position, const void *buffer, size_t *_numBytes);
static status_t random_read(void *cookie, off_t position, void *_buffer, size_t *_numBytes);
static status_t random_write(void *cookie, off_t position, const void *buffer, size_t *_numBytes);
static status_t random_control(void *cookie, uint32 op, void *arg, size_t length);
static status_t random_close(void *cookie);
static status_t random_free(void *cookie);
@@ -353,6 +353,7 @@ publish_devices(void)
return sRandomNames;
}
device_hooks *
find_device(const char* name)
{
@@ -388,7 +389,7 @@ random_open(const char *name, uint32 flags, void **cookie)
}
static ssize_t
static status_t
random_read(void *cookie, off_t position, void *_buffer, size_t *_numBytes)
{
int32 *buffer = (int32 *)_buffer;
@@ -413,11 +414,12 @@ random_read(void *cookie, off_t position, void *_buffer, size_t *_numBytes)
buffer8[(i*4) + j] = chrand8(sRandomEnv);
release_sem(sRandomSem);
return B_OK;
}
static ssize_t
static status_t
random_write(void *cookie, off_t position, const void *buffer, size_t *_numBytes)
{
return B_OK;