From 50b838d8ed43f6e6df7e49fc5f2bea1d36f20a0b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 30 Jul 2017 10:11:41 +0200 Subject: [PATCH] Cleanups --- tasks/task_database.c | 8 ++++---- tasks/task_database_cue.c | 23 ++++++++++++----------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/tasks/task_database.c b/tasks/task_database.c index 1c0bc34bed..1a28754fb6 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -142,18 +142,18 @@ static int iso_get_serial(database_state_handle_t *db_state, { const char* system_name = NULL; - // Check if the system was not auto-detected. + /* Check if the system was not auto-detected. */ if (detect_system(name, &system_name) < 0) { - // Attempt to read an ASCII serial, like Wii. + /* Attempt to read an ASCII serial, like Wii. */ if (detect_serial_ascii_game(name, serial)) { - // ASCII serial (Wii) was detected. + /* ASCII serial (Wii) was detected. */ RARCH_LOG("%s '%s'\n", msg_hash_to_str(MSG_FOUND_DISK_LABEL), serial); return 0; } - // Any other non-system specific detection methods? + /* Any other non-system specific detection methods? */ return 0; } diff --git a/tasks/task_database_cue.c b/tasks/task_database_cue.c index 5990dcd3a4..738dc30b13 100644 --- a/tasks/task_database_cue.c +++ b/tasks/task_database_cue.c @@ -338,7 +338,7 @@ int detect_serial_ascii_game(const char *track_path, char *game_id) bool rv = false; RFILE *fd = filestream_open(track_path, RFILE_MODE_READ, -1); - // Attempt to load the file. + /* Attempt to load the file. */ if (!fd) { RARCH_LOG("%s: %s\n", @@ -352,23 +352,24 @@ int detect_serial_ascii_game(const char *track_path, char *game_id) filestream_seek(fd, pos, SEEK_SET); if (filestream_read(fd, game_id, 10000) > 0) { + unsigned i; game_id[15] = '\0'; numberOfAscii = 0; - // Loop through until we run out of ASCII characters. - for (int i = 0; i < 15; i++) { - // Is the given character ASCII? A-Z, 0-9, - - if (game_id[i] == 45 || (game_id[i] >= 48 && game_id[i] <= 57) || (game_id[i] >= 65 && game_id[i] <= 90)) { + /* Loop through until we run out of ASCII characters. */ + for (i = 0; i < 15; i++) + { + /* Is the given character ASCII? A-Z, 0-9, - */ + if (game_id[i] == 45 || (game_id[i] >= 48 && game_id[i] <= 57) || (game_id[i] >= 65 && game_id[i] <= 90)) numberOfAscii++; - } - else { + else break; - } } - // If the length of the text is between 3 and 9 characters, it could be a serial. - if (numberOfAscii > 3 && numberOfAscii < 9) { - // Cut the string off, and return it as a valid serial. + /* If the length of the text is between 3 and 9 characters, it could be a serial. */ + if (numberOfAscii > 3 && numberOfAscii < 9) + { + /* Cut the string off, and return it as a valid serial. */ game_id[numberOfAscii] = '\0'; rv = true; break;