All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian Göttsche" <cgzones@googlemail.com>
To: selinux@vger.kernel.org
Subject: [RFC PATCH 5/9] libselinux: explicitly ignore return values
Date: Fri, 12 May 2023 12:23:18 +0200	[thread overview]
Message-ID: <20230512102322.72235-5-cgzones@googlemail.com> (raw)
In-Reply-To: <20230512102322.72235-1-cgzones@googlemail.com>

Tell GCC, see [1], to actually no issue warnings about explicitly
ignored return values.

Also explicitly ignored return values in cleanup handlers.

    togglesebool.c: In function ‘rollback’:
    togglesebool.c:18:17: error: ignoring return value of ‘security_set_boolean’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
       18 |                 security_set_boolean(argv[i],
          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       19 |                                      security_get_boolean_active(argv[i]));
          |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    load_policy.c: In function ‘selinux_init_load_policy’:
    load_policy.c:329:17: error: ‘security_disable’ is deprecated: SELinux runtime disable is deprecated [-Werror=deprecated-declarations]
      329 |                 rc = security_disable();
          |                 ^~

    booleans.c: In function ‘rollback’:
    booleans.c:332:17: error: ignoring return value of ‘security_set_boolean’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
      332 |                 security_set_boolean(boollist[i].name,
          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      333 |                                      security_get_boolean_active(boollist[i].
          |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      334 |                                                                  name));
          |                                                                  ~~~~~~

    checkAccess.c: In function ‘selinux_check_access’:
    checkAccess.c:42:16: error: ignoring return value of ‘selinux_status_updated’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
       42 |         (void) selinux_status_updated();
          |                ^~~~~~~~~~~~~~~~~~~~~~~~

    avc.c: In function ‘avc_has_perm_noaudit’:
    avc.c:761:24: error: ignoring return value of ‘selinux_status_updated’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
      761 |                 (void) selinux_status_updated();
          |                        ^~~~~~~~~~~~~~~~~~~~~~~~

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libselinux/src/avc.c            | 2 +-
 libselinux/src/booleans.c       | 2 +-
 libselinux/src/checkAccess.c    | 2 +-
 libselinux/src/load_policy.c    | 2 +-
 libselinux/utils/togglesebool.c | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libselinux/src/avc.c b/libselinux/src/avc.c
index 634badf9..2cb6366f 100644
--- a/libselinux/src/avc.c
+++ b/libselinux/src/avc.c
@@ -757,7 +757,7 @@ int avc_has_perm_noaudit(security_id_t ssid,
 		avd_init(avd);
 
 	if (!avc_using_threads && !avc_app_main_loop) {
-		(void) selinux_status_updated();
+		(void)! selinux_status_updated();
 	}
 
 	if (!aeref) {
diff --git a/libselinux/src/booleans.c b/libselinux/src/booleans.c
index e34b39ff..30733564 100644
--- a/libselinux/src/booleans.c
+++ b/libselinux/src/booleans.c
@@ -327,7 +327,7 @@ static void rollback(SELboolean * boollist, int end)
 	int i;
 
 	for (i = 0; i < end; i++)
-		security_set_boolean(boollist[i].name,
+		(void)! security_set_boolean(boollist[i].name,
 				     security_get_boolean_active(boollist[i].
 								 name));
 }
diff --git a/libselinux/src/checkAccess.c b/libselinux/src/checkAccess.c
index 022cd6b5..1df0c8ad 100644
--- a/libselinux/src/checkAccess.c
+++ b/libselinux/src/checkAccess.c
@@ -39,7 +39,7 @@ int selinux_check_access(const char *scon, const char *tcon, const char *class,
 	if (rc < 0)
 		return rc;
 
-	(void) selinux_status_updated();
+	(void)! selinux_status_updated();
 
        sclass = string_to_security_class(class);
        if (sclass == 0) {
diff --git a/libselinux/src/load_policy.c b/libselinux/src/load_policy.c
index 17918e8b..c3ac18e2 100644
--- a/libselinux/src/load_policy.c
+++ b/libselinux/src/load_policy.c
@@ -238,7 +238,7 @@ int selinux_init_load_policy(int *enforce)
 	 * Get desired mode (disabled, permissive, enforcing) from 
 	 * /etc/selinux/config. 
 	 */
-	selinux_getenforcemode(&seconfig);
+	(void)! selinux_getenforcemode(&seconfig);
 
 	/* Check for an override of the mode via the kernel command line. */
 	rc = mount("proc", "/proc", "proc", 0, 0);
diff --git a/libselinux/utils/togglesebool.c b/libselinux/utils/togglesebool.c
index 4a7c830e..d8cee287 100644
--- a/libselinux/utils/togglesebool.c
+++ b/libselinux/utils/togglesebool.c
@@ -15,7 +15,7 @@ static __attribute__ ((__noreturn__)) void rollback(int argc, char **argv)
 	int i;
 
 	for (i = 1; i < argc; i++)
-		security_set_boolean(argv[i],
+		(void)! security_set_boolean(argv[i],
 				     security_get_boolean_active(argv[i]));
 	exit(1);
 }
-- 
2.40.1


  parent reply	other threads:[~2023-05-12 10:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-12 10:23 [RFC PATCH 1/9] libselinux: annotate interfaces with compiler attributes Christian Göttsche
2023-05-12 10:23 ` [RFC PATCH 2/9] libselinux: deprecate matchpathcon and compute_user interfaces Christian Göttsche
2023-06-15 20:31   ` James Carter
2023-05-12 10:23 ` [RFC PATCH 3/9] libselinux: declare avc_open(3) options parameter const Christian Göttsche
2023-05-12 10:23 ` [RFC PATCH 4/9] mcstrans: check getcon(3) and context_range_set(3) for failure Christian Göttsche
2023-05-12 10:23 ` Christian Göttsche [this message]
2023-05-12 10:23 ` [RFC PATCH 6/9] libselinux: ignore internal use of deprecated interfaces Christian Göttsche
2023-05-12 10:23 ` [RFC PATCH 7/9] secon: check selinux_raw_to_trans_context(3) for failure Christian Göttsche
2023-05-12 10:23 ` [RFC PATCH 8/9] restorecond: check selinux_restorecon(3) " Christian Göttsche
2023-05-12 10:23 ` [RFC PATCH 9/9] restorecond: drop last matchpathcon call Christian Göttsche
2023-06-15 20:22 ` [RFC PATCH 1/9] libselinux: annotate interfaces with compiler attributes James Carter

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=20230512102322.72235-5-cgzones@googlemail.com \
    --to=cgzones@googlemail.com \
    --cc=selinux@vger.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 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.