diff mbox series

[06/13] checkpolicy: follow declaration-after-statement

Message ID 20210706175433.29270-6-cgzones@googlemail.com (mailing list archive)
State Accepted
Headers show
Series [01/13] checkpolicy: pass CFLAGS at link stage | expand

Commit Message

Christian Göttsche July 6, 2021, 5:54 p.m. UTC
Follow the project style of no declaration after statement.

Found by the GCC warning -Wdeclaration-after-statement.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 checkpolicy/checkmodule.c   | 6 ++++--
 checkpolicy/policy_define.c | 3 ++-
 checkpolicy/test/dismod.c   | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

Comments

Nicolas Iooss July 12, 2021, 7:13 a.m. UTC | #1
On Tue, Jul 6, 2021 at 7:54 PM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> Follow the project style of no declaration after statement.
>
> Found by the GCC warning -Wdeclaration-after-statement.
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
> ---
>  checkpolicy/checkmodule.c   | 6 ++++--
>  checkpolicy/policy_define.c | 3 ++-
>  checkpolicy/test/dismod.c   | 2 +-
>  3 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/checkpolicy/checkmodule.c b/checkpolicy/checkmodule.c
> index 40d0ec99..316b2898 100644
> --- a/checkpolicy/checkmodule.c
> +++ b/checkpolicy/checkmodule.c
> @@ -288,14 +288,16 @@ int main(int argc, char **argv)
>         }
>
>         if (policy_type != POLICY_BASE && outfile) {
> +               char *out_name;
> +               char *separator;
>                 char *mod_name = modpolicydb.name;
>                 char *out_path = strdup(outfile);
>                 if (out_path == NULL) {
>                         fprintf(stderr, "%s:  out of memory\n", argv[0]);
>                         exit(1);
>                 }
> -               char *out_name = basename(out_path);
> -               char *separator = strrchr(out_name, '.');
> +               out_name = basename(out_path);
> +               separator = strrchr(out_name, '.');
>                 if (separator) {
>                         *separator = '\0';
>                 }
> diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c
> index 7eff747a..22218c07 100644
> --- a/checkpolicy/policy_define.c
> +++ b/checkpolicy/policy_define.c
> @@ -1904,8 +1904,9 @@ int avrule_read_ioctls(struct av_ioctl_range_list **rangehead)
>  {
>         char *id;
>         struct av_ioctl_range_list *rnew, *r = NULL;
> -       *rangehead = NULL;
>         uint8_t omit = 0;
> +
> +       *rangehead = NULL;

Hello,
All the patches of this series look good to me. But here, you
introduced trailing tabs, which is reported by "git am" when applying
the patch:

        .git/rebase-apply/patch:40: trailing whitespace.

        .git/rebase-apply/patch:41: trailing whitespace.
                *rangehead = NULL;
        warning: 2 lines add whitespace errors.

Anyway I can remove these tabs when applying this patch.

Acked-by: Nicolas Iooss <nicolas.iooss@m4x.org>

If nobody else has comments, I will apply them tomorrow.
Thanks!
Nicolas
Nicolas Iooss July 13, 2021, 7:59 p.m. UTC | #2
On Mon, Jul 12, 2021 at 9:13 AM Nicolas Iooss <nicolas.iooss@m4x.org> wrote:
>
> On Tue, Jul 6, 2021 at 7:54 PM Christian Göttsche
> <cgzones@googlemail.com> wrote:
> >
> > Follow the project style of no declaration after statement.
> >
> > Found by the GCC warning -Wdeclaration-after-statement.
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
> > ---
> >  checkpolicy/checkmodule.c   | 6 ++++--
> >  checkpolicy/policy_define.c | 3 ++-
> >  checkpolicy/test/dismod.c   | 2 +-
> >  3 files changed, 7 insertions(+), 4 deletions(-)
> >
> > diff --git a/checkpolicy/checkmodule.c b/checkpolicy/checkmodule.c
> > index 40d0ec99..316b2898 100644
> > --- a/checkpolicy/checkmodule.c
> > +++ b/checkpolicy/checkmodule.c
> > @@ -288,14 +288,16 @@ int main(int argc, char **argv)
> >         }
> >
> >         if (policy_type != POLICY_BASE && outfile) {
> > +               char *out_name;
> > +               char *separator;
> >                 char *mod_name = modpolicydb.name;
> >                 char *out_path = strdup(outfile);
> >                 if (out_path == NULL) {
> >                         fprintf(stderr, "%s:  out of memory\n", argv[0]);
> >                         exit(1);
> >                 }
> > -               char *out_name = basename(out_path);
> > -               char *separator = strrchr(out_name, '.');
> > +               out_name = basename(out_path);
> > +               separator = strrchr(out_name, '.');
> >                 if (separator) {
> >                         *separator = '\0';
> >                 }
> > diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c
> > index 7eff747a..22218c07 100644
> > --- a/checkpolicy/policy_define.c
> > +++ b/checkpolicy/policy_define.c
> > @@ -1904,8 +1904,9 @@ int avrule_read_ioctls(struct av_ioctl_range_list **rangehead)
> >  {
> >         char *id;
> >         struct av_ioctl_range_list *rnew, *r = NULL;
> > -       *rangehead = NULL;
> >         uint8_t omit = 0;
> > +
> > +       *rangehead = NULL;
>
> Hello,
> All the patches of this series look good to me. But here, you
> introduced trailing tabs, which is reported by "git am" when applying
> the patch:
>
>         .git/rebase-apply/patch:40: trailing whitespace.
>
>         .git/rebase-apply/patch:41: trailing whitespace.
>                 *rangehead = NULL;
>         warning: 2 lines add whitespace errors.
>
> Anyway I can remove these tabs when applying this patch.
>
> Acked-by: Nicolas Iooss <nicolas.iooss@m4x.org>
>
> If nobody else has comments, I will apply them tomorrow.
> Thanks!
> Nicolas

Merged with the trailing whitespaces removed.
Thanks!
Nicolas
diff mbox series

Patch

diff --git a/checkpolicy/checkmodule.c b/checkpolicy/checkmodule.c
index 40d0ec99..316b2898 100644
--- a/checkpolicy/checkmodule.c
+++ b/checkpolicy/checkmodule.c
@@ -288,14 +288,16 @@  int main(int argc, char **argv)
 	}
 
 	if (policy_type != POLICY_BASE && outfile) {
+		char *out_name;
+		char *separator;
 		char *mod_name = modpolicydb.name;
 		char *out_path = strdup(outfile);
 		if (out_path == NULL) {
 			fprintf(stderr, "%s:  out of memory\n", argv[0]);
 			exit(1);
 		}
-		char *out_name = basename(out_path);
-		char *separator = strrchr(out_name, '.');
+		out_name = basename(out_path);
+		separator = strrchr(out_name, '.');
 		if (separator) {
 			*separator = '\0';
 		}
diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c
index 7eff747a..22218c07 100644
--- a/checkpolicy/policy_define.c
+++ b/checkpolicy/policy_define.c
@@ -1904,8 +1904,9 @@  int avrule_read_ioctls(struct av_ioctl_range_list **rangehead)
 {
 	char *id;
 	struct av_ioctl_range_list *rnew, *r = NULL;
-	*rangehead = NULL;
 	uint8_t omit = 0;
+	
+	*rangehead = NULL;	
 
 	/* read in all the ioctl commands */
 	while ((id = queue_remove(id_queue))) {
diff --git a/checkpolicy/test/dismod.c b/checkpolicy/test/dismod.c
index fadbc8d1..b1b96115 100644
--- a/checkpolicy/test/dismod.c
+++ b/checkpolicy/test/dismod.c
@@ -697,8 +697,8 @@  int display_avblock(int field, policydb_t * policy,
 {
 	avrule_block_t *block = policydb.global;
 	while (block != NULL) {
-		fprintf(out_fp, "--- begin avrule block ---\n");
 		avrule_decl_t *decl = block->branch_list;
+		fprintf(out_fp, "--- begin avrule block ---\n");
 		while (decl != NULL) {
 			if (display_avdecl(decl, field, policy, out_fp)) {
 				return -1;