More linting in src/cdrom

This commit is contained in:
Jasmine Iwanek
2023-08-21 20:22:09 -04:00
parent 6f4a3ebb9e
commit 12070eb62a
3 changed files with 100 additions and 98 deletions

View File

@@ -68,24 +68,24 @@ cdrom_image_backend_log(const char *fmt, ...)
/* Binary file functions. */
static int
bin_read(void *p, uint8_t *buffer, uint64_t seek, size_t count)
bin_read(void *priv, uint8_t *buffer, uint64_t seek, size_t count)
{
track_file_t *tf = (track_file_t *) p;
track_file_t *tf = (track_file_t *) priv;
cdrom_image_backend_log("CDROM: binary_read(%08lx, pos=%" PRIu64 " count=%lu\n",
tf->file, seek, count);
if (tf->file == NULL)
if (tf->fp == NULL)
return 0;
if (fseeko64(tf->file, seek, SEEK_SET) == -1) {
if (fseeko64(tf->fp, seek, SEEK_SET) == -1) {
#ifdef ENABLE_CDROM_IMAGE_BACKEND_LOG
cdrom_image_backend_log("CDROM: binary_read failed during seek!\n");
#endif
return 0;
}
if (fread(buffer, count, 1, tf->file) != 1) {
if (fread(buffer, count, 1, tf->fp) != 1) {
#ifdef ENABLE_CDROM_IMAGE_BACKEND_LOG
cdrom_image_backend_log("CDROM: binary_read failed during read!\n");
#endif
@@ -96,39 +96,39 @@ bin_read(void *p, uint8_t *buffer, uint64_t seek, size_t count)
}
static uint64_t
bin_get_length(void *p)
bin_get_length(void *priv)
{
off64_t len;
track_file_t *tf = (track_file_t *) p;
track_file_t *tf = (track_file_t *) priv;
cdrom_image_backend_log("CDROM: binary_length(%08lx)\n", tf->file);
if (tf->file == NULL)
if (tf->fp == NULL)
return 0;
fseeko64(tf->file, 0, SEEK_END);
len = ftello64(tf->file);
fseeko64(tf->fp, 0, SEEK_END);
len = ftello64(tf->fp);
cdrom_image_backend_log("CDROM: binary_length(%08lx) = %" PRIu64 "\n", tf->file, len);
return len;
}
static void
bin_close(void *p)
bin_close(void *priv)
{
track_file_t *tf = (track_file_t *) p;
track_file_t *tf = (track_file_t *) priv;
if (tf == NULL)
return;
if (tf->file != NULL) {
fclose(tf->file);
tf->file = NULL;
if (tf->fp != NULL) {
fclose(tf->fp);
tf->fp = NULL;
}
memset(tf->fn, 0x00, sizeof(tf->fn));
free(p);
free(priv);
}
static track_file_t *
@@ -144,14 +144,14 @@ bin_init(const char *filename, int *error)
memset(tf->fn, 0x00, sizeof(tf->fn));
strncpy(tf->fn, filename, sizeof(tf->fn) - 1);
tf->file = plat_fopen64(tf->fn, "rb");
tf->fp = plat_fopen64(tf->fn, "rb");
cdrom_image_backend_log("CDROM: binary_open(%s) = %08lx\n", tf->fn, tf->file);
if (stat(tf->fn, &stats) != 0) {
/* Use a blank structure if stat failed. */
memset(&stats, 0, sizeof(struct stat));
}
*error = ((tf->file == NULL) || ((stats.st_mode & S_IFMT) == S_IFDIR));
*error = ((tf->fp == NULL) || ((stats.st_mode & S_IFMT) == S_IFDIR));
/* Set the function pointers. */
if (!*error) {
@@ -162,7 +162,7 @@ bin_init(const char *filename, int *error)
/* From the check above, error may still be non-zero if opening a directory.
* The error is set for viso to try and open the directory following this function.
* However, we need to make sure the descriptor is closed. */
if ((tf->file != NULL) && ((stats.st_mode & S_IFMT) == S_IFDIR)) {
if ((tf->fp != NULL) && ((stats.st_mode & S_IFMT) == S_IFDIR)) {
/* tf is freed by bin_close */
bin_close(tf);
} else {
@@ -203,7 +203,7 @@ static void
cdi_clear_tracks(cd_img_t *cdi)
{
const track_file_t *last = NULL;
track_t *cur = NULL;
track_t *cur = NULL;
if ((cdi->tracks == NULL) || (cdi->tracks_num == 0))
return;