Skip to content

Commit

Permalink
Don't quit on invalid options
Browse files Browse the repository at this point in the history
  • Loading branch information
complexlogic committed Sep 14, 2022
1 parent 938f5a5 commit 2a13229
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
12 changes: 5 additions & 7 deletions src/easymode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,17 +391,15 @@ int format_handler(void *user, const char *section, const char *name, const char
}

inline void join_paths(std::filesystem::path &p, std::initializer_list<const char*> list)
{
for (const char *item : list) { // Appending null string will cause segfault
if (item == NULL)
return;
}

{
auto it = list.begin();
p = *it;
it++;
for (it; it != list.end(); ++it)
for (it; it != list.end(); ++it) {
if (*it == NULL)
return;
p /= *it;
}
}

static void load_preset(const char *preset)
Expand Down
1 change: 0 additions & 1 deletion src/easymode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class WorkerThread {
std::mutex thread_mutex;
std::thread *thread;
std::condition_variable thread_cv;

};

void easy_mode(int argc, char *argv[]);
Expand Down
4 changes: 0 additions & 4 deletions src/rsgain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,6 @@ static void custom_mode(int argc, char *argv[])
case 'o':
parse_opus_mode(optarg, config.opus_mode);
break;

case '?':
help_custom();
quit(EXIT_FAILURE);

case 'h':
help_custom();
Expand Down
9 changes: 3 additions & 6 deletions src/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ FileType ScanJob::add_directory(std::filesystem::path &path)
std::set<FileType> extensions;
std::vector<std::string> file_list;
FileType file_type;
size_t num_extensions;

// Determine directory filetype
for (const std::filesystem::directory_entry &entry : std::filesystem::directory_iterator(path)) {
Expand All @@ -97,16 +96,14 @@ FileType ScanJob::add_directory(std::filesystem::path &path)
if (file_type != FileType::INVALID)
extensions.insert(file_type);
}
num_extensions = extensions.size();
if (num_extensions != 1)
if (extensions.size() != 1)
return FileType::INVALID;
file_type = *extensions.begin();

// Generate vector of files with directory file type
for (const std::filesystem::directory_entry &entry : std::filesystem::directory_iterator(path)) {
if (!entry.is_regular_file() || !entry.path().has_extension())
continue;
if (determine_filetype(entry.path().extension().string()) == file_type)
if (entry.is_regular_file() && entry.path().has_extension() &&
determine_filetype(entry.path().extension().string()) == file_type)
tracks.push_back(Track(entry.path().string(), file_type));
}
type = file_type;
Expand Down

0 comments on commit 2a13229

Please sign in to comment.