]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
I guess we just can't use an enum for flag fields anymore...
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 7 Sep 2019 05:19:55 +0000 (00:19 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 7 Sep 2019 05:19:55 +0000 (00:19 -0500)
src/lib/unlang/foreach.c
src/lib/unlang/interpret.c
src/lib/unlang/return.c
src/lib/unlang/unlang_priv.h

index 8dd0891decab042558bc92e470a059caee852a88..c2ca43a0d241cc8df3d3e5c9870a7e7f8ef3bc0f 100644 (file)
@@ -185,15 +185,14 @@ static unlang_action_t unlang_break(REQUEST *request, rlm_rcode_t *presult, int
 
        RDEBUG2("%s", unlang_ops[instruction->type].name);
 
+       *presult = frame->result;
+       *priority = frame->priority;
+
        /*
         *      Stop at the next break point, or if we hit
         *      the a top frame.
         */
-       stack->unwind = UNWIND_FLAG_BREAK_POINT | UNWIND_FLAG_TOP_FRAME;
-
-       *presult = frame->result;
-       *priority = frame->priority;
-
+       UNWIND_TO_BREAK(stack);
        return UNLANG_ACTION_UNWIND;
 }
 
index a367bafe858972e5ba492f3ea5c646b4229c8915..f0808d52f0a97d1527312f5db082f4fe74b10e22 100644 (file)
@@ -484,7 +484,7 @@ static inline unlang_frame_action_t frame_eval(REQUEST *request, unlang_stack_fr
                do_stop:
                        frame->result = RLM_MODULE_FAIL;
                        frame->priority = 9999;
-                       stack->unwind = UNWIND_FLAG_TOP_FRAME | UNWIND_FLAG_NO_CLEAR;
+                       UNWIND_ALL(stack);
                        break;
                }
 
index 5454af820a59a91b1a68777330b4af484e39623e..4f0feea6c3727ea0d357c4669bcaefeda4bf060a 100644 (file)
@@ -35,15 +35,14 @@ unlang_action_t unlang_return(REQUEST *request, rlm_rcode_t *presult, int *prior
 
        RDEBUG2("%s", unlang_ops[instruction->type].name);
 
+       *presult = frame->result;
+       *priority = frame->priority;
+
        /*
         *      Stop at the next return point, or if we hit
         *      the a top frame.
         */
-       stack->unwind = UNWIND_FLAG_RETURN_POINT | UNWIND_FLAG_TOP_FRAME;
-
-       *presult = frame->result;
-       *priority = frame->priority;
-
+       UNWIND_TO_RETURN(stack);
        return UNLANG_ACTION_UNWIND;
 }
 
index 2d88568630adf597511e11e2f425e4bfd86d9e65..4c6229c2faa88fc4f4e98b0481cf924f64457499 100644 (file)
@@ -234,39 +234,36 @@ typedef struct {
        unlang_t                *found;
 } unlang_frame_state_redundant_t;
 
-typedef enum {
-       UNWIND_FLAG_NONE                = 0x00,                 //!< No flags.
-       UNWIND_FLAG_REPEAT              = 0x01,                 //!< Repeat the frame on the way up the stack.
-       UNWIND_FLAG_TOP_FRAME           = 0x02,                 //!< are we the top frame of the stack?
+#define UNWIND_FLAG_NONE               0x00                    //!< No flags.
+#define UNWIND_FLAG_REPEAT             0x01                    //!< Repeat the frame on the way up the stack.
+#define UNWIND_FLAG_TOP_FRAME          0x02                    //!< are we the top frame of the stack?
                                                                ///< If true, causes the interpreter to stop
                                                                ///< interpreting and return, control then passes
                                                                ///< to whatever called the interpreter.
-       UNWIND_FLAG_BREAK_POINT         = 0x04,                 //!< 'break' stops here.
-       UNWIND_FLAG_RETURN_POINT        = 0x08,                 //!< 'return' stops here.
-       UNWIND_FLAG_NO_CLEAR            = 0x10,                 //!< Keep unwinding, don't clear the unwind flag.
-       UNWIND_FLAG_MAX                 = 0xff
-} unlang_unwind_flags_t;
+#define UNWIND_FLAG_BREAK_POINT                0x04                    //!< 'break' stops here.
+#define UNWIND_FLAG_RETURN_POINT       0x08                    //!< 'return' stops here.
+#define UNWIND_FLAG_NO_CLEAR           0x10                    //!< Keep unwinding, don't clear the unwind flag.
+
 
 #define repeatable_set(_frame)         ((_frame)->uflags |= UNWIND_FLAG_REPEAT)
 #define top_frame_set(_frame)          ((_frame)->uflags |= UNWIND_FLAG_TOP_FRAME)
 #define break_point_set(_frame)                ((_frame)->uflags |= UNWIND_FLAG_BREAK_POINT)
 #define return_point_set(_frame)       ((_frame)->uflags |= UNWIND_FLAG_RETURN_POINT)
 
-/*
- *     clang doesn't like the fact that the masks
- *     are outside the range of values the enum
- *     can represent *sigh*
- */
-#define repeatable_clear(_frame)       ((_frame)->uflags) -= (((_frame)->uflags) & UNWIND_FLAG_REPEAT)
-#define top_frame_clear(_frame)                ((_frame)->uflags) -= (((_frame)->uflags) & UNWIND_FLAG_TOP_FRAME)
-#define break_point_clear(_frame)      ((_frame)->uflags) -= (((_frame)->uflags) & UNWIND_FLAG_BREAK_POINT)
-#define return_point_clear(_frame)     ((_frame)->uflags) -= (((_frame)->uflags) & UNWIND_FLAG_RETURN_POINT)
+#define repeatable_clear(_frame)       ((_frame)->uflags) &= ~UNWIND_FLAG_REPEAT
+#define top_frame_clear(_frame)                ((_frame)->uflags) &= ~UNWIND_FLAG_TOP_FRAME
+#define break_point_clear(_frame)      ((_frame)->uflags) &= ~UNWIND_FLAG_BREAK_POINT
+#define return_point_clear(_frame)     ((_frame)->uflags) &= ~UNWIND_FLAG_RETURN_POINT
 
 #define is_repeatable(_frame)          ((_frame)->uflags & UNWIND_FLAG_REPEAT)
 #define is_top_frame(_frame)           ((_frame)->uflags & UNWIND_FLAG_TOP_FRAME)
 #define is_break_point(_frame)         ((_frame)->uflags & UNWIND_FLAG_BREAK_POINT)
 #define is_return_point(_frame)        ((_frame)->uflags & UNWIND_FLAG_RETURN_POINT)
 
+#define UNWIND_TO_BREAK(_stack)                ((_stack)->unwind = (UNWIND_FLAG_BREAK_POINT | UNWIND_FLAG_TOP_FRAME))
+#define UNWIND_TO_RETURN(_stack)       ((_stack)->unwind = (UNWIND_FLAG_RETURN_POINT | UNWIND_FLAG_TOP_FRAME))
+#define UNWIND_ALL(_stack)             ((_stack)->unwind = (UNWIND_FLAG_TOP_FRAME | UNWIND_FLAG_NO_CLEAR))
+
 /** Our interpreter stack, as distinct from the C stack
  *
  * We don't call the modules recursively.  Instead we iterate over a list of #unlang_t and
@@ -300,7 +297,7 @@ typedef struct {
                                                                ///< frame lower in the stack to determine if the
                                                                ///< result stored in the lower stack frame should
                                                                ///< be replaced.
-       unlang_unwind_flags_t   uflags;                         //!< Unwind markers
+       uint8_t                 uflags;                         //!< Unwind markers
 } unlang_stack_frame_t;
 
 /** An unlang stack associated with a request
@@ -309,7 +306,7 @@ typedef struct {
 typedef struct {
        rlm_rcode_t             result;                         //!< The current stack rcode.
        int                     depth;                          //!< Current depth we're executing at.
-       unlang_unwind_flags_t   unwind;                         //!< Unwind to this frame if it exists.
+       uint8_t                 unwind;                         //!< Unwind to this frame if it exists.
                                                                ///< This is used for break and return.
        unlang_stack_frame_t    frame[UNLANG_STACK_MAX];        //!< The stack...
 } unlang_stack_t;