Skip to content

Commit

Permalink
Settings.cpp: assert that value is given for those command line argum…
Browse files Browse the repository at this point in the history
…ents that require a value
  • Loading branch information
ibc committed Aug 12, 2024
1 parent 5ce4ff8 commit db2252c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions worker/src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ void Settings::SetConfiguration(int argc, char* argv[])
{
case 'l':
{
if (!optarg)
{
MS_THROW_TYPE_ERROR("missing value in command line argument: %s", optarg);
}

stringValue = std::string(optarg);
SetLogLevel(stringValue);

Expand All @@ -89,6 +94,11 @@ void Settings::SetConfiguration(int argc, char* argv[])

case 't':
{
if (!optarg)
{
MS_THROW_TYPE_ERROR("missing value in command line argument: %s", optarg);
}

stringValue = std::string(optarg);
logTags.push_back(stringValue);

Expand All @@ -97,6 +107,11 @@ void Settings::SetConfiguration(int argc, char* argv[])

case 'm':
{
if (!optarg)
{
MS_THROW_TYPE_ERROR("missing value in command line argument: %s", optarg);
}

try
{
Settings::configuration.rtcMinPort = static_cast<uint16_t>(std::stoi(optarg));
Expand All @@ -111,6 +126,11 @@ void Settings::SetConfiguration(int argc, char* argv[])

case 'M':
{
if (!optarg)
{
MS_THROW_TYPE_ERROR("missing value in command line argument: %s", optarg);
}

try
{
Settings::configuration.rtcMaxPort = static_cast<uint16_t>(std::stoi(optarg));
Expand All @@ -125,6 +145,11 @@ void Settings::SetConfiguration(int argc, char* argv[])

case 'c':
{
if (!optarg)
{
MS_THROW_TYPE_ERROR("missing value in command line argument: %s", optarg);
}

stringValue = std::string(optarg);
Settings::configuration.dtlsCertificateFile = stringValue;

Expand All @@ -133,6 +158,11 @@ void Settings::SetConfiguration(int argc, char* argv[])

case 'p':
{
if (!optarg)
{
MS_THROW_TYPE_ERROR("missing value in command line argument: %s", optarg);
}

stringValue = std::string(optarg);
Settings::configuration.dtlsPrivateKeyFile = stringValue;

Expand All @@ -141,6 +171,11 @@ void Settings::SetConfiguration(int argc, char* argv[])

case 'W':
{
if (!optarg)
{
MS_THROW_TYPE_ERROR("missing value in command line argument: %s", optarg);
}

stringValue = std::string(optarg);

if (stringValue != Settings::configuration.libwebrtcFieldTrials)
Expand Down

0 comments on commit db2252c

Please sign in to comment.