diff mbox

Add FALLTHRU to gimple-ssa-sprintf.c

Message ID 20160921105233.GI19950@redhat.com
State New
Headers show

Commit Message

Marek Polacek Sept. 21, 2016, 10:52 a.m. UTC
Pointed out by Tobias.  This looks like a missing fallthru marker.

Ok?

2016-09-21  Marek Polacek  <polacek@redhat.com>

	* gimple-ssa-sprintf.c (pass_sprintf_length::compute_format_length):
	Add falls through comment.


	Marek

Comments

Jakub Jelinek Sept. 21, 2016, 10:57 a.m. UTC | #1
On Wed, Sep 21, 2016 at 12:52:33PM +0200, Marek Polacek wrote:
> Pointed out by Tobias.  This looks like a missing fallthru marker.
> 
> Ok?
> 
> 2016-09-21  Marek Polacek  <polacek@redhat.com>
> 
> 	* gimple-ssa-sprintf.c (pass_sprintf_length::compute_format_length):
> 	Add falls through comment.

This is obvious.

> diff --git gcc/gimple-ssa-sprintf.c gcc/gimple-ssa-sprintf.c
> index 0afcf68..dddb026 100644
> --- gcc/gimple-ssa-sprintf.c
> +++ gcc/gimple-ssa-sprintf.c
> @@ -2260,6 +2260,7 @@ pass_sprintf_length::compute_format_length (const call_info &info,
>  	case '\0':
>  	  --pf;
>  	  res->bounded = false;
> +	  /* FALLTHRU */
>  	case '%':
>  	  spec.fmtfunc = format_percent;
>  	  break;
> 
> 	Marek

	Jakub
Marek Polacek Sept. 21, 2016, 11:07 a.m. UTC | #2
On Wed, Sep 21, 2016 at 12:57:23PM +0200, Jakub Jelinek wrote:
> On Wed, Sep 21, 2016 at 12:52:33PM +0200, Marek Polacek wrote:
> > Pointed out by Tobias.  This looks like a missing fallthru marker.
> > 
> > Ok?
> > 
> > 2016-09-21  Marek Polacek  <polacek@redhat.com>
> > 
> > 	* gimple-ssa-sprintf.c (pass_sprintf_length::compute_format_length):
> > 	Add falls through comment.
> 
> This is obvious.

I wanted to give Martin a chance to comment, maybe it should've been
a break, but I'll commit this now.  Thanks.

	Marek
Jakub Jelinek Sept. 21, 2016, 11:11 a.m. UTC | #3
On Wed, Sep 21, 2016 at 01:07:20PM +0200, Marek Polacek wrote:
> On Wed, Sep 21, 2016 at 12:57:23PM +0200, Jakub Jelinek wrote:
> > On Wed, Sep 21, 2016 at 12:52:33PM +0200, Marek Polacek wrote:
> > > Pointed out by Tobias.  This looks like a missing fallthru marker.
> > > 
> > > Ok?
> > > 
> > > 2016-09-21  Marek Polacek  <polacek@redhat.com>
> > > 
> > > 	* gimple-ssa-sprintf.c (pass_sprintf_length::compute_format_length):
> > > 	Add falls through comment.
> > 
> > This is obvious.
> 
> I wanted to give Martin a chance to comment, maybe it should've been
> a break, but I'll commit this now.  Thanks.

Well, generally it isn't obvious, but in this case IMHO it is, in the light
of the comment:
          /* Handle a sole '%' character the same as "%%" but since it's
             undefined prevent the result from being folded.  */
        case '\0':
          --pf;
          res->bounded = false;
        case '%':
          spec.fmtfunc = format_percent;
          break;
so, what it does for "...%" is that it decreases the char pointer, so it
acts almost like "...%%" - spec.specifier = *pf++; will be also '%' and
pf afterwards will point after it.

	Jakub
Martin Sebor Sept. 21, 2016, 2:56 p.m. UTC | #4
On 09/21/2016 05:07 AM, Marek Polacek wrote:
> On Wed, Sep 21, 2016 at 12:57:23PM +0200, Jakub Jelinek wrote:
>> On Wed, Sep 21, 2016 at 12:52:33PM +0200, Marek Polacek wrote:
>>> Pointed out by Tobias.  This looks like a missing fallthru marker.
>>>
>>> Ok?
>>>
>>> 2016-09-21  Marek Polacek  <polacek@redhat.com>
>>>
>>> 	* gimple-ssa-sprintf.c (pass_sprintf_length::compute_format_length):
>>> 	Add falls through comment.
>>
>> This is obvious.
>
> I wanted to give Martin a chance to comment, maybe it should've been
> a break, but I'll commit this now.  Thanks.

Yes, falling through is intentional here and should have probably
been better documented.  Thanks for taking care of it!

Martin
diff mbox

Patch

diff --git gcc/gimple-ssa-sprintf.c gcc/gimple-ssa-sprintf.c
index 0afcf68..dddb026 100644
--- gcc/gimple-ssa-sprintf.c
+++ gcc/gimple-ssa-sprintf.c
@@ -2260,6 +2260,7 @@  pass_sprintf_length::compute_format_length (const call_info &info,
 	case '\0':
 	  --pf;
 	  res->bounded = false;
+	  /* FALLTHRU */
 	case '%':
 	  spec.fmtfunc = format_percent;
 	  break;