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]
Message-ID: <20180321092458.76v5jujepp2inmov@mwanda>
Date:   Wed, 21 Mar 2018 12:24:58 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Pratik Jain <pratik.jain0509@...il.com>
Cc:     arnaud.patard@...-net.org, devel@...verdev.osuosl.org,
        gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Staging: xgifb: XGI_main_26.c: Refactored the function

On Tue, Mar 20, 2018 at 07:32:32PM +0530, Pratik Jain wrote:
> Refactored the function `XGIfb_search_refresh_rate` by removing a level
> of `if...else` block nesting. Removed unnecessary parantheses.
> 
> Signed-off-by: Pratik Jain <pratik.jain0509@...il.com>
> ---
>  drivers/staging/xgifb/XGI_main_26.c | 59 +++++++++++++++++++------------------
>  1 file changed, 30 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c
> index 10107de0119a..aee969aab681 100644
> --- a/drivers/staging/xgifb/XGI_main_26.c
> +++ b/drivers/staging/xgifb/XGI_main_26.c
> @@ -544,41 +544,42 @@ static u8 XGIfb_search_refresh_rate(struct xgifb_video_info *xgifb_info,
>  	yres = XGIbios_mode[xgifb_info->mode_idx].yres;
>  
>  	xgifb_info->rate_idx = 0;
> -	while ((XGIfb_vrate[i].idx != 0) && (XGIfb_vrate[i].xres <= xres)) {
> -		if ((XGIfb_vrate[i].xres == xres) &&
> -		    (XGIfb_vrate[i].yres == yres)) {
> -			if (XGIfb_vrate[i].refresh == rate) {
> +
> +	while (XGIfb_vrate[i].idx != 0 && XGIfb_vrate[i].xres <= xres) {
> +		/* Skip values with xres or yres less than specified */
> +		if ((XGIfb_vrate[i].yres != yres) ||
> +		    (XGIfb_vrate[i].xres < xres)) {

Both < and != are equivalent, but to me != feels more obvious.  With !=
the opposite of that is *always* == so that's obvious just by looking at
it.  But with < you have to look at the lines before so you have to
remember more stuff to understand the code.

The other thing is that != xres matches nicely with != yres.  Otherwise
I sort of assume from looking at it that != and < are different things.

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ