don't add integers to string literals (#410)

* string literal + integer means unintended and incorrect pointer arithmetic

fixes a clang warning. it could not be triggered, because it can only be
triggered if the string given to getopt is not covered among the
cases in the switch.

* handle review comment
This commit is contained in:
Paul Dreik 2019-12-24 20:19:22 +01:00 committed by GitHub
parent 2caac2b218
commit 27293cc1c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -126,7 +126,10 @@ struct option_struct {
}
break;
default:
exit_error("Unexpected argument " + c);
// reaching here means an argument was given to getopt() which did not have a case label
exit_error("Unexpected argument - missing case for option "+
std::string(1,static_cast<char>(c))+
" (programming error)");
}
}
#else