All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian Göttsche" <cgzones@googlemail.com>
To: selinux@vger.kernel.org
Subject: [PATCH 03/25] libselinux: label_common(): do not discard const qualifier
Date: Mon,  3 May 2021 19:53:28 +0200	[thread overview]
Message-ID: <20210503175350.55954-4-cgzones@googlemail.com> (raw)
In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com>

As the const qualifier is discarded in label_common(), do not return a
const qualified pointer pointer from the local function `lookup_all()`.

label_file.c: In function ‘lookup_common’:
label_file.c:994:24: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
  994 |  struct spec *result = (struct spec*)matches[0];
      |                        ^

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libselinux/src/label_file.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c
index 726394ca..4d4e3a76 100644
--- a/libselinux/src/label_file.c
+++ b/libselinux/src/label_file.c
@@ -845,7 +845,7 @@ static void closef(struct selabel_handle *rec)
 // Finds all the matches of |key| in the given context. Returns the result in
 // the allocated array and updates the match count. If match_count is NULL,
 // stops early once the 1st match is found.
-static const struct spec **lookup_all(struct selabel_handle *rec,
+static struct spec **lookup_all(struct selabel_handle *rec,
                                       const char *key,
                                       int type,
                                       bool partial,
@@ -861,7 +861,7 @@ static const struct spec **lookup_all(struct selabel_handle *rec,
 	unsigned int sofar = 0;
 	char *sub = NULL;
 
-	const struct spec **result = NULL;
+	struct spec **result = NULL;
 	if (match_count) {
 		*match_count = 0;
 		result = calloc(data->nspec, sizeof(struct spec*));
@@ -987,11 +987,11 @@ static struct spec *lookup_common(struct selabel_handle *rec,
                                   const char *key,
                                   int type,
                                   bool partial) {
-	const struct spec **matches = lookup_all(rec, key, type, partial, NULL);
+	struct spec **matches = lookup_all(rec, key, type, partial, NULL);
 	if (!matches) {
 		return NULL;
 	}
-	struct spec *result = (struct spec*)matches[0];
+	struct spec *result = matches[0];
 	free(matches);
 	return result;
 }
@@ -1054,7 +1054,7 @@ static bool hash_all_partial_matches(struct selabel_handle *rec, const char *key
 	assert(digest);
 
 	size_t total_matches;
-	const struct spec **matches = lookup_all(rec, key, 0, true, &total_matches);
+	struct spec **matches = lookup_all(rec, key, 0, true, &total_matches);
 	if (!matches) {
 		return false;
 	}
-- 
2.31.1


  parent reply	other threads:[~2021-05-03 17:54 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-03 17:53 [PATCH 00/25] libselinux: misc compiler and static analyzer findings Christian Göttsche
2021-05-03 17:53 ` [PATCH 01/25] libselinux: sidtab_hash(): do not discard const qualifier Christian Göttsche
2021-05-03 17:53 ` [PATCH 02/25] libselinux: selinux_file_context_cmp(): " Christian Göttsche
2021-05-03 17:53 ` Christian Göttsche [this message]
2021-05-03 17:53 ` [PATCH 04/25] libselinux: Sha1Finalise(): " Christian Göttsche
2021-05-03 17:53 ` [PATCH 05/25] libselinux: sefcontext_compile: mark local variable static Christian Göttsche
2021-05-03 17:53 ` [PATCH 06/25] libselinux: avcstat: use standard length modifier for unsigned long long Christian Göttsche
2021-05-03 17:53 ` [PATCH 07/25] libselinux: selinux_restorecon: mark local variable static Christian Göttsche
2021-05-03 17:53 ` [PATCH 08/25] libselinux: selabel_get_digests_all_partial_matches: free memory after FTS_D block Christian Göttsche
2021-05-03 17:53 ` [PATCH 09/25] libselinux: getconlist: free memory on multiple level arguments Christian Göttsche
2021-05-03 17:53 ` [PATCH 10/25] libselinux: exclude_non_seclabel_mounts(): drop unused variable Christian Göttsche
2021-05-03 17:53 ` [PATCH 11/25] libselinux: context_new(): drop dead assignment Christian Göttsche
2021-05-03 17:53 ` [PATCH 12/25] libselinux: label_x::init(): " Christian Göttsche
2021-05-03 17:53 ` [PATCH 13/25] libselinux: label_media::init(): " Christian Göttsche
2021-05-03 17:53 ` [PATCH 14/25] libselinux: setexecfilecon(): " Christian Göttsche
2021-05-03 17:53 ` [PATCH 15/25] libselinux: getdefaultcon: free memory on multiple same arguments Christian Göttsche
2021-05-03 17:53 ` [PATCH 16/25] libselinux: store_stem(): do not free possible non-heap object Christian Göttsche
2021-05-03 17:53 ` [PATCH 17/25] libselinux: matchmediacon(): close file on error Christian Göttsche
2021-05-03 17:53 ` [PATCH 18/25] libselinux: init_selinux_config(): free resources " Christian Göttsche
2021-05-03 17:53 ` [PATCH 19/25] libselinux: label_file::init(): do not pass NULL to strdup Christian Göttsche
2021-05-03 17:53 ` [PATCH 20/25] libselinux: matchpathcon: free memory on realloc failure Christian Göttsche
2021-05-03 17:53 ` [PATCH 21/25] libselinux: label_db::db_init(): open file with CLOEXEC mode Christian Göttsche
2021-05-03 17:53 ` [PATCH 22/25] libselinux: drop redundant casts to the same type Christian Göttsche
2021-05-03 17:53 ` [PATCH 23/25] libselinux: sidtab_sid_stats(): unify parameter name Christian Göttsche
2021-05-03 17:53 ` [PATCH 24/25] libselinux: regex: unify parameter names Christian Göttsche
2021-05-03 17:53 ` [PATCH 25/25] libselinux: label_file.c: fix indent Christian Göttsche
2021-05-18 18:37 ` [PATCH 00/25] libselinux: misc compiler and static analyzer findings Petr Lautrbach

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=20210503175350.55954-4-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.