Skip to content

Commit

Permalink
remove unneeded void* casts, and fix gcc -pedantic warnings
Browse files Browse the repository at this point in the history
git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@1366 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information
vinoski committed Jan 25, 2009
1 parent 8054c71 commit c76f1ba
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions c_src/yaws_sendfile_drv.c
Expand Up @@ -156,15 +156,15 @@ static void yaws_sendfile_drv_output(ErlDrvData handle, char* buf, int buflen)
int out_buflen = set_error_buffer(&b, socket_fd, errno);
driver_output(d->port, buf, out_buflen);
} else {
Transfer* xfer = (Transfer*)hashtable_search(d->xfer_table, *(void**)&socket_fd);
Transfer* xfer = (Transfer*)hashtable_search(d->xfer_table, &socket_fd);
if (xfer == NULL) {
xfer = (Transfer*)malloc(sizeof(Transfer));
if (xfer == NULL) {
int out_buflen = set_error_buffer(&b, socket_fd, ENOMEM);
driver_output(d->port, buf, out_buflen);
return;
}
if (!hashtable_insert(d->xfer_table, *(void**)&socket_fd, xfer)) {
if (!hashtable_insert(d->xfer_table, &socket_fd, xfer)) {
int out_buflen = set_error_buffer(&b, socket_fd, ENOMEM);
driver_output(d->port, buf, out_buflen);
free(xfer);
Expand All @@ -185,14 +185,16 @@ static void yaws_sendfile_drv_ready_output(ErlDrvData handle, ErlDrvEvent ev)
{
Desc* d = (Desc*)handle;
int socket_fd = *(int*)&ev;
Transfer* xfer = (Transfer*)hashtable_search(d->xfer_table, *(void**)&socket_fd);
ssize_t result;
off_t cur_offset;
Transfer* xfer = (Transfer*)hashtable_search(d->xfer_table, &socket_fd);
if (xfer == NULL) {
/* fatal error, something is very wrong */
driver_failure_atom(d->port, "socket_fd_not_found");
return;
}
off_t cur_offset = xfer->offset;
ssize_t result = yaws_sendfile_call(socket_fd, xfer->file_fd, &xfer->offset, xfer->count);
cur_offset = xfer->offset;
result = yaws_sendfile_call(socket_fd, xfer->file_fd, &xfer->offset, xfer->count);
if (result < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
off_t written = xfer->offset - cur_offset;
xfer->count -= written;
Expand Down

0 comments on commit c76f1ba

Please sign in to comment.