Unexpected structure of macros in ngx_string.h
Maxim Dounin
mdounin at mdounin.ru
Tue Jan 12 12:56:08 UTC 2021
Hello!
On Tue, Jan 12, 2021 at 12:40:06AM +0000, Chris Newton wrote:
> I just came across a problem with an innocuous looking line of code in a
> new module I have been working on:
>
> if (tmp_str.len == 0)
>
> ngx_str_set(&tmp_str, "/");
>
>
> The modification of tmp_str.data to '/' was always being made, but the
> length wasn't if the test failed. This turns out to be caused by the style
> used in the definition of the ngx_str_set macro.
I always wonder why people intentionally ignore nginx style and
then complain something doesn't work for them. Following nginx
style and always using curly brackets is how it is expected to
work.
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx-devel
mailing list