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  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 19 Jan 2022 21:30:47 +0200
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Lucas De Marchi <lucas.demarchi@...el.com>
Cc:     linux-kernel@...r.kernel.org, intel-gfx@...ts.freedesktop.org,
        dri-devel@...ts.freedesktop.org, amd-gfx@...ts.freedesktop.org,
        linux-security-module@...r.kernel.org,
        nouveau@...ts.freedesktop.org, netdev@...r.kernel.org,
        Alex Deucher <alexander.deucher@....com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Ben Skeggs <bskeggs@...hat.com>,
        Christian K├Ânig <christian.koenig@....com>,
        Chris Wilson <chris@...is-wilson.co.uk>,
        Daniel Vetter <daniel@...ll.ch>,
        David Airlie <airlied@...ux.ie>,
        "David S . Miller" <davem@...emloft.net>,
        Emma Anholt <emma@...olt.net>, Eryk Brol <eryk.brol@....com>,
        Francis Laniel <laniel_francis@...vacyrequired.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Harry Wentland <harry.wentland@....com>,
        Jakub Kicinski <kuba@...nel.org>,
        Jani Nikula <jani.nikula@...ux.intel.com>,
        Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
        Julia Lawall <julia.lawall@...6.fr>,
        Kentaro Takeda <takedakn@...data.co.jp>,
        Leo Li <sunpeng.li@....com>,
        Mikita Lipski <mikita.lipski@....com>,
        Petr Mladek <pmladek@...e.com>,
        Rahul Lakkireddy <rahul.lakkireddy@...lsio.com>,
        Raju Rangoju <rajur@...lsio.com>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Rodrigo Vivi <rodrigo.vivi@...el.com>,
        Sakari Ailus <sakari.ailus@...ux.intel.com>,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Vishal Kulkarni <vishal@...lsio.com>
Subject: Re: [PATCH 3/3] drm: Convert open yes/no strings to yesno()

On Tue, Jan 18, 2022 at 11:24:50PM -0800, Lucas De Marchi wrote:
> linux/string_helpers.h provides a helper to return "yes"/"no"
> strings. Replace the open coded versions with yesno(). The places were
> identified with the following semantic patch:
> 
> 	@@
> 	expression b;
> 	@@
> 
> 	- b ? "yes" : "no"
> 	+ yesno(b)
> 
> Then the includes were added, so we include-what-we-use, and parenthesis
> adjusted in drivers/gpu/drm/v3d/v3d_debugfs.c. After the conversion we
> still see the same binary sizes:
> 
>    text    data     bss     dec     hex filename
> 1442171   60344     800 1503315  16f053 ./drivers/gpu/drm/radeon/radeon.ko
> 1442171   60344     800 1503315  16f053 ./drivers/gpu/drm/radeon/radeon.ko.old
> 5985991  324439   33808 6344238  60ce2e ./drivers/gpu/drm/amd/amdgpu/amdgpu.ko
> 5985991  324439   33808 6344238  60ce2e ./drivers/gpu/drm/amd/amdgpu/amdgpu.ko.old
>  411986   10490    6176  428652   68a6c ./drivers/gpu/drm/drm.ko
>  411986   10490    6176  428652   68a6c ./drivers/gpu/drm/drm.ko.old
> 1970292  109515    2352 2082159  1fc56f ./drivers/gpu/drm/nouveau/nouveau.ko
> 1970292  109515    2352 2082159  1fc56f ./drivers/gpu/drm/nouveau/nouveau.ko.old

...

>  #include <linux/module.h>
>  #include <linux/sched.h>
>  #include <linux/slab.h>
> +#include <linux/string_helpers.h>

+ blank line?

> +#include <linux/string_helpers.h>

...

>  	seq_printf(m, "\tDP branch device present: %s\n",
> -		   branch_device ? "yes" : "no");
> +		   yesno(branch_device));

Now it's possible to keep this on one line.

...

>  	drm_printf_indent(p, indent, "imported=%s\n",
> -			  obj->import_attach ? "yes" : "no");
> +			  yesno(obj->import_attach));

81 here, but anyway, ditto!

...

>   */

+blank line here?

> +#include <linux/string_helpers.h>
> +
>  #include "aux.h"
>  #include "pad.h"

...

>  	seq_printf(m, "MMU:        %s\n",
> -		   (ident2 & V3D_HUB_IDENT2_WITH_MMU) ? "yes" : "no");
> +		   yesno(ident2 & V3D_HUB_IDENT2_WITH_MMU));
>  	seq_printf(m, "TFU:        %s\n",
> -		   (ident1 & V3D_HUB_IDENT1_WITH_TFU) ? "yes" : "no");
> +		   yesno(ident1 & V3D_HUB_IDENT1_WITH_TFU));
>  	seq_printf(m, "TSY:        %s\n",
> -		   (ident1 & V3D_HUB_IDENT1_WITH_TSY) ? "yes" : "no");
> +		   yesno(ident1 & V3D_HUB_IDENT1_WITH_TSY));
>  	seq_printf(m, "MSO:        %s\n",
> -		   (ident1 & V3D_HUB_IDENT1_WITH_MSO) ? "yes" : "no");
> +		   yesno(ident1 & V3D_HUB_IDENT1_WITH_MSO));
>  	seq_printf(m, "L3C:        %s (%dkb)\n",
> -		   (ident1 & V3D_HUB_IDENT1_WITH_L3C) ? "yes" : "no",
> +		   yesno(ident1 & V3D_HUB_IDENT1_WITH_L3C),
>  		   V3D_GET_FIELD(ident2, V3D_HUB_IDENT2_L3C_NKB));

I believe it's fine to join back to have less LOCs (yes, it will be 83 or so,
but I believe in these cases it's very much okay).

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists