All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: core: remove unnecessary (void*) conversions
@ 2023-03-17  6:47 Yu Zhe
  2023-03-23 12:13 ` Ulf Hansson
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Yu Zhe @ 2023-03-17  6:47 UTC (permalink / raw)
  To: ulf.hansson; +Cc: linux-mmc, linux-kernel, kernel-janitors, liqiong, Yu Zhe

Pointer variables of void * type do not require type cast.

Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
---
 drivers/mmc/core/debugfs.c  | 2 +-
 drivers/mmc/core/host.c     | 2 +-
 drivers/mmc/core/mmc_test.c | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index fe6808771bc7..2c97b94aab23 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -246,7 +246,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(mmc_err_state, mmc_err_state_get, NULL, "%llu\n");
 
 static int mmc_err_stats_show(struct seq_file *file, void *data)
 {
-	struct mmc_host *host = (struct mmc_host *)file->private;
+	struct mmc_host *host = file->private;
 	const char *desc[MMC_ERR_MAX] = {
 		[MMC_ERR_CMD_TIMEOUT] = "Command Timeout Occurred",
 		[MMC_ERR_CMD_CRC] = "Command CRC Errors Occurred",
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 096093f7be00..76900f67c782 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -590,7 +590,7 @@ EXPORT_SYMBOL(mmc_alloc_host);
 
 static void devm_mmc_host_release(struct device *dev, void *res)
 {
-	mmc_free_host(*(struct mmc_host **)res);
+	mmc_free_host(res);
 }
 
 struct mmc_host *devm_mmc_alloc_host(struct device *dev, int extra)
diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c
index 156d34b2ed4d..0f6a563103fd 100644
--- a/drivers/mmc/core/mmc_test.c
+++ b/drivers/mmc/core/mmc_test.c
@@ -3045,7 +3045,7 @@ static LIST_HEAD(mmc_test_file_test);
 
 static int mtf_test_show(struct seq_file *sf, void *data)
 {
-	struct mmc_card *card = (struct mmc_card *)sf->private;
+	struct mmc_card *card = sf->private;
 	struct mmc_test_general_result *gr;
 
 	mutex_lock(&mmc_test_lock);
@@ -3079,8 +3079,8 @@ static int mtf_test_open(struct inode *inode, struct file *file)
 static ssize_t mtf_test_write(struct file *file, const char __user *buf,
 	size_t count, loff_t *pos)
 {
-	struct seq_file *sf = (struct seq_file *)file->private_data;
-	struct mmc_card *card = (struct mmc_card *)sf->private;
+	struct seq_file *sf = file->private_data;
+	struct mmc_card *card = sf->private;
 	struct mmc_test_card *test;
 	long testcase;
 	int ret;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] mmc: core: remove unnecessary (void*) conversions
  2023-03-17  6:47 [PATCH] mmc: core: remove unnecessary (void*) conversions Yu Zhe
@ 2023-03-23 12:13 ` Ulf Hansson
       [not found] ` <CGME20230324132858eucas1p25cdd6af81a14bf40474f58fa16d087f5@eucas1p2.samsung.com>
  2023-03-28  3:10 ` [PATCH v2] " Yu Zhe
  2 siblings, 0 replies; 10+ messages in thread
From: Ulf Hansson @ 2023-03-23 12:13 UTC (permalink / raw)
  To: Yu Zhe; +Cc: linux-mmc, linux-kernel, kernel-janitors, liqiong

On Fri, 17 Mar 2023 at 07:48, Yu Zhe <yuzhe@nfschina.com> wrote:
>
> Pointer variables of void * type do not require type cast.
>
> Signed-off-by: Yu Zhe <yuzhe@nfschina.com>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/core/debugfs.c  | 2 +-
>  drivers/mmc/core/host.c     | 2 +-
>  drivers/mmc/core/mmc_test.c | 6 +++---
>  3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
> index fe6808771bc7..2c97b94aab23 100644
> --- a/drivers/mmc/core/debugfs.c
> +++ b/drivers/mmc/core/debugfs.c
> @@ -246,7 +246,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(mmc_err_state, mmc_err_state_get, NULL, "%llu\n");
>
>  static int mmc_err_stats_show(struct seq_file *file, void *data)
>  {
> -       struct mmc_host *host = (struct mmc_host *)file->private;
> +       struct mmc_host *host = file->private;
>         const char *desc[MMC_ERR_MAX] = {
>                 [MMC_ERR_CMD_TIMEOUT] = "Command Timeout Occurred",
>                 [MMC_ERR_CMD_CRC] = "Command CRC Errors Occurred",
> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> index 096093f7be00..76900f67c782 100644
> --- a/drivers/mmc/core/host.c
> +++ b/drivers/mmc/core/host.c
> @@ -590,7 +590,7 @@ EXPORT_SYMBOL(mmc_alloc_host);
>
>  static void devm_mmc_host_release(struct device *dev, void *res)
>  {
> -       mmc_free_host(*(struct mmc_host **)res);
> +       mmc_free_host(res);
>  }
>
>  struct mmc_host *devm_mmc_alloc_host(struct device *dev, int extra)
> diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c
> index 156d34b2ed4d..0f6a563103fd 100644
> --- a/drivers/mmc/core/mmc_test.c
> +++ b/drivers/mmc/core/mmc_test.c
> @@ -3045,7 +3045,7 @@ static LIST_HEAD(mmc_test_file_test);
>
>  static int mtf_test_show(struct seq_file *sf, void *data)
>  {
> -       struct mmc_card *card = (struct mmc_card *)sf->private;
> +       struct mmc_card *card = sf->private;
>         struct mmc_test_general_result *gr;
>
>         mutex_lock(&mmc_test_lock);
> @@ -3079,8 +3079,8 @@ static int mtf_test_open(struct inode *inode, struct file *file)
>  static ssize_t mtf_test_write(struct file *file, const char __user *buf,
>         size_t count, loff_t *pos)
>  {
> -       struct seq_file *sf = (struct seq_file *)file->private_data;
> -       struct mmc_card *card = (struct mmc_card *)sf->private;
> +       struct seq_file *sf = file->private_data;
> +       struct mmc_card *card = sf->private;
>         struct mmc_test_card *test;
>         long testcase;
>         int ret;
> --
> 2.11.0
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] mmc: core: remove unnecessary (void*) conversions
       [not found] ` <CGME20230324132858eucas1p25cdd6af81a14bf40474f58fa16d087f5@eucas1p2.samsung.com>
@ 2023-03-24 13:28   ` Marek Szyprowski
  2023-03-24 15:46     ` Ulf Hansson
  2023-03-24 16:39     ` Dan Carpenter
  0 siblings, 2 replies; 10+ messages in thread
From: Marek Szyprowski @ 2023-03-24 13:28 UTC (permalink / raw)
  To: Yu Zhe, ulf.hansson; +Cc: linux-mmc, linux-kernel, kernel-janitors, liqiong

On 17.03.2023 07:47, Yu Zhe wrote:
> Pointer variables of void * type do not require type cast.
>
> Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
> ---
>   drivers/mmc/core/debugfs.c  | 2 +-
>   drivers/mmc/core/host.c     | 2 +-
>   drivers/mmc/core/mmc_test.c | 6 +++---
>   3 files changed, 5 insertions(+), 5 deletions(-)
...
> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> index 096093f7be00..76900f67c782 100644
> --- a/drivers/mmc/core/host.c
> +++ b/drivers/mmc/core/host.c
> @@ -590,7 +590,7 @@ EXPORT_SYMBOL(mmc_alloc_host);
>   
>   static void devm_mmc_host_release(struct device *dev, void *res)
>   {
> -	mmc_free_host(*(struct mmc_host **)res);
> +	mmc_free_host(res);

The above chunk is wrong and causes following regression on today's 
Linux next-20230324:

Unable to handle kernel paging request at virtual address 0000000000001020
Mem abort info:
meson-gx-mmc ffe07000.mmc: allocated mmc-pwrseq
...
[0000000000001020] user address but active_mm is swapper
Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
Modules linked in:
CPU: 3 PID: 10 Comm: kworker/u12:0 Not tainted 6.3.0-rc3-next-20230324+ 
#13452
Hardware name: Khadas VIM3 (DT)
Workqueue: events_unbound async_run_entry_fn
pstate: 00000005 (nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : mmc_pwrseq_free+0x1c/0x38
lr : devm_mmc_host_release+0x1c/0x34
...
Call trace:
  mmc_pwrseq_free+0x1c/0x38
  devm_mmc_host_release+0x1c/0x34
  release_nodes+0x5c/0x90
  devres_release_all+0x8c/0xdc
  device_unbind_cleanup+0x18/0x68
  really_probe+0x11c/0x2b4
  __driver_probe_device+0x78/0xe0
  driver_probe_device+0xd8/0x160
  __device_attach_driver+0xb8/0x138
  bus_for_each_drv+0x84/0xe0
  __device_attach_async_helper+0xb0/0xd4
  async_run_entry_fn+0x34/0xe0
  process_one_work+0x288/0x5c0
  worker_thread+0x74/0x450
  kthread+0x124/0x128
  ret_from_fork+0x10/0x20
Code: f9000bf3 aa0003f3 f9424c00 b4000080 (f9401000)
---[ end trace 0000000000000000 ]---

Ulf: do You want me to send a partial revert or will you handle it by 
dropping this patch?

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] mmc: core: remove unnecessary (void*) conversions
  2023-03-24 13:28   ` Marek Szyprowski
@ 2023-03-24 15:46     ` Ulf Hansson
  2023-03-24 16:39     ` Dan Carpenter
  1 sibling, 0 replies; 10+ messages in thread
From: Ulf Hansson @ 2023-03-24 15:46 UTC (permalink / raw)
  To: Marek Szyprowski
  Cc: Yu Zhe, linux-mmc, linux-kernel, kernel-janitors, liqiong

On Fri, 24 Mar 2023 at 14:28, Marek Szyprowski <m.szyprowski@samsung.com> wrote:
>
> On 17.03.2023 07:47, Yu Zhe wrote:
> > Pointer variables of void * type do not require type cast.
> >
> > Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
> > ---
> >   drivers/mmc/core/debugfs.c  | 2 +-
> >   drivers/mmc/core/host.c     | 2 +-
> >   drivers/mmc/core/mmc_test.c | 6 +++---
> >   3 files changed, 5 insertions(+), 5 deletions(-)
> ...
> > diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> > index 096093f7be00..76900f67c782 100644
> > --- a/drivers/mmc/core/host.c
> > +++ b/drivers/mmc/core/host.c
> > @@ -590,7 +590,7 @@ EXPORT_SYMBOL(mmc_alloc_host);
> >
> >   static void devm_mmc_host_release(struct device *dev, void *res)
> >   {
> > -     mmc_free_host(*(struct mmc_host **)res);
> > +     mmc_free_host(res);
>
> The above chunk is wrong and causes following regression on today's
> Linux next-20230324:
>
> Unable to handle kernel paging request at virtual address 0000000000001020
> Mem abort info:
> meson-gx-mmc ffe07000.mmc: allocated mmc-pwrseq
> ...
> [0000000000001020] user address but active_mm is swapper
> Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
> Modules linked in:
> CPU: 3 PID: 10 Comm: kworker/u12:0 Not tainted 6.3.0-rc3-next-20230324+
> #13452
> Hardware name: Khadas VIM3 (DT)
> Workqueue: events_unbound async_run_entry_fn
> pstate: 00000005 (nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> pc : mmc_pwrseq_free+0x1c/0x38
> lr : devm_mmc_host_release+0x1c/0x34
> ...
> Call trace:
>   mmc_pwrseq_free+0x1c/0x38
>   devm_mmc_host_release+0x1c/0x34
>   release_nodes+0x5c/0x90
>   devres_release_all+0x8c/0xdc
>   device_unbind_cleanup+0x18/0x68
>   really_probe+0x11c/0x2b4
>   __driver_probe_device+0x78/0xe0
>   driver_probe_device+0xd8/0x160
>   __device_attach_driver+0xb8/0x138
>   bus_for_each_drv+0x84/0xe0
>   __device_attach_async_helper+0xb0/0xd4
>   async_run_entry_fn+0x34/0xe0
>   process_one_work+0x288/0x5c0
>   worker_thread+0x74/0x450
>   kthread+0x124/0x128
>   ret_from_fork+0x10/0x20
> Code: f9000bf3 aa0003f3 f9424c00 b4000080 (f9401000)
> ---[ end trace 0000000000000000 ]---
>
> Ulf: do You want me to send a partial revert or will you handle it by
> dropping this patch?

Thanks for the report, I will simply drop the patch!

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] mmc: core: remove unnecessary (void*) conversions
  2023-03-24 13:28   ` Marek Szyprowski
  2023-03-24 15:46     ` Ulf Hansson
@ 2023-03-24 16:39     ` Dan Carpenter
  2023-03-27 10:26       ` Ulf Hansson
  1 sibling, 1 reply; 10+ messages in thread
From: Dan Carpenter @ 2023-03-24 16:39 UTC (permalink / raw)
  To: Marek Szyprowski
  Cc: Yu Zhe, ulf.hansson, linux-mmc, linux-kernel, kernel-janitors, liqiong

[-- Attachment #1: Type: text/plain, Size: 1515 bytes --]

On Fri, Mar 24, 2023 at 02:28:57PM +0100, Marek Szyprowski wrote:
> On 17.03.2023 07:47, Yu Zhe wrote:
> > Pointer variables of void * type do not require type cast.
> >
> > Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
> > ---
> >   drivers/mmc/core/debugfs.c  | 2 +-
> >   drivers/mmc/core/host.c     | 2 +-
> >   drivers/mmc/core/mmc_test.c | 6 +++---
> >   3 files changed, 5 insertions(+), 5 deletions(-)
> ...
> > diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> > index 096093f7be00..76900f67c782 100644
> > --- a/drivers/mmc/core/host.c
> > +++ b/drivers/mmc/core/host.c
> > @@ -590,7 +590,7 @@ EXPORT_SYMBOL(mmc_alloc_host);
> >   
> >   static void devm_mmc_host_release(struct device *dev, void *res)
> >   {
> > -	mmc_free_host(*(struct mmc_host **)res);
> > +	mmc_free_host(res);
> 
> The above chunk is wrong and causes following regression on today's 
> Linux next-20230324:

Ugh...

Ok.  I have a script that I use to help review mechanical patches.  I
have added an '-r cast' option to help review "remove unnecessary cast"
patches.

If you do `cat this_email.txt | rename_rev.pl -r cast` then the output
looks like:

================
 static void devm_mmc_host_release(struct device *dev, void *res)
 {
-       mmc_free_host(*res);
+       mmc_free_host(res);
 }
 
 struct mmc_host *devm_mmc_alloc_host(struct device *dev, int extra)
================

I have gone through all of Yu Zhe's patches and the rest are okay.

I've attached my rename_rev.pl script.

regards,
dan carpenter


[-- Attachment #2: rename_rev.pl --]
[-- Type: text/x-perl, Size: 11308 bytes --]

#!/usr/bin/perl

# This is a tool to help review variable rename patches. The goal is
# to strip out the automatic sed renames and the white space changes
# and leaves the interesting code changes.
#
# Example 1: A patch renames openInfo to open_info:
#     cat diff | rename_review.pl openInfo open_info
#
# Example 2: A patch swaps the first two arguments to some_func():
#     cat diff | rename_review.pl \
#                    -e 's/some_func\((.*?),(.*?),/some_func\($2, $1,/'
#
# Example 3: A patch removes the xkcd_ prefix from some but not all the
# variables.  Instead of trying to figure out which variables were renamed
# just remove the prefix from them all:
#     cat diff | rename_review.pl -ea 's/xkcd_//g'
#
# Example 4: A patch renames 20 CamelCase variables.  To review this let's
# just ignore all case changes and all '_' chars.
#     cat diff | rename_review -ea 'tr/[A-Z]/[a-z]/' -ea 's/_//g'
#
# The other arguments are:
# -nc removes comments
# -ns removes '\' chars if they are at the end of the line.

use strict;
use File::Temp qw/ :mktemp  /;

sub usage() {
    print "usage: cat diff | $0 old new old new old new...\n";
    print "   or: cat diff | $0 -e 's/old/new/g'\n";
    print " -a : auto";
    print " -e : execute on old lines\n";
    print " -ea: execute on all lines\n";
    print " -nc: no comments\n";
    print " -nb: no unneeded braces\n";
    print " -ns: no slashes at the end of a line\n";
    print " -pull: for function pull.  deletes context.\n";
    print " -r <recipe>: NULL, bool, cast";
    exit(1);
}
my @subs;
my @strict_subs;
my @cmds;
my $strip_comments;
my $strip_braces;
my $strip_slashes;
my $pull_context;
my $auto;

sub filter($) {
    my $line = shift();
    my $old = 0;
    if ($line =~ /^-/) {
        $old = 1;
    }
    # remove the first char
    $line =~ s/^[ +-]//;
    if ($strip_comments) {
        $line =~ s/\/\*.*?\*\///g;
        $line =~ s/\/\/.*//;
    }
    foreach my $cmd (@cmds) {
        if ($old || $cmd->[0] =~ /^-ea$/) {
            eval "\$line =~ $cmd->[1]";
        }
    }
    foreach my $sub (@subs) {
        if ($old) {
            $line =~ s/$sub->[0]/$sub->[1]/g;
        }
    }
    foreach my $sub (@strict_subs) {
        if ($old) {
            $line =~ s/\b$sub->[0]\b/$sub->[1]/g;
        }
    }

    # remove the newline so we can move curly braces here if we want.
    $line =~ s/\n//;
    return $line;
}

while (my $param1 = shift()) {
    if ($param1 =~ /^-a$/) {
        $auto = 1;
        next;
    }
    if ($param1 =~ /^-nc$/) {
        $strip_comments = 1;
        next;
    }
    if ($param1 =~ /^-nb$/) {
        $strip_braces = 1;
        next;
    }
    if ($param1 =~ /^-ns$/) {
        $strip_slashes = 1;
        next;
    }
    if ($param1 =~ /^-pull$/) {
        $pull_context = 1;
        next;
    }
    my $param2 = shift();
    if ($param2 =~ /^$/) {
        usage();
    }
    if ($param1 =~ /^-e(a|)$/) {
        push @cmds, [$param1, $param2];
        next;
    }
    if ($param1 =~ /^-r$/) {
        if ($param2 =~ /bool/) {
            push @cmds, ["-e", "s/== true//"];
            push @cmds, ["-e", "s/true ==//"];
            push @cmds, ["-e", "s/([a-zA-Z\-\>\._]+) == false/!\$1/"];
            next;
        } elsif ($param2 =~ /NULL/) {
            push @cmds, ["-e", "s/ != NULL//"];
            push @cmds, ["-e", "s/([a-zA-Z\-\>\._0-9]+) == NULL/!\$1/"];
            next;
        } elsif ($param2 =~ /^BIT$/) {
            push @cmds, ["-e", 's/1[uU]* *<< *(\d+)/BIT($1)/'];
            push @cmds, ["-e", 's/\(1 *<< *(\w+)\)/BIT($1)/'];
            push @cmds, ["-e", 's/\(BIT\((.*?)\)\)/BIT($1)/'];
            next;
        } elsif ($param2 =~ /^HBIT$/) {
            push @cmds, ["-e", 's/0x0*1\b/BIT(0)/'];
            push @cmds, ["-e", 's/0x0*2\b/BIT(1)/'];
            push @cmds, ["-e", 's/0x0*4\b/BIT(2)/'];
            push @cmds, ["-e", 's/0x0*8\b/BIT(3)/'];
            push @cmds, ["-e", 's/0x0*10\b/BIT(4)/'];
            push @cmds, ["-e", 's/0x0*20\b/BIT(5)/'];
            push @cmds, ["-e", 's/0x0*40\b/BIT(6)/'];
            push @cmds, ["-e", 's/0x0*80\b/BIT(7)/'];
            next;
        } elsif ($param2 =~ /cast/) {
            push @cmds, ["-e", 's/\(struct .*?\)//'];
            next;
        }

        usage();
    }

    push @subs, [$param1, $param2];
}

my ($oldfh, $oldfile) = mkstemp("/tmp/oldXXXXX");
my ($newfh, $newfile) = mkstemp("/tmp/newXXXXX");

my @input = <STDIN>;

# auto works on the observation that the - line comes before the + line when we
# rename variables.  Take the first - line.  Find the first + line.  Find the
# one word difference.  Test that the old word never occurs in the new text.
if ($auto) {
    my %c_keywords = (  auto => 1,
                        break => 1,
                        case => 1,
                        char => 1,
                        const => 1,
                        continue => 1,
                        default => 1,
                        do => 1,
                        double => 1,
                        else => 1,
                        enum => 1,
                        extern => 1,
                        float => 1,
                        for => 1,
                        goto => 1,
                        if => 1,
                        int => 1,
                        long => 1,
                        register => 1,
                        return => 1,
                        short => 1,
                        signed => 1,
                        sizeof => 1,
                        static => 1,
                        struct => 1,
                        switch => 1,
                        typedef => 1,
                        union => 1,
                        unsigned => 1,
                        void => 1,
                        volatile => 1,
                        while => 1);
    my %old_words;
    my %new_words;
    my %added_cmds;
    my @new_subs;

    my $inside = 0;
    foreach my $line (@input) {
        if ($line =~ /^(---|\+\+\+)/) {
            next;
        }

        if ($line =~ /^@/) {
            $inside = 1;
        }
        if ($inside && !(($_ =~ /^[- @+]/) || ($_ =~ /^$/))) {
            $inside = 0;
        }
        if (!$inside) {
            next;
        }

        if ($line =~ /^-/) {
            s/-//;
            my @words = split(/\W+/, $line);
            foreach my $word (@words) {
                $old_words{$word} = 1;
            }
        } elsif ($line =~ /^\+/) {
            s/\+//;
            my @words = split(/\W+/, $line);
            foreach my $word (@words) {
                $new_words{$word} = 1;
            }
        }
    }

    my $old_line;
    my $new_line;
    $inside = 0;
    foreach my $line (@input) {
        if ($line =~ /^(---|\+\+\+)/) {
            next;
        }

        if ($line =~ /^@/) {
            $inside = 1;
        }
        if ($inside && !(($_ =~ /^[- @+]/) || ($_ =~ /^$/))) {
            $inside = 0;
        }
        if (!$inside) {
            next;
        }


        if ($line =~ /^-/ && !$old_line) {
            s/^-//;
            $old_line = $line;
            next;
        } elsif ($old_line && $line =~ /^\+/) {
            s/^\+//;
            $new_line = $line;
        } else {
            next;
        }

        my @old_words = split(/\W+/, $old_line);
        my @new_words = split(/\W+/, $new_line);
        my @new_cmds;

        my $i;
        my $diff_count = 0;
        for ($i = 0; ; $i++) {
            if (!defined($old_words[$i]) && !defined($new_words[$i])) {
                last;
            }
            if (!defined($old_words[$i]) || !defined($new_words[$i])) {
                $diff_count = 1000;
                last;
            }
            if ($old_words[$i] eq $new_words[$i]) {
                next;
            }
            if ($c_keywords{$old_words[$i]}) {
                $diff_count = 1000;
                last;
            }
            if ($new_words{$old_words[$i]}) {
                $diff_count++;
            }
            push @new_cmds, [$old_words[$i], $new_words[$i]];
        }
        if ($diff_count <= 2) {
            foreach my $sub (@new_cmds) {
                if ($added_cmds{$sub->[0] . $sub->[1]}) {
                    next;
                }
                $added_cmds{$sub->[0] . $sub->[1]} = 1;
                push @new_subs, [$sub->[0] , $sub->[1]];
            }
        }

        $old_line = 0;
    }

    if (@new_subs) {
        print "RENAMES:\n";
        foreach my $sub (@new_subs) {
            print "$sub->[0] => $sub->[1]\n";
            push @strict_subs, [$sub->[0] , $sub->[1]];
        }
        print "---\n";
    }
}

my $output;

#recreate an old file and a new file
my $inside = 0;
foreach (@input) {
    if ($pull_context && !($_ =~ /^[+-@]/)) {
        next;
    }

    if ($_ =~ /^(---|\+\+\+)/) {
        next;
    }

    if ($_ =~ /^@/) {
        $inside = 1;
    }
    if ($inside && !(($_ =~ /^[- @+]/) || ($_ =~ /^$/))) {
        $inside = 0;
    }
    if (!$inside) {
        next;
    }

    $output = filter($_);

    if ($strip_braces && $_ =~ /^(\+|-)\W+{/) {
        $output =~ s/^[\t ]+(.*)/ $1/;
    } else {
        $output = "\n" . $output;
    }

    if ($_ =~ /^-/) {
        print $oldfh $output;
        next;
    }
    if ($_ =~ /^\+/) {
        print $newfh $output;
        next;
    }
    print $oldfh $output;
    print $newfh $output;

}
print $oldfh "\n";
print $newfh "\n";
# git diff puts a -- and version at the end of the diff.  put the -- into the
# new file as well so it's ignored
if ($output =~ /\n-/) {
    print $newfh "-\n";
}

my $hunk;
my $old_txt;
my $new_txt;

open diff, "diff -uw $oldfile $newfile |";
while (<diff>) {
    if ($_ =~ /^(---|\+\+\+)/) {
        next;
    }

    if ($_ =~ /^@/) {

        if ($strip_comments) {
            $old_txt =~ s/\/\*.*?\*\///g;
            $new_txt =~ s/\/\*.*?\*\///g;
        }
        if ($strip_braces) {
            $old_txt =~ s/{([^;{]*?);}/$1;/g;
            $new_txt =~ s/{([^;{]*?);}/$1;/g;
            # this is a hack because i don't know how to replace nested
            # unneeded curly braces.
            $old_txt =~ s/{([^;{]*?);}/$1;/g;
            $new_txt =~ s/{([^;{]*?);}/$1;/g;
        }

        if ($old_txt ne $new_txt) {
            print $hunk;
            print $_;
        }
        $hunk = "";
        $old_txt = "";
        $new_txt = "";
        next;
    }

    $hunk = $hunk . $_;

    if ($strip_slashes) {
        s/\\$//;
    }

    if ($_ =~ /^-/) {
        s/-//;
        s/[ \t\n]//g;
        $old_txt = $old_txt . $_;
        next;
    }
    if ($_ =~ /^\+/) {
        s/\+//;
        s/[ \t\n]//g;
        $new_txt = $new_txt . $_;
        next;
    }
    if ($_ =~ /^ /) {
        s/^ //;
        s/[ \t\n]//g;
        $old_txt = $old_txt . $_;
        $new_txt = $new_txt . $_;
    }
}

if ($old_txt ne $new_txt) {
    if ($strip_comments) {
        $old_txt =~ s/\/\*.*?\*\///g;
        $new_txt =~ s/\/\*.*?\*\///g;
    }
    if ($strip_braces) {
        $old_txt =~ s/{([^;{]*?);}/$1;/g;
        $new_txt =~ s/{([^;{]*?);}/$1;/g;
        $old_txt =~ s/{([^;{]*?);}/$1;/g;
        $new_txt =~ s/{([^;{]*?);}/$1;/g;
    }

    print $hunk;
}

unlink($oldfile);
unlink($newfile);

print "\ndone.\n";

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] mmc: core: remove unnecessary (void*) conversions
  2023-03-24 16:39     ` Dan Carpenter
@ 2023-03-27 10:26       ` Ulf Hansson
  0 siblings, 0 replies; 10+ messages in thread
From: Ulf Hansson @ 2023-03-27 10:26 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Marek Szyprowski, Yu Zhe, linux-mmc, linux-kernel,
	kernel-janitors, liqiong

On Fri, 24 Mar 2023 at 17:39, Dan Carpenter <error27@gmail.com> wrote:
>
> On Fri, Mar 24, 2023 at 02:28:57PM +0100, Marek Szyprowski wrote:
> > On 17.03.2023 07:47, Yu Zhe wrote:
> > > Pointer variables of void * type do not require type cast.
> > >
> > > Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
> > > ---
> > >   drivers/mmc/core/debugfs.c  | 2 +-
> > >   drivers/mmc/core/host.c     | 2 +-
> > >   drivers/mmc/core/mmc_test.c | 6 +++---
> > >   3 files changed, 5 insertions(+), 5 deletions(-)
> > ...
> > > diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> > > index 096093f7be00..76900f67c782 100644
> > > --- a/drivers/mmc/core/host.c
> > > +++ b/drivers/mmc/core/host.c
> > > @@ -590,7 +590,7 @@ EXPORT_SYMBOL(mmc_alloc_host);
> > >
> > >   static void devm_mmc_host_release(struct device *dev, void *res)
> > >   {
> > > -   mmc_free_host(*(struct mmc_host **)res);
> > > +   mmc_free_host(res);
> >
> > The above chunk is wrong and causes following regression on today's
> > Linux next-20230324:
>
> Ugh...
>
> Ok.  I have a script that I use to help review mechanical patches.  I
> have added an '-r cast' option to help review "remove unnecessary cast"
> patches.
>
> If you do `cat this_email.txt | rename_rev.pl -r cast` then the output
> looks like:
>
> ================
>  static void devm_mmc_host_release(struct device *dev, void *res)
>  {
> -       mmc_free_host(*res);
> +       mmc_free_host(res);
>  }
>
>  struct mmc_host *devm_mmc_alloc_host(struct device *dev, int extra)
> ================
>
> I have gone through all of Yu Zhe's patches and the rest are okay.
>
> I've attached my rename_rev.pl script.

Thanks for helping out Dan! I will use your script next time!

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2] mmc: core: remove unnecessary (void*) conversions
  2023-03-17  6:47 [PATCH] mmc: core: remove unnecessary (void*) conversions Yu Zhe
  2023-03-23 12:13 ` Ulf Hansson
       [not found] ` <CGME20230324132858eucas1p25cdd6af81a14bf40474f58fa16d087f5@eucas1p2.samsung.com>
@ 2023-03-28  3:10 ` Yu Zhe
  2023-04-03 11:24   ` Ulf Hansson
  2 siblings, 1 reply; 10+ messages in thread
From: Yu Zhe @ 2023-03-28  3:10 UTC (permalink / raw)
  To: ulf.hansson, adrian.hunter, quic_sayalil, quic_c_sbhanu,
	quic_luliang, m.szyprowski, wsa+renesas, yebin10
  Cc: linux-mmc, linux-kernel, kernel-janitors, liqiong, Yu Zhe

Pointer variables of void * type do not require type cast.

Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 drivers/mmc/core/debugfs.c  | 2 +-
 drivers/mmc/core/mmc_test.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index fe6808771bc7..2c97b94aab23 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -246,7 +246,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(mmc_err_state, mmc_err_state_get, NULL, "%llu\n");
 
 static int mmc_err_stats_show(struct seq_file *file, void *data)
 {
-	struct mmc_host *host = (struct mmc_host *)file->private;
+	struct mmc_host *host = file->private;
 	const char *desc[MMC_ERR_MAX] = {
 		[MMC_ERR_CMD_TIMEOUT] = "Command Timeout Occurred",
 		[MMC_ERR_CMD_CRC] = "Command CRC Errors Occurred",
diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c
index 156d34b2ed4d..0f6a563103fd 100644
--- a/drivers/mmc/core/mmc_test.c
+++ b/drivers/mmc/core/mmc_test.c
@@ -3045,7 +3045,7 @@ static LIST_HEAD(mmc_test_file_test);
 
 static int mtf_test_show(struct seq_file *sf, void *data)
 {
-	struct mmc_card *card = (struct mmc_card *)sf->private;
+	struct mmc_card *card = sf->private;
 	struct mmc_test_general_result *gr;
 
 	mutex_lock(&mmc_test_lock);
@@ -3079,8 +3079,8 @@ static int mtf_test_open(struct inode *inode, struct file *file)
 static ssize_t mtf_test_write(struct file *file, const char __user *buf,
 	size_t count, loff_t *pos)
 {
-	struct seq_file *sf = (struct seq_file *)file->private_data;
-	struct mmc_card *card = (struct mmc_card *)sf->private;
+	struct seq_file *sf = file->private_data;
+	struct mmc_card *card = sf->private;
 	struct mmc_test_card *test;
 	long testcase;
 	int ret;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] mmc: core: remove unnecessary (void*) conversions
  2023-03-28  3:10 ` [PATCH v2] " Yu Zhe
@ 2023-04-03 11:24   ` Ulf Hansson
  2023-04-03 11:47     ` Yu Zhe
  0 siblings, 1 reply; 10+ messages in thread
From: Ulf Hansson @ 2023-04-03 11:24 UTC (permalink / raw)
  To: Yu Zhe
  Cc: adrian.hunter, quic_sayalil, quic_c_sbhanu, quic_luliang,
	m.szyprowski, wsa+renesas, yebin10, linux-mmc, linux-kernel,
	kernel-janitors, liqiong

On Tue, 28 Mar 2023 at 05:11, Yu Zhe <yuzhe@nfschina.com> wrote:
>
> Pointer variables of void * type do not require type cast.
>
> Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
> Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>

Did Marek give his reviewed-by tag offlist? I couldn't find his reply,
just to make sure this is correct?

Kind regards
Uffe

> ---
>  drivers/mmc/core/debugfs.c  | 2 +-
>  drivers/mmc/core/mmc_test.c | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
> index fe6808771bc7..2c97b94aab23 100644
> --- a/drivers/mmc/core/debugfs.c
> +++ b/drivers/mmc/core/debugfs.c
> @@ -246,7 +246,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(mmc_err_state, mmc_err_state_get, NULL, "%llu\n");
>
>  static int mmc_err_stats_show(struct seq_file *file, void *data)
>  {
> -       struct mmc_host *host = (struct mmc_host *)file->private;
> +       struct mmc_host *host = file->private;
>         const char *desc[MMC_ERR_MAX] = {
>                 [MMC_ERR_CMD_TIMEOUT] = "Command Timeout Occurred",
>                 [MMC_ERR_CMD_CRC] = "Command CRC Errors Occurred",
> diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c
> index 156d34b2ed4d..0f6a563103fd 100644
> --- a/drivers/mmc/core/mmc_test.c
> +++ b/drivers/mmc/core/mmc_test.c
> @@ -3045,7 +3045,7 @@ static LIST_HEAD(mmc_test_file_test);
>
>  static int mtf_test_show(struct seq_file *sf, void *data)
>  {
> -       struct mmc_card *card = (struct mmc_card *)sf->private;
> +       struct mmc_card *card = sf->private;
>         struct mmc_test_general_result *gr;
>
>         mutex_lock(&mmc_test_lock);
> @@ -3079,8 +3079,8 @@ static int mtf_test_open(struct inode *inode, struct file *file)
>  static ssize_t mtf_test_write(struct file *file, const char __user *buf,
>         size_t count, loff_t *pos)
>  {
> -       struct seq_file *sf = (struct seq_file *)file->private_data;
> -       struct mmc_card *card = (struct mmc_card *)sf->private;
> +       struct seq_file *sf = file->private_data;
> +       struct mmc_card *card = sf->private;
>         struct mmc_test_card *test;
>         long testcase;
>         int ret;
> --
> 2.11.0
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] mmc: core: remove unnecessary (void*) conversions
  2023-04-03 11:24   ` Ulf Hansson
@ 2023-04-03 11:47     ` Yu Zhe
  2023-04-03 12:35       ` Ulf Hansson
  0 siblings, 1 reply; 10+ messages in thread
From: Yu Zhe @ 2023-04-03 11:47 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: adrian.hunter, quic_sayalil, quic_luliang, m.szyprowski,
	wsa+renesas, yebin10, linux-mmc, linux-kernel, kernel-janitors,
	liqiong


> On Tue, 28 Mar 2023 at 05:11, Yu Zhe <yuzhe@nfschina.com> wrote:
>> Pointer variables of void * type do not require type cast.
>>
>> Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
>> Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Did Marek give his reviewed-by tag offlist? I couldn't find his reply,
> just to make sure this is correct?
>
> Kind regards
> Uffe


Sorry, it may be a misuse of "reviewed-by" tag,  "Marek Szyprowski" gave the error
report at the previous patch, so, i put the name at reviewed-by tag.

>
>> ---
>>   drivers/mmc/core/debugfs.c  | 2 +-
>>   drivers/mmc/core/mmc_test.c | 6 +++---
>>   2 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
>> index fe6808771bc7..2c97b94aab23 100644
>> --- a/drivers/mmc/core/debugfs.c
>> +++ b/drivers/mmc/core/debugfs.c
>> @@ -246,7 +246,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(mmc_err_state, mmc_err_state_get, NULL, "%llu\n");
>>
>>   static int mmc_err_stats_show(struct seq_file *file, void *data)
>>   {
>> -       struct mmc_host *host = (struct mmc_host *)file->private;
>> +       struct mmc_host *host = file->private;
>>          const char *desc[MMC_ERR_MAX] = {
>>                  [MMC_ERR_CMD_TIMEOUT] = "Command Timeout Occurred",
>>                  [MMC_ERR_CMD_CRC] = "Command CRC Errors Occurred",
>> diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c
>> index 156d34b2ed4d..0f6a563103fd 100644
>> --- a/drivers/mmc/core/mmc_test.c
>> +++ b/drivers/mmc/core/mmc_test.c
>> @@ -3045,7 +3045,7 @@ static LIST_HEAD(mmc_test_file_test);
>>
>>   static int mtf_test_show(struct seq_file *sf, void *data)
>>   {
>> -       struct mmc_card *card = (struct mmc_card *)sf->private;
>> +       struct mmc_card *card = sf->private;
>>          struct mmc_test_general_result *gr;
>>
>>          mutex_lock(&mmc_test_lock);
>> @@ -3079,8 +3079,8 @@ static int mtf_test_open(struct inode *inode, struct file *file)
>>   static ssize_t mtf_test_write(struct file *file, const char __user *buf,
>>          size_t count, loff_t *pos)
>>   {
>> -       struct seq_file *sf = (struct seq_file *)file->private_data;
>> -       struct mmc_card *card = (struct mmc_card *)sf->private;
>> +       struct seq_file *sf = file->private_data;
>> +       struct mmc_card *card = sf->private;
>>          struct mmc_test_card *test;
>>          long testcase;
>>          int ret;
>> --
>> 2.11.0
>>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] mmc: core: remove unnecessary (void*) conversions
  2023-04-03 11:47     ` Yu Zhe
@ 2023-04-03 12:35       ` Ulf Hansson
  0 siblings, 0 replies; 10+ messages in thread
From: Ulf Hansson @ 2023-04-03 12:35 UTC (permalink / raw)
  To: Yu Zhe
  Cc: adrian.hunter, quic_sayalil, quic_luliang, m.szyprowski,
	wsa+renesas, yebin10, linux-mmc, linux-kernel, kernel-janitors,
	liqiong

On Mon, 3 Apr 2023 at 14:13, Yu Zhe <yuzhe@nfschina.com> wrote:
>
>
> > On Tue, 28 Mar 2023 at 05:11, Yu Zhe <yuzhe@nfschina.com> wrote:
> >> Pointer variables of void * type do not require type cast.
> >>
> >> Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
> >> Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > Did Marek give his reviewed-by tag offlist? I couldn't find his reply,
> > just to make sure this is correct?
> >
> > Kind regards
> > Uffe
>
>
> Sorry, it may be a misuse of "reviewed-by" tag,  "Marek Szyprowski" gave the error
> report at the previous patch, so, i put the name at reviewed-by tag.

Yes, you shouldn't put his tag like this, unless he explicitly has said so.

For bug reports we use "Reported-by:", but in this case I decided it
was better to drop the offending commit, which means this isn't
applicable here.

Anyway, there is no need to resend, I will just drop the tag when applying.

Kind regards
Uffe

>
> >
> >> ---
> >>   drivers/mmc/core/debugfs.c  | 2 +-
> >>   drivers/mmc/core/mmc_test.c | 6 +++---
> >>   2 files changed, 4 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
> >> index fe6808771bc7..2c97b94aab23 100644
> >> --- a/drivers/mmc/core/debugfs.c
> >> +++ b/drivers/mmc/core/debugfs.c
> >> @@ -246,7 +246,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(mmc_err_state, mmc_err_state_get, NULL, "%llu\n");
> >>
> >>   static int mmc_err_stats_show(struct seq_file *file, void *data)
> >>   {
> >> -       struct mmc_host *host = (struct mmc_host *)file->private;
> >> +       struct mmc_host *host = file->private;
> >>          const char *desc[MMC_ERR_MAX] = {
> >>                  [MMC_ERR_CMD_TIMEOUT] = "Command Timeout Occurred",
> >>                  [MMC_ERR_CMD_CRC] = "Command CRC Errors Occurred",
> >> diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c
> >> index 156d34b2ed4d..0f6a563103fd 100644
> >> --- a/drivers/mmc/core/mmc_test.c
> >> +++ b/drivers/mmc/core/mmc_test.c
> >> @@ -3045,7 +3045,7 @@ static LIST_HEAD(mmc_test_file_test);
> >>
> >>   static int mtf_test_show(struct seq_file *sf, void *data)
> >>   {
> >> -       struct mmc_card *card = (struct mmc_card *)sf->private;
> >> +       struct mmc_card *card = sf->private;
> >>          struct mmc_test_general_result *gr;
> >>
> >>          mutex_lock(&mmc_test_lock);
> >> @@ -3079,8 +3079,8 @@ static int mtf_test_open(struct inode *inode, struct file *file)
> >>   static ssize_t mtf_test_write(struct file *file, const char __user *buf,
> >>          size_t count, loff_t *pos)
> >>   {
> >> -       struct seq_file *sf = (struct seq_file *)file->private_data;
> >> -       struct mmc_card *card = (struct mmc_card *)sf->private;
> >> +       struct seq_file *sf = file->private_data;
> >> +       struct mmc_card *card = sf->private;
> >>          struct mmc_test_card *test;
> >>          long testcase;
> >>          int ret;
> >> --
> >> 2.11.0
> >>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-04-03 12:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17  6:47 [PATCH] mmc: core: remove unnecessary (void*) conversions Yu Zhe
2023-03-23 12:13 ` Ulf Hansson
     [not found] ` <CGME20230324132858eucas1p25cdd6af81a14bf40474f58fa16d087f5@eucas1p2.samsung.com>
2023-03-24 13:28   ` Marek Szyprowski
2023-03-24 15:46     ` Ulf Hansson
2023-03-24 16:39     ` Dan Carpenter
2023-03-27 10:26       ` Ulf Hansson
2023-03-28  3:10 ` [PATCH v2] " Yu Zhe
2023-04-03 11:24   ` Ulf Hansson
2023-04-03 11:47     ` Yu Zhe
2023-04-03 12:35       ` Ulf Hansson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.