SELinux Security Module development
 help / color / mirror / Atom feed
From: James Carter <jwcart2@gmail.com>
To: selinux@vger.kernel.org
Cc: dburgener@linux.microsoft.com, cgzones@googlemail.com,
	James Carter <jwcart2@gmail.com>
Subject: [PATCH 1/7 v2] libsepol: Changes to ebitmap.h to fix compiler warnings
Date: Wed,  9 Aug 2023 16:40:40 -0400	[thread overview]
Message-ID: <20230809204046.110783-2-jwcart2@gmail.com> (raw)
In-Reply-To: <20230809204046.110783-1-jwcart2@gmail.com>

When compiling with the "-Wnull-dereference" flag, the compiler is
not smart enough to realize that anytime the ebitmap_t node field is
NULL, the highbit field will equal 0. This causes false positive
warnings to be generated.

Change the ebitmap_is_empty() and ebitmap_length() macros to check
for the node being NULL instead of just relying on the value of
highbit to eliminate these false warnings.

Signed-off-by: James Carter <jwcart2@gmail.com>
---
 libsepol/include/sepol/policydb/ebitmap.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libsepol/include/sepol/policydb/ebitmap.h b/libsepol/include/sepol/policydb/ebitmap.h
index c434c4ba..7e19c301 100644
--- a/libsepol/include/sepol/policydb/ebitmap.h
+++ b/libsepol/include/sepol/policydb/ebitmap.h
@@ -39,8 +39,8 @@ typedef struct ebitmap {
 	uint32_t highbit;	/* highest position in the total bitmap */
 } ebitmap_t;
 
-#define ebitmap_is_empty(e) (((e)->highbit) == 0)
-#define ebitmap_length(e) ((e)->highbit)
+#define ebitmap_is_empty(e) (((e)->node) == NULL)
+#define ebitmap_length(e) ((e)->node ? (e)->highbit : 0)
 #define ebitmap_startbit(e) ((e)->node ? (e)->node->startbit : 0)
 #define ebitmap_startnode(e) ((e)->node)
 
-- 
2.41.0


  reply	other threads:[~2023-08-09 20:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09 20:40 [PATCH 0/7 v2] Add support for notself and other to CIL James Carter
2023-08-09 20:40 ` James Carter [this message]
2023-08-09 20:40 ` [PATCH 2/7 v2] libsepol/cil: Do not call ebitmap_init twice for an ebitmap James Carter
2023-08-09 20:40 ` [PATCH 3/7 v2] libsepol/cil: Add notself and other support to CIL James Carter
2023-08-09 20:40 ` [PATCH 4/7 v2] libsepol: update CIL generation for trivial not-self rules James Carter
2023-08-09 20:40 ` [PATCH 5/7 v2] libsepol: Use ERR() instead of log_err() James Carter
2023-08-09 20:40 ` [PATCH 6/7 v2] secilc/docs: Add notself and other keywords to CIL documentation James Carter
2023-08-09 20:40 ` [PATCH 7/7 v2] secilc/test: Add notself and other tests 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=20230809204046.110783-2-jwcart2@gmail.com \
    --to=jwcart2@gmail.com \
    --cc=cgzones@googlemail.com \
    --cc=dburgener@linux.microsoft.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox