sergey-dryabzhinsky / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
1.02k stars 215 forks source link

"Fall through Error" "ngx_rtmp_eval.c" 160:17; Ubuntu 18.10 Nginx 10.15.5 #285

Open pheynnx opened 5 years ago

pheynnx commented 5 years ago

I can't make nginx with the module do to an error in ngx_rtmp_eval.c; I am grabbing from the latest dev branch. And I can't seem to bypass the warnings.? I tried "make -Werror" but that didn't work.

winshining commented 5 years ago

Add

/* fall through */

before

case ESCAPE:

and

default:
    break;

at the end of switch after

case NORMAL:

will eliminate the error.

jstilwell commented 5 years ago

I'm having the same problem - above solution not working for me.

thepurplepainter commented 5 years ago

Same here. Maybe I just didn't understand the instructions above... I dug around on the interwebz and found this article: https://dzone.com/articles/implicit-fallthrough-in-gcc-7 which indicates fall-through comments must be placed in switch statements to ensure the compiler will allow other values than those defined explicitly.

These “falls through” comments are meant to be used as in the example here:

switch (cond)
 {
 case 0:
   foo (0);
   /* FALLTHRU */
 case 1:
   foo (1); 
   /* further code */
 }

They should precede the case or default keywords. Be aware, though, that they might clash with macros so sometimes using the attributes will be necessary.

Based on this, I updated as follows (where switch (c) { is line 160 and case ESCAPE: was originally line 170. My additions include both fall-through statements and the default: break; in between them:

            case NORMAL:
                switch (c) {
                    case '$':
                        name.data = p + 1;
                        state = NAME;
                        continue;
                    case '\\':
                        state = ESCAPE;
                        continue;
                    /* fall through */
                    default:
                        break;
                }
           /* fall through */
           case ESCAPE:

This change to ngx_rtmp_eval.c corrected the issue and I was able to make and install the package. I used instructions on the following site as a guide for building and installing nginx with RTMP module on my pi (running ArchArm64):

https://obsproject.com/forum/resources/how-to-set-up-your-own-private-rtmp-server-using-nginx.50/

I'm still trying to get the RTMP part to work (on Pi running Arch64). Maybe it's not compatible with the most recent nginx, not sure, but the compile errors are gone anyway...

sundbry commented 5 years ago

You can work around this without patching by configuring NGINX with --with-cc-opt="-Werror=implicit-fallthrough=0 to ignore the error in GCC

sergey-dryabzhinsky commented 3 years ago

All fixes from arut and suggested in dev-branch. You can try it again.