Fix lseek() return value handling

lseek() returns an off_t and not an int, using an int to store and
test the return value means we'll error out when the position in the file
gets past INT_MAX.
This commit is contained in:
Julien BLACHE 2010-02-10 18:19:32 +01:00
parent 2b4f07195a
commit a5a46b8a53
2 changed files with 6 additions and 4 deletions

View File

@ -321,6 +321,7 @@ httpd_stream_file(struct evhttp_request *req, int id)
char buf[64];
int64_t offset;
int64_t end_offset;
off_t pos;
int transcode;
int ret;
@ -447,8 +448,8 @@ httpd_stream_file(struct evhttp_request *req, int id)
}
st->size = sb.st_size;
ret = lseek(st->fd, offset, SEEK_SET);
if (ret < 0)
pos = lseek(st->fd, offset, SEEK_SET);
if (pos == (off_t) -1)
{
DPRINTF(E_LOG, L_HTTPD, "Could not seek into %s: %s\n", mfi->path, strerror(errno));

View File

@ -313,6 +313,7 @@ struct transcode_ctx *
transcode_setup(struct media_file_info *mfi, off_t *est_size)
{
struct transcode_ctx *ctx;
off_t pos;
int hdr_len;
int i;
int ret;
@ -428,8 +429,8 @@ transcode_setup(struct media_file_info *mfi, off_t *est_size)
else
hdr_len = 0;
ret = lseek(ctx->fd, hdr_len, SEEK_SET);
if (ret < 0)
pos = lseek(ctx->fd, hdr_len, SEEK_SET);
if (pos == (off_t) -1)
{
DPRINTF(E_WARN, L_XCODE, "Could not seek: %s\n", strerror(errno));