Skip to content

Commit

Permalink
Remove -Wswitch-enum compiler option.
Browse files Browse the repository at this point in the history
The -Wswitch option included in -Wall provides the same level of coverage and allows enum options to be grouped into default.
  • Loading branch information
dwsteele committed May 15, 2019
1 parent 53f6232 commit 5bba72b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 24 deletions.
4 changes: 4 additions & 0 deletions doc/xml/release.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@
<p>Improve coverage in <file>perl/exec</file>, <file>config/config</file>, and <file>config/parse</file> modules.</p>
</release-item>

<release-item>
<p>Remove <id>-Wswitch-enum</id> compiler option.</p>
</release-item>

<release-item>
<p>Error on multiple option alternate names and simplify help command.</p>
</release-item>
Expand Down
29 changes: 8 additions & 21 deletions src/common/type/variant.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ varEq(const Variant *this1, const Variant *this2)
break;
}

case varTypeKeyValue:
case varTypeVariantList:
default:
THROW_FMT(AssertError, "unable to test equality for %s", variantTypeName[this1->type]);
}
}
Expand Down Expand Up @@ -382,9 +381,7 @@ varBoolForce(const Variant *this)
result = varUInt64(this) != 0;
break;

case varTypeDouble:
case varTypeKeyValue:
case varTypeVariantList:
default:
THROW_FMT(AssertError, "unable to force %s to %s", variantTypeName[this->type], variantTypeName[varTypeBool]);
}

Expand Down Expand Up @@ -484,8 +481,7 @@ varDblForce(const Variant *this)
break;
}

case varTypeKeyValue:
case varTypeVariantList:
default:
THROW_FMT(AssertError, "unable to force %s to %s", variantTypeName[this->type], variantTypeName[varTypeDouble]);
}

Expand Down Expand Up @@ -603,9 +599,7 @@ varIntForce(const Variant *this)
break;
}

case varTypeDouble:
case varTypeKeyValue:
case varTypeVariantList:
default:
THROW_FMT(AssertError, "unable to force %s to %s", variantTypeName[this->type], variantTypeName[varTypeInt]);
}

Expand Down Expand Up @@ -711,9 +705,7 @@ varInt64Force(const Variant *this)
break;
}

case varTypeDouble:
case varTypeKeyValue:
case varTypeVariantList:
default:
THROW_FMT(AssertError, "unable to force %s to %s", variantTypeName[this->type], variantTypeName[varTypeInt64]);
}

Expand Down Expand Up @@ -840,9 +832,7 @@ varUIntForce(const Variant *this)
break;
}

case varTypeDouble:
case varTypeKeyValue:
case varTypeVariantList:
default:
THROW_FMT(AssertError, "unable to force %s to %s", variantTypeName[this->type], variantTypeName[varTypeUInt]);
}

Expand Down Expand Up @@ -958,9 +948,7 @@ varUInt64Force(const Variant *this)
break;
}

case varTypeDouble:
case varTypeKeyValue:
case varTypeVariantList:
default:
THROW_FMT(AssertError, "unable to force %s to %s", variantTypeName[this->type], variantTypeName[varTypeUInt64]);
}

Expand Down Expand Up @@ -1137,8 +1125,7 @@ varStrForce(const Variant *this)
break;
}

case varTypeKeyValue:
case varTypeVariantList:
default:
THROW_FMT(FormatError, "unable to force %s to %s", variantTypeName[this->type], variantTypeName[varTypeString]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/configure
Original file line number Diff line number Diff line change
Expand Up @@ -2799,7 +2799,7 @@ fi
CWARNING=$warning
else
CWARNING="$warning -Wwrite-strings -Wswitch-enum -Wconversion -Wformat=2 -Wformat-nonliteral -Wstrict-prototypes -Wpointer-arith -Wvla"
CWARNING="$warning -Wwrite-strings -Wconversion -Wformat=2 -Wformat-nonliteral -Wstrict-prototypes -Wpointer-arith -Wvla"
fi
Expand Down
2 changes: 1 addition & 1 deletion src/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ then

AC_SUBST(CWARNING, $warning)
else
AC_SUBST(CWARNING, "$warning -Wwrite-strings -Wswitch-enum -Wconversion -Wformat=2 -Wformat-nonliteral -Wstrict-prototypes -Wpointer-arith -Wvla")
AC_SUBST(CWARNING, "$warning -Wwrite-strings -Wconversion -Wformat=2 -Wformat-nonliteral -Wstrict-prototypes -Wpointer-arith -Wvla")
fi

# Set includes
Expand Down
2 changes: 1 addition & 1 deletion test/lib/pgBackRestTest/Common/JobTest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ sub run

# Determine which warnings are available
my $strWarningFlags =
'-Werror -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wswitch-enum -Wconversion -Wformat=2' .
'-Werror -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wconversion -Wformat=2' .
' -Wformat-nonliteral -Wstrict-prototypes -Wpointer-arith -Wvla' .
($self->{oTest}->{&TEST_VM} eq VM_U16 || $self->{oTest}->{&TEST_VM} eq VM_U18 ?
' -Wformat-signedness' : '') .
Expand Down

0 comments on commit 5bba72b

Please sign in to comment.