Bug fix: The lseek methods of IsoFileSource for local filesystem and loaded ISO returned libisofs error codes as positive off_t numbers

This commit is contained in:
Thomas Schmitt 2022-04-26 12:03:53 +02:00
parent da00291519
commit 2af17490a0
2 changed files with 11 additions and 11 deletions

View File

@ -961,18 +961,18 @@ off_t ifs_lseek(IsoFileSource *src, off_t offset, int flag)
ImageFileSourceData *data;
if (src == NULL) {
return (off_t)ISO_NULL_POINTER;
return (off_t)((int) ISO_NULL_POINTER);
}
if (offset < (off_t)0) {
return (off_t)ISO_WRONG_ARG_VALUE;
return (off_t)((int) ISO_WRONG_ARG_VALUE);
}
data = src->data;
if (!data->opened) {
return (off_t)ISO_FILE_NOT_OPENED;
return (off_t)((int) ISO_FILE_NOT_OPENED);
} else if (data->opened != 1) {
return (off_t)ISO_FILE_IS_DIR;
return (off_t)((int) ISO_FILE_IS_DIR);
}
switch (flag) {
@ -987,7 +987,7 @@ off_t ifs_lseek(IsoFileSource *src, off_t offset, int flag)
data->data.offset = data->info.st_size + offset;
break;
default:
return (off_t)ISO_WRONG_ARG_VALUE;
return (off_t)((int) ISO_WRONG_ARG_VALUE);
}
/*

View File

@ -337,7 +337,7 @@ off_t lfs_lseek(IsoFileSource *src, off_t offset, int flag)
int whence;
if (src == NULL) {
return (off_t)ISO_NULL_POINTER;
return (off_t)((int) ISO_NULL_POINTER);
}
switch (flag) {
case 0:
@ -347,7 +347,7 @@ off_t lfs_lseek(IsoFileSource *src, off_t offset, int flag)
case 2:
whence = SEEK_END; break;
default:
return (off_t)ISO_WRONG_ARG_VALUE;
return (off_t)((int) ISO_WRONG_ARG_VALUE);
}
data = src->data;
@ -360,19 +360,19 @@ off_t lfs_lseek(IsoFileSource *src, off_t offset, int flag)
/* error on read */
switch (errno) {
case ESPIPE:
ret = (off_t)ISO_FILE_ERROR;
ret = (off_t)((int) ISO_FILE_ERROR);
break;
default:
ret = (off_t)ISO_ERROR;
ret = (off_t)((int) ISO_ERROR);
break;
}
}
return ret;
}
case 2: /* directory */
return (off_t)ISO_FILE_IS_DIR;
return (off_t)((int) ISO_FILE_IS_DIR);
default:
return (off_t)ISO_FILE_NOT_OPENED;
return (off_t)((int) ISO_FILE_NOT_OPENED);
}
}