mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-30 05:39:12 +02:00
Add asserts to default switch cases in common/type/variant module.
This matches how switch is used in other parts of the code and prevents invalid values from being processed normally.
This commit is contained in:
parent
ad8e92a9ac
commit
273d5050f8
@ -188,6 +188,7 @@ varEq(const Variant *this1, const Variant *this2)
|
||||
break;
|
||||
|
||||
default:
|
||||
ASSERT(varType(this1) == varTypeKeyValue || varType(this1) == varTypeVariantList);
|
||||
THROW_FMT(AssertError, "unable to test equality for %s", variantTypeName[varType(this1)]);
|
||||
}
|
||||
}
|
||||
@ -298,6 +299,7 @@ varBoolForce(const Variant *this)
|
||||
break;
|
||||
|
||||
default:
|
||||
ASSERT(varType(this) == varTypeKeyValue || varType(this) == varTypeVariantList);
|
||||
THROW_FMT(AssertError, "unable to force %s to %s", variantTypeName[varType(this)], variantTypeName[varTypeBool]);
|
||||
}
|
||||
|
||||
@ -410,6 +412,7 @@ varIntForce(const Variant *this)
|
||||
}
|
||||
|
||||
default:
|
||||
ASSERT(varType(this) == varTypeKeyValue || varType(this) == varTypeVariantList);
|
||||
THROW_FMT(AssertError, "unable to force %s to %s", variantTypeName[varType(this)], variantTypeName[varTypeInt]);
|
||||
}
|
||||
|
||||
@ -506,6 +509,7 @@ varInt64Force(const Variant *this)
|
||||
}
|
||||
|
||||
default:
|
||||
ASSERT(varType(this) == varTypeKeyValue || varType(this) == varTypeVariantList);
|
||||
THROW_FMT(AssertError, "unable to force %s to %s", variantTypeName[varType(this)], variantTypeName[varTypeInt64]);
|
||||
}
|
||||
|
||||
@ -627,6 +631,7 @@ varUIntForce(const Variant *this)
|
||||
break;
|
||||
|
||||
default:
|
||||
ASSERT(varType(this) == varTypeKeyValue || varType(this) == varTypeVariantList);
|
||||
THROW_FMT(AssertError, "unable to force %s to %s", variantTypeName[varType(this)], variantTypeName[varTypeUInt]);
|
||||
}
|
||||
|
||||
@ -735,6 +740,7 @@ varUInt64Force(const Variant *this)
|
||||
break;
|
||||
|
||||
default:
|
||||
ASSERT(varType(this) == varTypeKeyValue || varType(this) == varTypeVariantList);
|
||||
THROW_FMT(AssertError, "unable to force %s to %s", variantTypeName[varType(this)], variantTypeName[varTypeUInt64]);
|
||||
}
|
||||
|
||||
@ -934,6 +940,7 @@ varStrForce(const Variant *this)
|
||||
}
|
||||
|
||||
default:
|
||||
ASSERT(varType(this) == varTypeKeyValue || varType(this) == varTypeVariantList);
|
||||
THROW_FMT(FormatError, "unable to force %s to %s", variantTypeName[varType(this)], variantTypeName[varTypeString]);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user