lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 29 Jun 2023 15:14:27 +0200
From: Petr Machata <me@...chata.org>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH iproute2 3/5] ss: fix warning about empty if()


Stephen Hemminger <stephen@...workplumber.org> writes:

> With all warnings enabled gcc wants brackets around the
> empty if() clause. "Yes I really want an empty clause"
>
> Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
> ---
>  misc/ss.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/misc/ss.c b/misc/ss.c
> index de02fccb539b..e9d813596b91 100644
> --- a/misc/ss.c
> +++ b/misc/ss.c
> @@ -627,8 +627,9 @@ static void user_ent_hash_build_task(char *path, int pid, int tid)
>  
>  			fp = fopen(stat, "r");
>  			if (fp) {
> -				if (fscanf(fp, "%*d (%[^)])", task) < 1)
> +				if (fscanf(fp, "%*d (%[^)])", task) < 1) {
>  					; /* ignore */
> +				}
>  				fclose(fp);
>  			}
>  		}

Reviewed-by: Petr Machata <me@...chata.org>

As an aside, this whole if business is necessary in the first place due
to __attribute__((warn_unused_result)) that fscanf apparently has on
some libc's. But ignoring fscanf failures is safe, because a) `task' is
pre-initialized at variable definition, so ignoring the result like this
should indeed be safe; and b), fp references some file in /proc and we
can rely on the format and that the scan will in fact not fail.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ