On Thu, 2023-09-21 at 16:19 +0200, Pablo Neira Ayuso wrote: > On Wed, Sep 20, 2023 at 09:28:29PM +0200, Thomas Haller wrote: > > > > The check "if (value > (uint32_t) EXPR_MAX)" is only here to ensure > > that nothing is lost while casting the uint32_t "value" to the enum > > expr_types. > > Is this cast really required? This is to handle the hypothetical case > where EXPR_MAX ever gets a negative value? > EXPR_MAX is never negative. If EXPR_MAX is treated as a signed integer, then it will be implicitly cast to unsigned when comparing with the uint32_t. The behavior will be correct without a cast. But won't the compiler warn about comparing integers of different signedness? The cast is probably not needed. But it doesn't hurt. Thomas