Reduce variable scope

Also avoid declaring variables of different type, pointer and array, in
the same line.
This commit is contained in:
Christian Göttsche 2021-09-02 22:32:40 +02:00 committed by BenBE
parent b9fdf1c2a1
commit 7891cdc552
2 changed files with 4 additions and 2 deletions

View File

@ -86,8 +86,9 @@ static void Header_addMeterByName(Header* this, const char* name, MeterModeId mo
if (paren) {
int ok = sscanf(paren, "(%10u)", &param); // CPUMeter
if (!ok) {
char* end, dynamic[32] = {0};
char dynamic[32] = {0};
if (sscanf(paren, "(%30s)", dynamic)) { // DynamicMeter
char* end;
if ((end = strrchr(dynamic, ')')) == NULL)
return; // htoprc parse failure
*end = '\0';

View File

@ -134,8 +134,9 @@ static void Settings_readFields(Settings* settings, const char* line) {
}
// Dynamically-defined columns are always stored by-name.
char* end, dynamic[32] = {0};
char dynamic[32] = {0};
if (sscanf(ids[i], "Dynamic(%30s)", dynamic)) {
char* end;
if ((end = strrchr(dynamic, ')')) == NULL)
continue;
*end = '\0';