kernel: remove no-macro-redefined

This commit is contained in:
weishu
2023-05-22 10:50:04 +08:00
parent 8f3e59803f
commit 8858cc899e
5 changed files with 21 additions and 21 deletions

View File

@@ -29,4 +29,4 @@ endif
ccflags-y += -DEXPECTED_SIZE=$(EXPECTED_SIZE) ccflags-y += -DEXPECTED_SIZE=$(EXPECTED_SIZE)
ccflags-y += -DEXPECTED_HASH=$(EXPECTED_HASH) ccflags-y += -DEXPECTED_HASH=$(EXPECTED_HASH)
ccflags-y += -Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-int-conversion -Wno-gcc-compat ccflags-y += -Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-int-conversion -Wno-gcc-compat
ccflags-y += -Wno-macro-redefined -Wno-declaration-after-statement ccflags-y += -Wno-declaration-after-statement

View File

@@ -13,7 +13,7 @@
#include "ksu.h" #include "ksu.h"
#include "manager.h" #include "manager.h"
uid_t ksu_manager_uid = INVALID_UID; uid_t ksu_manager_uid = KSU_INVALID_UID;
bool become_manager(char *pkg) bool become_manager(char *pkg)
{ {

View File

@@ -4,13 +4,13 @@
#include "linux/cred.h" #include "linux/cred.h"
#include "linux/types.h" #include "linux/types.h"
#define INVALID_UID -1 #define KSU_INVALID_UID -1
extern uid_t ksu_manager_uid; // DO NOT DIRECT USE extern uid_t ksu_manager_uid; // DO NOT DIRECT USE
static inline bool ksu_is_manager_uid_valid() static inline bool ksu_is_manager_uid_valid()
{ {
return ksu_manager_uid != INVALID_UID; return ksu_manager_uid != KSU_INVALID_UID;
} }
static inline bool is_manager() static inline bool is_manager()
@@ -30,7 +30,7 @@ static inline void ksu_set_manager_uid(uid_t uid)
static inline void ksu_invalidate_manager_uid() static inline void ksu_invalidate_manager_uid()
{ {
ksu_manager_uid = INVALID_UID; ksu_manager_uid = KSU_INVALID_UID;
} }
bool become_manager(char *pkg); bool become_manager(char *pkg);

View File

@@ -11,6 +11,6 @@ ccflags-y += -DKSU_COMPAT_HAS_SELINUX_STATE
endif endif
ccflags-y += -Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-int-conversion ccflags-y += -Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-int-conversion
ccflags-y += -Wno-macro-redefined -Wno-declaration-after-statement -Wno-unused-function ccflags-y += -Wno-declaration-after-statement -Wno-unused-function
ccflags-y += -I$(srctree)/security/selinux -I$(srctree)/security/selinux/include ccflags-y += -I$(srctree)/security/selinux -I$(srctree)/security/selinux/include
ccflags-y += -I$(objtree)/security/selinux ccflags-y += -I$(objtree)/security/selinux

View File

@@ -73,7 +73,7 @@ static bool add_typeattribute(struct policydb *db, const char *type,
// rules // rules
#define strip_av(effect, invert) ((effect == AVTAB_AUDITDENY) == !invert) #define strip_av(effect, invert) ((effect == AVTAB_AUDITDENY) == !invert)
#define hash_for_each(node_ptr, n_slot, cur) \ #define ksu_hash_for_each(node_ptr, n_slot, cur) \
int i; \ int i; \
for (i = 0; i < n_slot; ++i) \ for (i = 0; i < n_slot; ++i) \
for (cur = node_ptr[i]; cur; cur = cur->next) for (cur = node_ptr[i]; cur; cur = cur->next)
@@ -81,10 +81,10 @@ static bool add_typeattribute(struct policydb *db, const char *type,
// htable is a struct instead of pointer above 5.8.0: // htable is a struct instead of pointer above 5.8.0:
// https://elixir.bootlin.com/linux/v5.8-rc1/source/security/selinux/ss/symtab.h // https://elixir.bootlin.com/linux/v5.8-rc1/source/security/selinux/ss/symtab.h
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
#define hashtab_for_each(htab, cur) hash_for_each (htab.htable, htab.size, cur) #define ksu_hashtab_for_each(htab, cur) ksu_hash_for_each (htab.htable, htab.size, cur)
#else #else
#define hashtab_for_each(htab, cur) \ #define ksu_hashtab_for_each(htab, cur) \
hash_for_each (htab->htable, htab->size, cur) ksu_hash_for_each (htab->htable, htab->size, cur)
#endif #endif
// symtab_search is introduced on 5.9.0: // symtab_search is introduced on 5.9.0:
@@ -95,7 +95,7 @@ static bool add_typeattribute(struct policydb *db, const char *type,
#endif #endif
#define avtab_for_each(avtab, cur) \ #define avtab_for_each(avtab, cur) \
hash_for_each (avtab.htable, avtab.nslot, cur) \ ksu_hash_for_each (avtab.htable, avtab.nslot, cur) \
; ;
static struct avtab_node *get_avtab_node(struct policydb *db, static struct avtab_node *get_avtab_node(struct policydb *db,
@@ -210,14 +210,14 @@ static void add_rule_raw(struct policydb *db, struct type_datum *src,
if (src == NULL) { if (src == NULL) {
struct hashtab_node *node; struct hashtab_node *node;
if (strip_av(effect, invert)) { if (strip_av(effect, invert)) {
hashtab_for_each(db->p_types.table, node) ksu_hashtab_for_each(db->p_types.table, node)
{ {
add_rule_raw(db, add_rule_raw(db,
(struct type_datum *)node->datum, (struct type_datum *)node->datum,
tgt, cls, perm, effect, invert); tgt, cls, perm, effect, invert);
}; };
} else { } else {
hashtab_for_each(db->p_types.table, node) ksu_hashtab_for_each(db->p_types.table, node)
{ {
struct type_datum *type = struct type_datum *type =
(struct type_datum *)(node->datum); (struct type_datum *)(node->datum);
@@ -230,14 +230,14 @@ static void add_rule_raw(struct policydb *db, struct type_datum *src,
} else if (tgt == NULL) { } else if (tgt == NULL) {
struct hashtab_node *node; struct hashtab_node *node;
if (strip_av(effect, invert)) { if (strip_av(effect, invert)) {
hashtab_for_each(db->p_types.table, node) ksu_hashtab_for_each(db->p_types.table, node)
{ {
add_rule_raw(db, src, add_rule_raw(db, src,
(struct type_datum *)node->datum, (struct type_datum *)node->datum,
cls, perm, effect, invert); cls, perm, effect, invert);
}; };
} else { } else {
hashtab_for_each(db->p_types.table, node) ksu_hashtab_for_each(db->p_types.table, node)
{ {
struct type_datum *type = struct type_datum *type =
(struct type_datum *)(node->datum); (struct type_datum *)(node->datum);
@@ -249,7 +249,7 @@ static void add_rule_raw(struct policydb *db, struct type_datum *src,
} }
} else if (cls == NULL) { } else if (cls == NULL) {
struct hashtab_node *node; struct hashtab_node *node;
hashtab_for_each(db->p_classes.table, node) ksu_hashtab_for_each(db->p_classes.table, node)
{ {
add_rule_raw(db, src, tgt, add_rule_raw(db, src, tgt,
(struct class_datum *)node->datum, perm, (struct class_datum *)node->datum, perm,
@@ -292,7 +292,7 @@ static void add_xperm_rule_raw(struct policydb *db, struct type_datum *src,
{ {
if (src == NULL) { if (src == NULL) {
struct hashtab_node *node; struct hashtab_node *node;
hashtab_for_each(db->p_types.table, node) ksu_hashtab_for_each(db->p_types.table, node)
{ {
struct type_datum *type = struct type_datum *type =
(struct type_datum *)(node->datum); (struct type_datum *)(node->datum);
@@ -303,7 +303,7 @@ static void add_xperm_rule_raw(struct policydb *db, struct type_datum *src,
}; };
} else if (tgt == NULL) { } else if (tgt == NULL) {
struct hashtab_node *node; struct hashtab_node *node;
hashtab_for_each(db->p_types.table, node) ksu_hashtab_for_each(db->p_types.table, node)
{ {
struct type_datum *type = struct type_datum *type =
(struct type_datum *)(node->datum); (struct type_datum *)(node->datum);
@@ -314,7 +314,7 @@ static void add_xperm_rule_raw(struct policydb *db, struct type_datum *src,
}; };
} else if (cls == NULL) { } else if (cls == NULL) {
struct hashtab_node *node; struct hashtab_node *node;
hashtab_for_each(db->p_classes.table, node) ksu_hashtab_for_each(db->p_classes.table, node)
{ {
add_xperm_rule_raw(db, src, tgt, add_xperm_rule_raw(db, src, tgt,
(struct class_datum *)(node->datum), (struct class_datum *)(node->datum),
@@ -870,7 +870,7 @@ static bool set_type_state(struct policydb *db, const char *type_name,
struct type_datum *type; struct type_datum *type;
if (type_name == NULL) { if (type_name == NULL) {
struct hashtab_node *node; struct hashtab_node *node;
hashtab_for_each(db->p_types.table, node) ksu_hashtab_for_each(db->p_types.table, node)
{ {
type = (struct type_datum *)(node->datum); type = (struct type_datum *)(node->datum);
if (ebitmap_set_bit(&db->permissive_map, type->value, if (ebitmap_set_bit(&db->permissive_map, type->value,
@@ -913,7 +913,7 @@ static void add_typeattribute_raw(struct policydb *db, struct type_datum *type,
struct hashtab_node *node; struct hashtab_node *node;
struct constraint_node *n; struct constraint_node *n;
struct constraint_expr *e; struct constraint_expr *e;
hashtab_for_each(db->p_classes.table, node) ksu_hashtab_for_each(db->p_classes.table, node)
{ {
struct class_datum *cls = (struct class_datum *)(node->datum); struct class_datum *cls = (struct class_datum *)(node->datum);
for (n = cls->constraints; n; n = n->next) { for (n = cls->constraints; n; n = n->next) {