* [refpolicy] [PATCH v2] fc_sort: avoid compiler warning/error
2017-06-05 15:04 ` [refpolicy] [PATCH v2] " Guido Trentalancia
@ 2017-06-05 14:20 ` Christian Göttsche
2017-06-05 15:22 ` Guido Trentalancia
2017-06-05 16:31 ` Jason Zaman
2017-06-05 22:08 ` [refpolicy] [PATCH v3] " Guido Trentalancia
2 siblings, 1 reply; 9+ messages in thread
From: Christian Göttsche @ 2017-06-05 14:20 UTC (permalink / raw)
To: refpolicy
Or maybe just add a comment /*FALLTHRU*/ ?
This should silence the warning.
https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/
On 5 Jun 2017 3:04 pm, "Guido Trentalancia via refpolicy" <
refpolicy@oss.tresys.com> wrote:
> Fix a "-Werror=implicit-fallthrough" compiler warning/error on
> the switch statement.
>
> This second version (v2) fixes a bug introduced with the previous
> version.
>
> Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
> ---
> support/fc_sort.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> --- a/support/fc_sort.c 2017-03-29 17:57:54.576386420 +0200
> +++ b/support/fc_sort.c 2017-06-05 17:01:44.818724998 +0200
> @@ -292,6 +292,11 @@ void fc_fill_data(file_context_node_t *f
> /* If a escape character is found,
> * skip the next character. */
> c++;
> + /* If no meta character has been found yet,
> + * add one to the stem length. */
> + if (!fc_node->meta)
> + fc_node->stem_len++;
> + break;
> default:
> /* If no meta character has been found yet,
> * add one to the stem length. */
> _______________________________________________
> refpolicy mailing list
> refpolicy at oss.tresys.com
> http://oss.tresys.com/mailman/listinfo/refpolicy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://oss.tresys.com/pipermail/refpolicy/attachments/20170605/f8516853/attachment-0001.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* [refpolicy] [PATCH] fc_sort: avoid compiler warning/error
@ 2017-06-05 14:56 Guido Trentalancia
2017-06-05 15:04 ` [refpolicy] [PATCH v2] " Guido Trentalancia
0 siblings, 1 reply; 9+ messages in thread
From: Guido Trentalancia @ 2017-06-05 14:56 UTC (permalink / raw)
To: refpolicy
Fix a "-Werror=implicit-fallthrough" compiler warning/error on
the switch statement.
Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
---
support/fc_sort.c | 1 +
1 file changed, 1 insertion(+)
--- a/support/fc_sort.c 2017-03-29 17:57:54.576386420 +0200
+++ b/support/fc_sort.c 2017-06-05 16:43:51.623729385 +0200
@@ -292,6 +292,7 @@ void fc_fill_data(file_context_node_t *f
/* If a escape character is found,
* skip the next character. */
c++;
+ break;
default:
/* If no meta character has been found yet,
* add one to the stem length. */
^ permalink raw reply [flat|nested] 9+ messages in thread
* [refpolicy] [PATCH v2] fc_sort: avoid compiler warning/error
2017-06-05 14:56 [refpolicy] [PATCH] fc_sort: avoid compiler warning/error Guido Trentalancia
@ 2017-06-05 15:04 ` Guido Trentalancia
2017-06-05 14:20 ` Christian Göttsche
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Guido Trentalancia @ 2017-06-05 15:04 UTC (permalink / raw)
To: refpolicy
Fix a "-Werror=implicit-fallthrough" compiler warning/error on
the switch statement.
This second version (v2) fixes a bug introduced with the previous
version.
Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
---
support/fc_sort.c | 5 +++++
1 file changed, 5 insertions(+)
--- a/support/fc_sort.c 2017-03-29 17:57:54.576386420 +0200
+++ b/support/fc_sort.c 2017-06-05 17:01:44.818724998 +0200
@@ -292,6 +292,11 @@ void fc_fill_data(file_context_node_t *f
/* If a escape character is found,
* skip the next character. */
c++;
+ /* If no meta character has been found yet,
+ * add one to the stem length. */
+ if (!fc_node->meta)
+ fc_node->stem_len++;
+ break;
default:
/* If no meta character has been found yet,
* add one to the stem length. */
^ permalink raw reply [flat|nested] 9+ messages in thread
* [refpolicy] [PATCH v2] fc_sort: avoid compiler warning/error
2017-06-05 14:20 ` Christian Göttsche
@ 2017-06-05 15:22 ` Guido Trentalancia
0 siblings, 0 replies; 9+ messages in thread
From: Guido Trentalancia @ 2017-06-05 15:22 UTC (permalink / raw)
To: refpolicy
Hello,
thanks for telling me about this option, but I prefer to leave things as they are, without being too much specific to the particular compiler.
Regards,
Guido
On the 5th of June 2017 16:20:15 CEST, "Christian G?ttsche" <cgzones@googlemail.com> wrote:
>Or maybe just add a comment /*FALLTHRU*/ ?
>This should silence the warning.
>
>https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/
>
>On 5 Jun 2017 3:04 pm, "Guido Trentalancia via refpolicy" <
>refpolicy at oss.tresys.com> wrote:
>
>> Fix a "-Werror=implicit-fallthrough" compiler warning/error on
>> the switch statement.
>>
>> This second version (v2) fixes a bug introduced with the previous
>> version.
>>
>> Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
>> ---
>> support/fc_sort.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> --- a/support/fc_sort.c 2017-03-29 17:57:54.576386420 +0200
>> +++ b/support/fc_sort.c 2017-06-05 17:01:44.818724998 +0200
>> @@ -292,6 +292,11 @@ void fc_fill_data(file_context_node_t *f
>> /* If a escape character is found,
>> * skip the next character. */
>> c++;
>> + /* If no meta character has been found yet,
>> + * add one to the stem length. */
>> + if (!fc_node->meta)
>> + fc_node->stem_len++;
>> + break;
>> default:
>> /* If no meta character has been found yet,
>> * add one to the stem length. */
>> _______________________________________________
>> refpolicy mailing list
>> refpolicy at oss.tresys.com
>> http://oss.tresys.com/mailman/listinfo/refpolicy
>>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [refpolicy] [PATCH v2] fc_sort: avoid compiler warning/error
2017-06-05 15:04 ` [refpolicy] [PATCH v2] " Guido Trentalancia
2017-06-05 14:20 ` Christian Göttsche
@ 2017-06-05 16:31 ` Jason Zaman
2017-06-05 22:08 ` [refpolicy] [PATCH v3] " Guido Trentalancia
2 siblings, 0 replies; 9+ messages in thread
From: Jason Zaman @ 2017-06-05 16:31 UTC (permalink / raw)
To: refpolicy
On Mon, Jun 05, 2017 at 05:04:53PM +0200, Guido Trentalancia via refpolicy wrote:
> Fix a "-Werror=implicit-fallthrough" compiler warning/error on
> the switch statement.
>
> This second version (v2) fixes a bug introduced with the previous
> version.
>
> Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
> ---
> support/fc_sort.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> --- a/support/fc_sort.c 2017-03-29 17:57:54.576386420 +0200
> +++ b/support/fc_sort.c 2017-06-05 17:01:44.818724998 +0200
> @@ -292,6 +292,11 @@ void fc_fill_data(file_context_node_t *f
> /* If a escape character is found,
> * skip the next character. */
> c++;
> + /* If no meta character has been found yet,
> + * add one to the stem length. */
> + if (!fc_node->meta)
> + fc_node->stem_len++;
> + break;
Why not just add /* -fallthrough */ instead of the break?
Seems more maintainable than duplicating the code in case something
changes later.
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
-- Jason
> default:
> /* If no meta character has been found yet,
> * add one to the stem length. */
> _______________________________________________
> refpolicy mailing list
> refpolicy at oss.tresys.com
> http://oss.tresys.com/mailman/listinfo/refpolicy
^ permalink raw reply [flat|nested] 9+ messages in thread
* [refpolicy] [PATCH v3] fc_sort: avoid compiler warning/error
2017-06-05 15:04 ` [refpolicy] [PATCH v2] " Guido Trentalancia
2017-06-05 14:20 ` Christian Göttsche
2017-06-05 16:31 ` Jason Zaman
@ 2017-06-05 22:08 ` Guido Trentalancia
2017-06-07 0:07 ` Chris PeBenito
2017-06-07 23:16 ` Chris PeBenito
2 siblings, 2 replies; 9+ messages in thread
From: Guido Trentalancia @ 2017-06-05 22:08 UTC (permalink / raw)
To: refpolicy
Fix a "-Werror=implicit-fallthrough" compiler warning/error on
the switch statement.
This third version (v3) fixes a bug introduced in the first
version and improves the style over the second version.
Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
---
support/fc_sort.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
--- a/support/fc_sort.c 2017-06-05 23:49:57.280624866 +0200
+++ b/support/fc_sort.c 2017-06-06 00:04:48.419621222 +0200
@@ -292,14 +292,16 @@ void fc_fill_data(file_context_node_t *f
/* If a escape character is found,
* skip the next character. */
c++;
+ break;
default:
- /* If no meta character has been found yet,
- * add one to the stem length. */
- if (!fc_node->meta)
- fc_node->stem_len++;
break;
}
+ /* If no meta character has been found yet,
+ * add one to the stem length. */
+ if (!fc_node->meta)
+ fc_node->stem_len++;
+
fc_node->str_len++;
c++;
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* [refpolicy] [PATCH v3] fc_sort: avoid compiler warning/error
2017-06-05 22:08 ` [refpolicy] [PATCH v3] " Guido Trentalancia
@ 2017-06-07 0:07 ` Chris PeBenito
2017-06-07 5:27 ` Guido Trentalancia
2017-06-07 23:16 ` Chris PeBenito
1 sibling, 1 reply; 9+ messages in thread
From: Chris PeBenito @ 2017-06-07 0:07 UTC (permalink / raw)
To: refpolicy
On 06/05/2017 06:08 PM, Guido Trentalancia via refpolicy wrote:
> Fix a "-Werror=implicit-fallthrough" compiler warning/error on
> the switch statement.
>
> This third version (v3) fixes a bug introduced in the first
> version and improves the style over the second version.
>
> Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
> ---
> support/fc_sort.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> --- a/support/fc_sort.c 2017-06-05 23:49:57.280624866 +0200
> +++ b/support/fc_sort.c 2017-06-06 00:04:48.419621222 +0200
> @@ -292,14 +292,16 @@ void fc_fill_data(file_context_node_t *f
> /* If a escape character is found,
> * skip the next character. */
> c++;
> + break;
> default:
> - /* If no meta character has been found yet,
> - * add one to the stem length. */
> - if (!fc_node->meta)
> - fc_node->stem_len++;
> break;
> }
>
> + /* If no meta character has been found yet,
> + * add one to the stem length. */
> + if (!fc_node->meta)
> + fc_node->stem_len++;
> +
> fc_node->str_len++;
> c++;
> }
This doesn't look like a valid change since the block you're doing
shouldn't be done if the current character is a metacharacter.
--
Chris PeBenito
^ permalink raw reply [flat|nested] 9+ messages in thread
* [refpolicy] [PATCH v3] fc_sort: avoid compiler warning/error
2017-06-07 0:07 ` Chris PeBenito
@ 2017-06-07 5:27 ` Guido Trentalancia
0 siblings, 0 replies; 9+ messages in thread
From: Guido Trentalancia @ 2017-06-07 5:27 UTC (permalink / raw)
To: refpolicy
Hello.
My reply follows the quoted message...
On the 7th of June 2017 02:07:49 CEST, Chris PeBenito <pebenito@ieee.org> wrote:
>On 06/05/2017 06:08 PM, Guido Trentalancia via refpolicy wrote:
>> Fix a "-Werror=implicit-fallthrough" compiler warning/error on
>> the switch statement.
>>
>> This third version (v3) fixes a bug introduced in the first
>> version and improves the style over the second version.
>>
>> Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
>> ---
>> support/fc_sort.c | 10 ++++++----
>> 1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> --- a/support/fc_sort.c 2017-06-05 23:49:57.280624866 +0200
>> +++ b/support/fc_sort.c 2017-06-06 00:04:48.419621222 +0200
>> @@ -292,14 +292,16 @@ void fc_fill_data(file_context_node_t *f
>> /* If a escape character is found,
>> * skip the next character. */
>> c++;
>> + break;
>> default:
>> - /* If no meta character has been found yet,
>> - * add one to the stem length. */
>> - if (!fc_node->meta)
>> - fc_node->stem_len++;
>> break;
>> }
>>
>> + /* If no meta character has been found yet,
>> + * add one to the stem length. */
>> + if (!fc_node->meta)
>> + fc_node->stem_len++;
>> +
>> fc_node->str_len++;
>> c++;
>> }
>
>This doesn't look like a valid change since the block you're doing
>shouldn't be done if the current character is a metacharacter.
fc_node->stem_len is incremented only if fc_node->meta is zero or, in other words, only if a metacharacter has not been found yet (a condition which does NOT include the case of the current character being a metacharacter).
So the "if" block that I simply moved out of the "switch" statement, but inside the "while" loop, is NOT executed if the current character is a metacharacter (because in such case fc_node->meta is one and not zero) !
I hope this helps.... Please consider that, as it is, the fc_sort code does not compile and the Reference Policy is thus unusable.
Regards,
Guido
^ permalink raw reply [flat|nested] 9+ messages in thread
* [refpolicy] [PATCH v3] fc_sort: avoid compiler warning/error
2017-06-05 22:08 ` [refpolicy] [PATCH v3] " Guido Trentalancia
2017-06-07 0:07 ` Chris PeBenito
@ 2017-06-07 23:16 ` Chris PeBenito
1 sibling, 0 replies; 9+ messages in thread
From: Chris PeBenito @ 2017-06-07 23:16 UTC (permalink / raw)
To: refpolicy
On 06/05/2017 06:08 PM, Guido Trentalancia via refpolicy wrote:
> Fix a "-Werror=implicit-fallthrough" compiler warning/error on
> the switch statement.
>
> This third version (v3) fixes a bug introduced in the first
> version and improves the style over the second version.
>
> Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
> ---
> support/fc_sort.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> --- a/support/fc_sort.c 2017-06-05 23:49:57.280624866 +0200
> +++ b/support/fc_sort.c 2017-06-06 00:04:48.419621222 +0200
> @@ -292,14 +292,16 @@ void fc_fill_data(file_context_node_t *f
> /* If a escape character is found,
> * skip the next character. */
> c++;
> + break;
> default:
> - /* If no meta character has been found yet,
> - * add one to the stem length. */
> - if (!fc_node->meta)
> - fc_node->stem_len++;
> break;
> }
>
> + /* If no meta character has been found yet,
> + * add one to the stem length. */
> + if (!fc_node->meta)
> + fc_node->stem_len++;
> +
> fc_node->str_len++;
> c++;
> }
Merged.
--
Chris PeBenito
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-06-07 23:16 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-05 14:56 [refpolicy] [PATCH] fc_sort: avoid compiler warning/error Guido Trentalancia
2017-06-05 15:04 ` [refpolicy] [PATCH v2] " Guido Trentalancia
2017-06-05 14:20 ` Christian Göttsche
2017-06-05 15:22 ` Guido Trentalancia
2017-06-05 16:31 ` Jason Zaman
2017-06-05 22:08 ` [refpolicy] [PATCH v3] " Guido Trentalancia
2017-06-07 0:07 ` Chris PeBenito
2017-06-07 5:27 ` Guido Trentalancia
2017-06-07 23:16 ` Chris PeBenito
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.