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

From: Stefan Kangas <[email-masked]>
Date: Thu, 23 Jan 2025 15:32:16 -0600

Eli Zaretskii <[email-masked]> writes:

>> Please let me know what you think of my most recent patch.  If you want
>> something different, may I ask that you send a patch?  I don't think
>> I understand if your idea is different from what I posted.  Thanks.
>
> Your patch still uses _mps_RES_ENUM, which is a macro that's not
> supposed to be used outside of MPS.  Isn't that so?  I thought all
> this discussion was how to avoid using that macro, wasn't it?

AFAIU, the patch I proposed removes that macro.  I just now grepped for
_mps_RES_ENUM after applying it, and couldn't find any matches in my
tree.  Are you seeing something different?

To simplify the review, I've attached the patch with a proper commit
message below.  Thanks.
From 154f143f3612461573024bcbac35b916b193ad53 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Thu, 23 Jan 2025 18:52:30 +0100
Subject: [PATCH] Don't use MPS internal macro in mps_res_to_string

* src/igc.c (mps_res_enum): Remove enum.
(mps_res_to_string): Don't use MPS internal macro in
mps_res_to_string.  (Bug#75755)
---
 src/igc.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/src/igc.c b/src/igc.c
index 57c13614f73..b02d29ca4da 100644
--- a/src/igc.c
+++ b/src/igc.c
@@ -252,18 +252,6 @@
 static enum igc_state igc_state = IGC_STATE_INITIAL;
 static void set_state (enum igc_state state);
 
-/* Define a named enumeration containing all cases that the integer type
-   mps_res_t is known to cover.  */
-
-#define RES_CASE(prefix, id, doc)                                            \
-  id,
-
-enum mps_res_enum
-{
-  _mps_RES_ENUM (RES_CASE, MPS_RES_)
-};
-#undef RES_CASE
-
 /* Convert an mps result code into a result string.  This shouldn't
    allocate memory because it's called when a fatal memory management
    error occurs. */
@@ -271,9 +259,7 @@ #define RES_CASE(prefix, id, doc)                                            \
 static const char *
 mps_res_to_string (mps_res_t res)
 {
-  /* mps_res_t is typedef'd to int, we want an enum so GCC warns about
-     new cases.  */
-  switch ((enum mps_res_enum) res)
+  switch (res)
     {
     case MPS_RES_OK:
       return "operation succeeded";
-- 
2.48.1