|
|
ffbc92 |
From 3950b1afedd1a5247dcb0eb4acffc3fe045a9fb3 Mon Sep 17 00:00:00 2001
|
|
|
ffbc92 |
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
|
|
|
ffbc92 |
Date: Mon, 3 May 2021 17:10:42 +0200
|
|
|
ffbc92 |
Subject: [PATCH] libselinux: label_common(): do not discard const qualifier
|
|
|
ffbc92 |
MIME-Version: 1.0
|
|
|
ffbc92 |
Content-Type: text/plain; charset=UTF-8
|
|
|
ffbc92 |
Content-Transfer-Encoding: 8bit
|
|
|
ffbc92 |
|
|
|
ffbc92 |
As the const qualifier is discarded in label_common(), do not return a
|
|
|
ffbc92 |
const qualified pointer pointer from the local function `lookup_all()`.
|
|
|
ffbc92 |
|
|
|
ffbc92 |
label_file.c: In function ‘lookup_common’:
|
|
|
ffbc92 |
label_file.c:994:24: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
|
|
|
ffbc92 |
994 | struct spec *result = (struct spec*)matches[0];
|
|
|
ffbc92 |
| ^
|
|
|
ffbc92 |
|
|
|
ffbc92 |
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
|
|
|
ffbc92 |
---
|
|
|
ffbc92 |
libselinux/src/label_file.c | 10 +++++-----
|
|
|
ffbc92 |
1 file changed, 5 insertions(+), 5 deletions(-)
|
|
|
ffbc92 |
|
|
|
ffbc92 |
diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c
|
|
|
ffbc92 |
index cfce23e0119e..b080fcf1305b 100644
|
|
|
ffbc92 |
--- a/libselinux/src/label_file.c
|
|
|
ffbc92 |
+++ b/libselinux/src/label_file.c
|
|
|
ffbc92 |
@@ -845,7 +845,7 @@ static void closef(struct selabel_handle *rec)
|
|
|
ffbc92 |
// Finds all the matches of |key| in the given context. Returns the result in
|
|
|
ffbc92 |
// the allocated array and updates the match count. If match_count is NULL,
|
|
|
ffbc92 |
// stops early once the 1st match is found.
|
|
|
ffbc92 |
-static const struct spec **lookup_all(struct selabel_handle *rec,
|
|
|
ffbc92 |
+static struct spec **lookup_all(struct selabel_handle *rec,
|
|
|
ffbc92 |
const char *key,
|
|
|
ffbc92 |
int type,
|
|
|
ffbc92 |
bool partial,
|
|
|
ffbc92 |
@@ -861,7 +861,7 @@ static const struct spec **lookup_all(struct selabel_handle *rec,
|
|
|
ffbc92 |
unsigned int sofar = 0;
|
|
|
ffbc92 |
char *sub = NULL;
|
|
|
ffbc92 |
|
|
|
ffbc92 |
- const struct spec **result = NULL;
|
|
|
ffbc92 |
+ struct spec **result = NULL;
|
|
|
ffbc92 |
if (match_count) {
|
|
|
ffbc92 |
*match_count = 0;
|
|
|
ffbc92 |
result = calloc(data->nspec, sizeof(struct spec*));
|
|
|
ffbc92 |
@@ -987,11 +987,11 @@ static struct spec *lookup_common(struct selabel_handle *rec,
|
|
|
ffbc92 |
const char *key,
|
|
|
ffbc92 |
int type,
|
|
|
ffbc92 |
bool partial) {
|
|
|
ffbc92 |
- const struct spec **matches = lookup_all(rec, key, type, partial, NULL);
|
|
|
ffbc92 |
+ struct spec **matches = lookup_all(rec, key, type, partial, NULL);
|
|
|
ffbc92 |
if (!matches) {
|
|
|
ffbc92 |
return NULL;
|
|
|
ffbc92 |
}
|
|
|
ffbc92 |
- struct spec *result = (struct spec*)matches[0];
|
|
|
ffbc92 |
+ struct spec *result = matches[0];
|
|
|
ffbc92 |
free(matches);
|
|
|
ffbc92 |
return result;
|
|
|
ffbc92 |
}
|
|
|
ffbc92 |
@@ -1054,7 +1054,7 @@ static bool hash_all_partial_matches(struct selabel_handle *rec, const char *key
|
|
|
ffbc92 |
assert(digest);
|
|
|
ffbc92 |
|
|
|
ffbc92 |
size_t total_matches;
|
|
|
ffbc92 |
- const struct spec **matches = lookup_all(rec, key, 0, true, &total_matches);
|
|
|
ffbc92 |
+ struct spec **matches = lookup_all(rec, key, 0, true, &total_matches);
|
|
|
ffbc92 |
if (!matches) {
|
|
|
ffbc92 |
return false;
|
|
|
ffbc92 |
}
|
|
|
ffbc92 |
--
|
|
|
ffbc92 |
2.32.0
|
|
|
ffbc92 |
|