diff mbox series

[RFC,v2,11/27] libselinux/utils: use type safe union assignment

Message ID 20230814132025.45364-12-cgzones@googlemail.com (mailing list archive)
State Accepted
Commit f1a8afc272fe
Delegated to: Petr Lautrbach
Headers show
Series libselinux: rework selabel_file(5) database | expand

Commit Message

Christian Göttsche Aug. 14, 2023, 1:20 p.m. UTC
selinux_check_access.c:43:10: warning: cast to union type is a GNU extension [-Wgnu-union-cast]
       43 |                                      (union selinux_callback)cb_auditinfo);
          |                                      ^                       ~~~~~~~~~~~~

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libselinux/utils/selinux_check_access.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Carter Oct. 5, 2023, 2:02 p.m. UTC | #1
On Mon, Aug 14, 2023 at 9:41 AM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
>     selinux_check_access.c:43:10: warning: cast to union type is a GNU extension [-Wgnu-union-cast]
>        43 |                                      (union selinux_callback)cb_auditinfo);
>           |                                      ^                       ~~~~~~~~~~~~
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  libselinux/utils/selinux_check_access.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libselinux/utils/selinux_check_access.c b/libselinux/utils/selinux_check_access.c
> index 6cea40e9..f7b27a85 100644
> --- a/libselinux/utils/selinux_check_access.c
> +++ b/libselinux/utils/selinux_check_access.c
> @@ -40,7 +40,7 @@ int main(int argc, char **argv)
>
>         if (audit_msg)
>                 selinux_set_callback(SELINUX_CB_AUDIT,
> -                                    (union selinux_callback)cb_auditinfo);
> +                                    (union selinux_callback) { .func_audit = cb_auditinfo });
>
>         rc = selinux_check_access(argv[optind], argv[optind + 1],
>                                   argv[optind + 2], argv[optind + 3],
> --
> 2.40.1
>
James Carter Oct. 12, 2023, 5:54 p.m. UTC | #2
On Thu, Oct 5, 2023 at 10:02 AM James Carter <jwcart2@gmail.com> wrote:
>
> On Mon, Aug 14, 2023 at 9:41 AM Christian Göttsche
> <cgzones@googlemail.com> wrote:
> >
> >     selinux_check_access.c:43:10: warning: cast to union type is a GNU extension [-Wgnu-union-cast]
> >        43 |                                      (union selinux_callback)cb_auditinfo);
> >           |                                      ^                       ~~~~~~~~~~~~
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
> Acked-by: James Carter <jwcart2@gmail.com>
>
Merged.
Thanks,
Jim

> > ---
> >  libselinux/utils/selinux_check_access.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libselinux/utils/selinux_check_access.c b/libselinux/utils/selinux_check_access.c
> > index 6cea40e9..f7b27a85 100644
> > --- a/libselinux/utils/selinux_check_access.c
> > +++ b/libselinux/utils/selinux_check_access.c
> > @@ -40,7 +40,7 @@ int main(int argc, char **argv)
> >
> >         if (audit_msg)
> >                 selinux_set_callback(SELINUX_CB_AUDIT,
> > -                                    (union selinux_callback)cb_auditinfo);
> > +                                    (union selinux_callback) { .func_audit = cb_auditinfo });
> >
> >         rc = selinux_check_access(argv[optind], argv[optind + 1],
> >                                   argv[optind + 2], argv[optind + 3],
> > --
> > 2.40.1
> >
diff mbox series

Patch

diff --git a/libselinux/utils/selinux_check_access.c b/libselinux/utils/selinux_check_access.c
index 6cea40e9..f7b27a85 100644
--- a/libselinux/utils/selinux_check_access.c
+++ b/libselinux/utils/selinux_check_access.c
@@ -40,7 +40,7 @@  int main(int argc, char **argv)
 
 	if (audit_msg)
 		selinux_set_callback(SELINUX_CB_AUDIT,
-				     (union selinux_callback)cb_auditinfo);
+				     (union selinux_callback) { .func_audit = cb_auditinfo });
 
 	rc = selinux_check_access(argv[optind], argv[optind + 1],
 				  argv[optind + 2], argv[optind + 3],