[pve-devel] applied: [PATCH firewall] fix ambiguous if statements

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Dec 13 14:47:31 CET 2016


applied
But technically it's not ambiguous, just plain weird ;-)

(Also note that the correct equivalent would be '!= 0' (since positive
numbers also map to 0), but `< 0` properly conforms to the documentation
and they don't seem to be able to return `> 0` in their code
(libnetfilter_log + libnfnetlink).)

On Tue, Dec 13, 2016 at 01:13:39PM +0100, Thomas Lamprecht wrote:
> the funciton nflog_bind_pf(...) returns an integer smaller 0 on a
> failure, we negated that which results in 1 if no failure and 0 if
> there was a failure.
> This is ambiguous and as no parenthesis are set the GCC 6 warning
> "logical-not-parentheses" gets triggered.
> 
> Use a simple
>     nflog_bind_pf(...) < 0
> check instead.
> 
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
>  src/pvefw-logger.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/pvefw-logger.c b/src/pvefw-logger.c
> index 3b79ed1..3dc40eb 100644
> --- a/src/pvefw-logger.c
> +++ b/src/pvefw-logger.c
> @@ -982,7 +982,7 @@ main(int argc, char *argv[])
>          exit(-1);
>      }
>  
> -    if (!nflog_bind_pf(logh, AF_INET) <= 0) {
> +    if (nflog_bind_pf(logh, AF_INET) < 0) {
>          fprintf(stderr, "nflog_bind_pf AF_INET failed\n");
>          exit(-1);
>      }
> @@ -994,7 +994,7 @@ main(int argc, char *argv[])
>      }
>  #endif
>  
> -    if (!nflog_bind_pf(logh, AF_BRIDGE) <= 0) {
> +    if (nflog_bind_pf(logh, AF_BRIDGE) < 0) {
>          fprintf(stderr, "nflog_bind_pf AF_BRIDGE failed\n");
>          exit(-1);
>      }
> -- 
> 2.1.4




More information about the pve-devel mailing list