Fix fallthrough warnings
[src/app-framework-binder.git] / src / websock.c
index f79feb5..0bbd56a 100644 (file)
@@ -45,7 +45,7 @@
 #define FRAME_SET_RSV3(BYTE)        (((BYTE) & 0x01) << 4)
 #define FRAME_SET_OPCODE(BYTE)      ((BYTE) & 0x0F)
 #define FRAME_SET_MASK(BYTE)        (((BYTE) & 0x01) << 7)
-#define FRAME_SET_LENGTH(X64, IDX)  (unsigned char)(((X64) >> ((IDX)*8)) & 0xFF)
+#define FRAME_SET_LENGTH(X64, IDX)  (unsigned char)((sizeof(X64)) <= (IDX) ? 0 : (((X64) >> ((IDX)*8)) & 0xFF))
 
 #define OPCODE_CONTINUATION 0x0
 #define OPCODE_TEXT         0x1
@@ -312,6 +312,7 @@ loop:
                ws->lenhead = 0;
                ws->szhead = 2;
                ws->state = STATE_START;
+               /*@fallthrough@*/
 
        case STATE_START:
                /* read the header */
@@ -342,12 +343,15 @@ loop:
                switch (FRAME_GET_PAYLOAD_LEN(ws->header[1])) {
                case 127:
                        ws->szhead += 6;
+                       /*@fallthrough@*/
                case 126:
                        ws->szhead += 2;
+                       /*@fallthrough@*/
                default:
                        ws->szhead += 4 * FRAME_GET_MASK(ws->header[1]);
                }
                ws->state = STATE_LENGTH;
+               /*@fallthrough@*/
 
        case STATE_LENGTH:
                /* continue to read the header */