mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Yongxin Yang <yangyongxin@kylinos.cn>
Cc: Bradley Morgan <include@grrlz.net>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] perf/profile: Remove unused local variable err
Date: Tue, 3 Nov 2026 23:58:51 -0800	[thread overview]
Message-ID: <20261103235851.b6f437ab7e0a82530555ef32@linux-foundation.org> (raw)
In-Reply-To: <20261104071402.1543517-1-yangyongxin@kylinos.cn>

On Wed,  4 Nov 2026 15:14:02 +0800 Yongxin Yang <yangyongxin@kylinos.cn> wrote:

> In create_proc_profile() the local variable err is only ever assigned 0 and
> then returned, so it can never hold anything but 0.  Drop it and return 0
> directly.
> 
> No functional change.
> 
> ...
>
> --- a/kernel/profile.c
> +++ b/kernel/profile.c
> @@ -240,7 +240,6 @@ static const struct proc_ops profile_proc_ops = {
>  int __ref create_proc_profile(void)
>  {
>  	struct proc_dir_entry *entry;
> -	int err = 0;
>  
>  	if (!prof_on)
>  		return 0;
> @@ -248,7 +247,7 @@ int __ref create_proc_profile(void)
>  			    NULL, &profile_proc_ops);
>  	if (entry)
>  		proc_set_size(entry, (1 + prof_len) * sizeof(atomic_t));
> -	return err;
> +	return 0;
>  }

Well.  If proc_create() returned error (entry==NULL) then should
create_proc_profile() just drop that information on the floor and
pretend that everything worked?

Would it be better to return an error from create_proc_profile() in
this situation?  Doing that that would require auditing the caller's
handling of this and hoping that the caller reports the failure in an
appropriate fashion.  If not then reporting the error from within
create_proc_profile() would be better than simple silence.


  reply	other threads:[~2026-11-04  7:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24  2:42 [PATCH] " yang_yongxin123
2026-08-24 10:01 ` Bradley Morgan
2026-11-04  7:14 ` [PATCH v2] " Yongxin Yang
2026-11-04  7:58   ` Andrew Morton [this message]
2026-11-04  9:32 ` [PATCH v3] perf/profile: Report failure to create /proc/profile Yongxin Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261103235851.b6f437ab7e0a82530555ef32@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=include@grrlz.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yangyongxin@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®