This commit is contained in:
twinaphex 2020-01-30 16:35:59 +01:00
parent f785e4b045
commit a034909ae9
11 changed files with 87 additions and 61 deletions

View File

@ -245,7 +245,7 @@ static void *coreaudio_init(const char *device,
#else
comp = AudioComponentFindNext(NULL, &desc);
#endif
if (comp == NULL)
if (!comp)
goto error;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))

View File

@ -448,7 +448,7 @@ static void *xv_init(const video_info_t *video,
g_x11_dpy = XOpenDisplay(NULL);
if (g_x11_dpy == NULL)
if (!g_x11_dpy)
{
RARCH_ERR("[XVideo]: Cannot connect to the X server.\n");
RARCH_ERR("[XVideo]: Check DISPLAY variable and if X is running.\n");

View File

@ -417,7 +417,7 @@ static void android_input_poll_main_cmd(void)
if ((android_app->sensor_state_mask
& (UINT64_C(1) << RETRO_SENSOR_ACCELEROMETER_ENABLE))
&& android_app->accelerometerSensor == NULL)
&& !android_app->accelerometerSensor)
input_sensor_set_state(0,
RETRO_SENSOR_ACCELEROMETER_ENABLE,
android_app->accelerometer_event_rate);

View File

@ -597,7 +597,7 @@ static void iohidmanager_hid_device_add_device(
for (i=0; i<MAX_USERS; i++)
{
struct iohidmanager_hid_adapter *a = (struct iohidmanager_hid_adapter*)hid->slots[i].data;
if (a == NULL)
if (!a)
continue;
if (a->uniqueId == deviceUniqueId)
return;
@ -1003,12 +1003,12 @@ static int iohidmanager_hid_manager_set_device_matching(
|| IOHIDDeviceConformsTo(dev, kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad)
)
{
if ( devList == NULL )
if (!devList)
{
devList = (hid_list_t *)malloc(sizeof(hid_list_t));
devList->device = dev;
devList->lid = iohidmanager_hid_device_get_location_id(dev);
devList->next = NULL;
devList = (hid_list_t *)malloc(sizeof(hid_list_t));
devList->device = dev;
devList->lid = iohidmanager_hid_device_get_location_id(dev);
devList->next = NULL;
}
else
{

View File

@ -424,8 +424,7 @@ static void cpulist_parse(CpuList* list, char **buf, ssize_t length)
q = end;
/* Get first value */
p = parse_decimal(p, q, &start_value);
if (p == NULL)
if (!(p = parse_decimal(p, q, &start_value)))
return;
end_value = start_value;
@ -435,8 +434,7 @@ static void cpulist_parse(CpuList* list, char **buf, ssize_t length)
*/
if (p < q && *p == '-')
{
p = parse_decimal(p+1, q, &end_value);
if (p == NULL)
if (!(p = parse_decimal(p+1, q, &end_value)))
return;
}

View File

@ -63,7 +63,10 @@ static void cdfs_determine_sector_size(cdfs_track_t* track)
static void cdfs_seek_track_sector(cdfs_track_t* track, unsigned int sector)
{
intfstream_seek(track->stream, sector * track->stream_sector_size + track->stream_sector_header_size + track->first_sector_offset, SEEK_SET);
intfstream_seek(track->stream,
sector * track->stream_sector_size +
track->stream_sector_header_size +
track->first_sector_offset, SEEK_SET);
}
void cdfs_seek_sector(cdfs_file_t* file, unsigned int sector)
@ -73,12 +76,12 @@ void cdfs_seek_sector(cdfs_file_t* file, unsigned int sector)
{
if (sector != file->current_sector)
{
file->current_sector = sector;
file->current_sector = sector;
file->sector_buffer_valid = 0;
}
file->pos = file->current_sector * 2048;
file->current_sector_offset = 0;
file->pos = file->current_sector * 2048;
file->current_sector_offset = 0;
}
}
@ -86,8 +89,8 @@ static int cdfs_find_file(cdfs_file_t* file, const char* path)
{
uint8_t buffer[2048], *tmp;
int sector, path_length;
const char* slash = strrchr(path, '\\');
if (slash)
{
/* navigate the path to the directory record for the file */
@ -105,12 +108,13 @@ static int cdfs_find_file(cdfs_file_t* file, const char* path)
{
int offset;
/* find the cd information (always 16 frames in) */
/* find the CD information (always 16 frames in) */
cdfs_seek_track_sector(file->track, 16);
intfstream_read(file->track->stream, buffer, sizeof(buffer));
/* the directory_record starts at 156 bytes into the sector.
* the sector containing the root directory contents is a 3 byte value that is 2 bytes into the directory_record. */
* the sector containing the root directory contents is a
* 3 byte value that is 2 bytes into the directory_record. */
offset = 156 + 2;
sector = buffer[offset] | (buffer[offset + 1] << 8) | (buffer[offset + 2] << 16);
}
@ -120,21 +124,26 @@ static int cdfs_find_file(cdfs_file_t* file, const char* path)
intfstream_read(file->track->stream, buffer, sizeof(buffer));
path_length = strlen(path);
tmp = buffer;
tmp = buffer;
while (tmp < buffer + sizeof(buffer))
{
/* the first byte of the record is the length of the record - if 0, we reached the end of the data */
/* The first byte of the record is the length of
* the record - if 0, we reached the end of the data */
if (!*tmp)
break;
/* filename is 33 bytes into the record and the format is "FILENAME;version" or "DIRECTORY" */
/* filename is 33 bytes into the record and
* the format is "FILENAME;version" or "DIRECTORY" */
if ((tmp[33 + path_length] == ';' || tmp[33 + path_length] == '\0') &&
strncasecmp((const char*)(tmp + 33), path, path_length) == 0)
{
/* the file size is in bytes 10-13 of the record */
file->size = tmp[10] | (tmp[11] << 8) | (tmp[12] << 16) | (tmp[13] << 24);
file->size = tmp[10] | (tmp[11] << 8)
| (tmp[12] << 16) | (tmp[13] << 24);
/* the file contents are in the sector identified in bytes 2-4 of the record */
/* the file contents are in the sector identified
* in bytes 2-4 of the record */
sector = tmp[2] | (tmp[3] << 8) | (tmp[4] << 16);
return sector;
}
@ -153,15 +162,17 @@ int cdfs_open_file(cdfs_file_t* file, cdfs_track_t* track, const char* path)
memset(file, 0, sizeof(*file));
file->track = track;
file->track = track;
file->current_sector = -1;
if (path)
file->first_sector = cdfs_find_file(file, path);
else if (file->track->stream_sector_size)
{
file->first_sector = 0;
file->size = (intfstream_get_size(file->track->stream) / file->track->stream_sector_size) * 2048;
file->size = (intfstream_get_size(
file->track->stream) / file->track->stream_sector_size)
* 2048;
}
else
file->first_sector = -1;
@ -189,12 +200,14 @@ int64_t cdfs_read_file(cdfs_file_t* file, void* buffer, uint64_t len)
{
if (remaining >= len)
{
memcpy(buffer, &file->sector_buffer[file->current_sector_offset], len);
memcpy(buffer,
&file->sector_buffer[file->current_sector_offset], len);
file->current_sector_offset += len;
return len;
}
memcpy(buffer, &file->sector_buffer[file->current_sector_offset], remaining);
memcpy(buffer,
&file->sector_buffer[file->current_sector_offset], remaining);
buffer = (char*)buffer + remaining;
bytes_read += remaining;
len -= remaining;
@ -204,11 +217,11 @@ int64_t cdfs_read_file(cdfs_file_t* file, void* buffer, uint64_t len)
++file->current_sector;
file->current_sector_offset = 0;
file->sector_buffer_valid = 0;
file->sector_buffer_valid = 0;
}
else if (file->current_sector < file->first_sector)
{
file->current_sector = file->first_sector;
file->current_sector = file->first_sector;
file->current_sector_offset = 0;
}
@ -217,8 +230,9 @@ int64_t cdfs_read_file(cdfs_file_t* file, void* buffer, uint64_t len)
cdfs_seek_track_sector(file->track, file->current_sector);
intfstream_read(file->track->stream, buffer, 2048);
buffer = (char*)buffer + 2048;
buffer = (char*)buffer + 2048;
bytes_read += 2048;
++file->current_sector;
len -= 2048;
@ -243,7 +257,8 @@ void cdfs_close_file(cdfs_file_t* file)
{
if (file)
{
/* not really anything to do here, just clear out the first_sector so read() won't do anything */
/* not really anything to do here, just
* clear out the first_sector so read() won't do anything */
file->first_sector = -1;
}
}
@ -314,21 +329,26 @@ static void cdfs_skip_spaces(const char** ptr)
++(*ptr);
}
static cdfs_track_t* cdfs_wrap_stream(intfstream_t* stream, unsigned first_sector_offset)
static cdfs_track_t* cdfs_wrap_stream(
intfstream_t* stream, unsigned first_sector_offset)
{
cdfs_track_t* track;
cdfs_track_t* track = NULL;
if (stream == NULL)
if (!stream)
return NULL;
track = (cdfs_track_t*)calloc(1, sizeof(*track));
track->stream = stream;
track = (cdfs_track_t*)
calloc(1, sizeof(*track));
track->stream = stream;
track->first_sector_offset = first_sector_offset;
cdfs_determine_sector_size(track);
return track;
}
static cdfs_track_t* cdfs_open_cue_track(const char* path, unsigned int track_index)
static cdfs_track_t* cdfs_open_cue_track(
const char* path, unsigned int track_index)
{
char* cue = NULL;
const char* line = NULL;
@ -442,10 +462,9 @@ static cdfs_track_t* cdfs_open_cue_track(const char* path, unsigned int track_in
if (found_track && index_number == 1)
{
if (strstr(current_track_path, "/") || strstr(current_track_path, "\\"))
{
if ( strstr(current_track_path, "/") ||
strstr(current_track_path, "\\"))
strncpy(track_path, current_track_path, sizeof(track_path));
}
else
{
fill_pathname_basedir(track_path, path, sizeof(track_path));
@ -462,7 +481,10 @@ static cdfs_track_t* cdfs_open_cue_track(const char* path, unsigned int track_in
if (string_is_empty(track_path))
return NULL;
track = cdfs_wrap_stream(intfstream_open_file(track_path, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE), track_offset);
track = cdfs_wrap_stream(intfstream_open_file(
track_path, RETRO_VFS_FILE_ACCESS_READ,
RETRO_VFS_FILE_ACCESS_HINT_NONE), track_offset);
if (track && track->stream_sector_size == 0)
{
track->stream_sector_size = sector_size;
@ -482,11 +504,14 @@ static cdfs_track_t* cdfs_open_chd_track(const char* path, int32_t track_index)
intfstream_t* intf_stream;
cdfs_track_t* track;
intf_stream = intfstream_open_chd_track(path, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE, track_index);
intf_stream = intfstream_open_chd_track(path,
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE,
track_index);
if (!intf_stream)
return NULL;
track = cdfs_wrap_stream(intf_stream, intfstream_get_offset_to_start(intf_stream));
track = cdfs_wrap_stream(intf_stream,
intfstream_get_offset_to_start(intf_stream));
if (track && track->stream_sector_header_size == 0)
{
@ -502,7 +527,8 @@ static cdfs_track_t* cdfs_open_chd_track(const char* path, int32_t track_index)
}
#endif
struct cdfs_track_t* cdfs_open_track(const char* path, unsigned int track_index)
struct cdfs_track_t* cdfs_open_track(const char* path,
unsigned int track_index)
{
const char* ext = path_get_extension(path);
@ -538,8 +564,11 @@ cdfs_track_t* cdfs_open_raw_track(const char* path)
{
const char* ext = path_get_extension(path);
if (string_is_equal_noncase(ext, "bin") || string_is_equal_noncase(ext, "iso"))
return cdfs_wrap_stream(intfstream_open_file(path, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE), 0);
if ( string_is_equal_noncase(ext, "bin") ||
string_is_equal_noncase(ext, "iso"))
return cdfs_wrap_stream(intfstream_open_file(path,
RETRO_VFS_FILE_ACCESS_READ,
RETRO_VFS_FILE_ACCESS_HINT_NONE), 0);
/* unsupported file type */
return NULL;

View File

@ -100,7 +100,7 @@ enum rwav_state rwav_iterate(rwav_iterator_t *iter)
samples = malloc(rwav->subchunk2size);
if (samples == NULL)
if (!samples)
return RWAV_ITERATE_ERROR;
rwav->numchannels = data[22] | data[23] << 8;

View File

@ -858,17 +858,17 @@ bool playlist_push(playlist_t *playlist,
* or command line, certain entry values will be missing.
* If we are now loading the same content from a playlist,
* fill in any blanks */
if ((playlist->entries[i].label == NULL) && !string_is_empty(entry->label))
if (!playlist->entries[i].label && !string_is_empty(entry->label))
{
playlist->entries[i].label = strdup(entry->label);
entry_updated = true;
}
if ((playlist->entries[i].crc32 == NULL) && !string_is_empty(entry->crc32))
if (!playlist->entries[i].crc32 && !string_is_empty(entry->crc32))
{
playlist->entries[i].crc32 = strdup(entry->crc32);
entry_updated = true;
}
if ((playlist->entries[i].db_name == NULL) && !string_is_empty(entry->db_name))
if (!playlist->entries[i].db_name && !string_is_empty(entry->db_name))
{
playlist->entries[i].db_name = strdup(entry->db_name);
entry_updated = true;

View File

@ -8702,7 +8702,7 @@ static void core_option_manager_set_display(core_option_manager_t *opt,
#define SYMBOL(x) do { \
function_t func = dylib_proc(lib_handle_local, #x); \
memcpy(&current_core->x, &func, sizeof(func)); \
if (current_core->x == NULL) { RARCH_ERR("Failed to load symbol: \"%s\"\n", #x); retroarch_fail(1, "init_libretro_symbols()"); } \
if (!current_core->x) { RARCH_ERR("Failed to load symbol: \"%s\"\n", #x); retroarch_fail(1, "init_libretro_symbols()"); } \
} while (0)
static dylib_t lib_handle;

View File

@ -141,7 +141,7 @@ void retro_main_log_file_init(const char *path, bool append)
#endif
log_file_fp = stderr;
if (path == NULL)
if (!path)
return;
log_file_fp = (FILE*)fopen_utf8(path, append ? "ab" : "wb");

View File

@ -86,14 +86,13 @@ static bool connmanctl_tether_status(void)
pclose(command_file);
if (ln == NULL)
if (!ln)
return false;
else if (ln[0] == '0')
if (ln[0] == '0')
return false;
else if (ln[0] == '1')
if (ln[0] == '1')
return true;
else
return false;
return false;
}
static void connmanctl_tether_toggle(bool switch_on, char* apname, char* passkey)
@ -582,7 +581,7 @@ static void connmanctl_tether_start_stop(bool start, char* configfile)
pclose(command_file);
}
if (apname == NULL || passkey == NULL)
if (!apname || !passkey)
{
RARCH_ERR("[CONNMANCTL] Tether start stop: APNAME or PASSWORD missing\n");