The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Petr Mladek <pmladek@suse.com>
Cc: I Hsin Cheng <richard120310@gmail.com>,
	rostedt@goodmis.org, linux@rasmusvillemoes.dk,
	senozhatsky@chromium.org, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org, jserv@ccns.ncku.edu.tw,
	shuah@kernel.org
Subject: Re: [PATCH] vsprintf: Drop unused assignment of fmt.state
Date: Mon, 10 Feb 2025 17:08:25 +0200	[thread overview]
Message-ID: <Z6oWaZl7DRoW0tDK@smile.fi.intel.com> (raw)
In-Reply-To: <Z6n6iWwnpA6wuUMD@pathway.suse.cz>

On Mon, Feb 10, 2025 at 02:09:53PM +0100, Petr Mladek wrote:
> On Thu 2025-02-06 17:32:32, Andy Shevchenko wrote:
> > On Thu, Feb 06, 2025 at 01:25:07AM +0800, I Hsin Cheng wrote:
> > > Remove unused assignment of "fmt.state", in both cases the value of
> > > "fmt.state" will be overwritten by either "FORMAT_STATE_PRECISION" or
> > > "FORMAT_STATE_NUM", the value "FORMAT_STATE_NONE" isn't going to be used
> > > after the assignment.

...

> > > struct fmt format_decode(struct fmt fmt, struct printf_spec *spec)
> > 
> > >  			spec->field_width = -spec->field_width;
> > >  			spec->flags |= LEFT;
> > >  		}
> > > -		fmt.state = FORMAT_STATE_NONE;
> > > +
> > >  		goto precision;
> > >  	}
> > >  
> > 
> > While both are kinda redundant, this is not obvious what's stated in the commit
> > message. Yes, `goto qualifier;` is straightforward, but not `goto precision;`.
> > Which makes me think that these assignments can make code robust against
> > potential future changes to allow to catch up the wrong code paths.
> 
> I fully agree with Andy here.
> 
> That said, I see the following right below the two conditions modified
> in this patch:
> 
> 	/* By default */
> 	fmt.state = FORMAT_STATE_NONE;
> 
> A good solution would be to move it up. It will be then obvious
> that we could remove these two initializations. I mean
> to do the following:

Which can't be performed (one need to check the old value first somehow) :-)

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-02-10 15:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 17:25 [PATCH] vsprintf: Drop unused assignment of fmt.state I Hsin Cheng
2025-02-06 15:32 ` Andy Shevchenko
2025-02-10  8:15   ` I Hsin Cheng
2025-02-10 13:09   ` Petr Mladek
2025-02-10 15:08     ` Andy Shevchenko [this message]
2025-02-12 12:29       ` Petr Mladek

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=Z6oWaZl7DRoW0tDK@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=jserv@ccns.ncku.edu.tw \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=pmladek@suse.com \
    --cc=richard120310@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=shuah@kernel.org \
    /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