Re: [nginx] enhance options
Hello! On Sun, Feb 04, 2018 at 08:49:12PM +0800, 洪志道 wrote: > Hi! > > Maybe it's better to keep the options more complete, and consider the > follow operation as a mistake. > > /usr/local/nginx/sbin/nginx - > > hg diff > diff -r cbf59d483c9c src/core/nginx.c > --- a/src/core/nginx.c Tue Jan 16 13:52:03 2018 +0300 > +++ b/src/core/nginx.c Sun Feb 04 07:41:36 2018 -0500 > @@ -753,7 +753,12 @@ > return NGX_ERROR; > } > > -while (*p) { > +do { > + > +if (*p == '\0') { > +ngx_log_stderr(0, "missing option: \"%s\"", argv[i]); > +return NGX_ERROR; > +} > > switch (*p++) { > > @@ -855,7 +860,8 @@ > ngx_log_stderr(0, "invalid option: \"%c\"", *(p - 1)); > return NGX_ERROR; > } > -} > + > +} while (*p); > > next: Checking *p twice on each loop iteration certainly looks superfluous. Rather, a more logical check would look like: diff --git a/src/core/nginx.c b/src/core/nginx.c --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -748,7 +748,7 @@ ngx_get_options(int argc, char *const *a p = (u_char *) argv[i]; -if (*p++ != '-') { +if (*p++ != '-' || *p == '\0') { ngx_log_stderr(0, "invalid option: \"%s\"", argv[i]); return NGX_ERROR; } Not sure it worth the change though. -- Maxim Dounin http://mdounin.ru/ ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
Re: [nginx] enhance options
LGTM On Sun, Feb 4, 2018 at 8:49 PM, 洪志道wrote: > Hi! > > Maybe it's better to keep the options more complete, and consider the > follow operation as a mistake. > > /usr/local/nginx/sbin/nginx - > > hg diff > diff -r cbf59d483c9c src/core/nginx.c > --- a/src/core/nginx.c Tue Jan 16 13:52:03 2018 +0300 > +++ b/src/core/nginx.c Sun Feb 04 07:41:36 2018 -0500 > @@ -753,7 +753,12 @@ > return NGX_ERROR; > } > > -while (*p) { > +do { > + > +if (*p == '\0') { > +ngx_log_stderr(0, "missing option: \"%s\"", argv[i]); > +return NGX_ERROR; > +} > > switch (*p++) { > > @@ -855,7 +860,8 @@ > ngx_log_stderr(0, "invalid option: \"%c\"", *(p - 1)); > return NGX_ERROR; > } > -} > + > +} while (*p); > > next: > > Thanks. > > ___ > nginx-devel mailing list > nginx-devel@nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel > ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
[nginx] enhance options
Hi! Maybe it's better to keep the options more complete, and consider the follow operation as a mistake. /usr/local/nginx/sbin/nginx - hg diff diff -r cbf59d483c9c src/core/nginx.c --- a/src/core/nginx.c Tue Jan 16 13:52:03 2018 +0300 +++ b/src/core/nginx.c Sun Feb 04 07:41:36 2018 -0500 @@ -753,7 +753,12 @@ return NGX_ERROR; } -while (*p) { +do { + +if (*p == '\0') { +ngx_log_stderr(0, "missing option: \"%s\"", argv[i]); +return NGX_ERROR; +} switch (*p++) { @@ -855,7 +860,8 @@ ngx_log_stderr(0, "invalid option: \"%c\"", *(p - 1)); return NGX_ERROR; } -} + +} while (*p); next: Thanks. ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel