Subject: bug#75755: feature/igc: Missing IGC_CHECK_RES?

From: Pip Cet <[email-masked]>
Date: Wed, 22 Jan 2025 12:18:20 +0000

"Pip Cet" <[email-masked]> writes:

> "Stefan Kangas" <[email-masked]> writes:
>
>> Gerd, do you remember why you didn't add CHECK_RES here?  Was there a
>> reason for that or just an oversight?
>
> My mistake (c6a3eb01f7acf9ccd00b38e0ef2ab05164e48635).  Please fix, or
> I'll do it in a bit.

Fixed.  Thanks again.  Checked the other mps calls, but what I found is
only this:

static const char *
mps_res_to_string (mps_res_t res)
{
  switch (res)
    {
#define RES_CASE(prefix, id, doc)                                            \
  case prefix##id:                                                           \
    return #prefix #id " " doc;
      _mps_RES_ENUM (RES_CASE, MPS_RES_);
#undef RES_CASE
    default:
      return NULL;
    }
}

It would be nice if we could settle on just one function to convert
mps_t to a string, and use it consistently.

My preference would be to add this code before result_string:

/* Define a named enumeration containing all cases that the integer type
   mps_res_t is known to cover.  */

enum mps_res_enum
{
  _mps_RES_ENUM (RES_CASE, MPS_RES_)
};
#undef RES_CASE

then cast to that type in our switch statement, which would remain
explicit, exhaustive, and default-free.

That way, we get warnings if the enum is extended.

Pip