@@ -64,11 +64,12 @@ int semanage_bool_compare2(const semanage_bool_t * boolean,
}
-static int semanage_bool_compare2_qsort(const semanage_bool_t ** boolean,
- const semanage_bool_t ** boolean2)
+static int semanage_bool_compare2_qsort(const void *p1, const void *p2)
{
+ const semanage_bool_t *const *boolean1 = p1;
+ const semanage_bool_t *const *boolean2 = p2;
- return sepol_bool_compare2(*boolean, *boolean2);
+ return sepol_bool_compare2(*boolean1, *boolean2);
}
/* Name */
@@ -43,7 +43,7 @@ typedef struct record_table {
/* Same as above, but dereferences the pointer first.
* This function is intenteded to be used as a qsort
* comparator. */
- int (*compare2_qsort) (const record_t ** rec, const record_t ** rec2);
+ int (*compare2_qsort) (const void * rec, const void * rec2);
/* Deep-copy clone of this record */
int (*clone) (struct semanage_handle * handle,
@@ -78,12 +78,10 @@ static int dbase_join_cache(semanage_handle_t * handle, dbase_join_t * dbase)
/* Sort for quicker merge later */
if (rcount1 > 0) {
- qsort(records1, rcount1, sizeof(record1_t *),
- (int (*)(const void *, const void *))rtable1->compare2_qsort);
+ qsort(records1, rcount1, sizeof(record1_t *), rtable1->compare2_qsort);
}
if (rcount2 > 0) {
- qsort(records2, rcount2, sizeof(record2_t *),
- (int (*)(const void *, const void *))rtable2->compare2_qsort);
+ qsort(records2, rcount2, sizeof(record2_t *), rtable2->compare2_qsort);
}
/* Now merge into this dbase */
@@ -121,13 +121,12 @@ int semanage_fcontext_compare2(const semanage_fcontext_t * fcontext,
}
-static int semanage_fcontext_compare2_qsort(const semanage_fcontext_t **
- fcontext,
- const semanage_fcontext_t **
- fcontext2)
+static int semanage_fcontext_compare2_qsort(const void *p1, const void *p2)
{
+ const semanage_fcontext_t *const *fcontext1 = p1;
+ const semanage_fcontext_t *const *fcontext2 = p2;
- return semanage_fcontext_compare2(*fcontext, *fcontext2);
+ return semanage_fcontext_compare2(*fcontext1, *fcontext2);
}
/* Create */
@@ -757,14 +757,20 @@ static int seuser_sort_func(const void *arg1, const void *arg2)
return strcmp(name1, name2);
}
-static int user_sort_func(semanage_user_t ** arg1, semanage_user_t ** arg2)
+static int user_sort_func(const void *arg1, const void *arg2)
{
- return strcmp(semanage_user_get_name(*arg1),
- semanage_user_get_name(*arg2));
+ const semanage_user_t *const *user1 = arg1;
+ const semanage_user_t *const *user2 = arg2;
+
+ return strcmp(semanage_user_get_name(*user1),
+ semanage_user_get_name(*user2));
}
-static int name_user_cmp(char *key, semanage_user_t ** val)
+static int name_user_cmp(const void *arg1, const void *arg2)
{
+ const char *key = arg1;
+ const semanage_user_t *const *val = arg2;
+
return strcmp(key, semanage_user_get_name(*val));
}
@@ -1184,8 +1190,7 @@ static genhomedircon_user_entry_t *get_users(genhomedircon_settings_t * s,
qsort(seuser_list, nseusers, sizeof(semanage_seuser_t *),
&seuser_sort_func);
- qsort(user_list, nusers, sizeof(semanage_user_t *),
- (int (*)(const void *, const void *))&user_sort_func);
+ qsort(user_list, nusers, sizeof(semanage_user_t *), user_sort_func);
for (i = 0; i < nseusers; i++) {
seuname = semanage_seuser_get_sename(seuser_list[i]);
@@ -1195,9 +1200,7 @@ static genhomedircon_user_entry_t *get_users(genhomedircon_settings_t * s,
continue;
/* find the user structure given the name */
- u = bsearch(seuname, user_list, nusers, sizeof(semanage_user_t *),
- (int (*)(const void *, const void *))
- &name_user_cmp);
+ u = bsearch(seuname, user_list, nusers, sizeof(semanage_user_t *), name_user_cmp);
/* %groupname syntax */
if (name[0] == '%') {
@@ -26,7 +26,6 @@ extern int semanage_ibendport_validate_local(semanage_handle_t *handle);
/* ==== Internal (to ibendports) API === */
- int semanage_ibendport_compare2_qsort(const semanage_ibendport_t **ibendport,
- const semanage_ibendport_t **ibendport2);
+ int semanage_ibendport_compare2_qsort(const void *p1, const void *p2);
#endif
@@ -37,10 +37,12 @@ int semanage_ibendport_compare2(const semanage_ibendport_t *ibendport,
}
- int semanage_ibendport_compare2_qsort(const semanage_ibendport_t **ibendport,
- const semanage_ibendport_t **ibendport2)
+ int semanage_ibendport_compare2_qsort(const void *p1, const void *p2)
{
- return sepol_ibendport_compare2(*ibendport, *ibendport2);
+ const semanage_ibendport_t *const *ibendport1 = p1;
+ const semanage_ibendport_t *const *ibendport2 = p2;
+
+ return sepol_ibendport_compare2(*ibendport1, *ibendport2);
}
int semanage_ibendport_key_create(semanage_handle_t *handle,
@@ -89,9 +89,7 @@ int semanage_ibendport_validate_local(semanage_handle_t *handle)
if (semanage_ibendport_list_local(handle, &ibendports, &nibendports) < 0)
goto err;
- qsort(ibendports, nibendports, sizeof(semanage_ibendport_t *),
- (int (*)(const void *, const void *))
- &semanage_ibendport_compare2_qsort);
+ qsort(ibendports, nibendports, sizeof(semanage_ibendport_t *), semanage_ibendport_compare2_qsort);
/* Test each ibendport */
while (i < nibendports) {
@@ -26,7 +26,6 @@ extern int semanage_ibpkey_validate_local(semanage_handle_t *handle);
/* ==== Internal (to ibpkeys) API === */
- int semanage_ibpkey_compare2_qsort(const semanage_ibpkey_t **ibpkey,
- const semanage_ibpkey_t **ibpkey2);
+ int semanage_ibpkey_compare2_qsort(const void *p1, const void *p2);
#endif
@@ -37,10 +37,12 @@ int semanage_ibpkey_compare2(const semanage_ibpkey_t *ibpkey,
}
- int semanage_ibpkey_compare2_qsort(const semanage_ibpkey_t **ibpkey,
- const semanage_ibpkey_t **ibpkey2)
+ int semanage_ibpkey_compare2_qsort(const void *p1, const void *p2)
{
- return sepol_ibpkey_compare2(*ibpkey, *ibpkey2);
+ const semanage_ibpkey_t *const *ibpkey1 = p1;
+ const semanage_ibpkey_t *const *ibpkey2 = p2;
+
+ return sepol_ibpkey_compare2(*ibpkey1, *ibpkey2);
}
int semanage_ibpkey_key_create(semanage_handle_t *handle,
@@ -91,9 +91,7 @@ int semanage_ibpkey_validate_local(semanage_handle_t *handle)
if (semanage_ibpkey_list_local(handle, &ibpkeys, &nibpkeys) < 0)
goto err;
- qsort(ibpkeys, nibpkeys, sizeof(semanage_ibpkey_t *),
- (int (*)(const void *, const void *))
- &semanage_ibpkey_compare2_qsort);
+ qsort(ibpkeys, nibpkeys, sizeof(semanage_ibpkey_t *), semanage_ibpkey_compare2_qsort);
/* Test each ibpkey for overlap */
while (i < nibpkeys) {
@@ -40,11 +40,13 @@ int semanage_iface_compare2(const semanage_iface_t * iface,
}
-static int semanage_iface_compare2_qsort(const semanage_iface_t ** iface,
- const semanage_iface_t ** iface2)
+static int semanage_iface_compare2_qsort(const void *p1,
+ const void *p2)
{
+ const semanage_iface_t *const *iface1 = p1;
+ const semanage_iface_t *const *iface2 = p2;
- return sepol_iface_compare2(*iface, *iface2);
+ return sepol_iface_compare2(*iface1, *iface2);
}
int semanage_iface_key_create(semanage_handle_t * handle,
@@ -26,7 +26,6 @@ extern int semanage_node_validate_local(semanage_handle_t * handle);
/* ==== Internal (to nodes) API === */
- int semanage_node_compare2_qsort(const semanage_node_t ** node,
- const semanage_node_t ** node2);
+ int semanage_node_compare2_qsort(const void *p1, const void *p2);
#endif
@@ -41,11 +41,12 @@ int semanage_node_compare2(const semanage_node_t * node,
}
- int semanage_node_compare2_qsort(const semanage_node_t ** node,
- const semanage_node_t ** node2)
+ int semanage_node_compare2_qsort(const void *p1, const void *p2)
{
+ const semanage_node_t *const *node1 = p1;
+ const semanage_node_t *const *node2 = p2;
- return sepol_node_compare2(*node, *node2);
+ return sepol_node_compare2(*node1, *node2);
}
int semanage_node_key_create(semanage_handle_t * handle,
@@ -169,9 +169,7 @@ int semanage_base_merge_components(semanage_handle_t * handle)
/* Sort records on MODE_SORT */
if (mode & MODE_SORT) {
- qsort(records, nrecords, sizeof(record_t *),
- (int (*)(const void *, const void *))rtable->
- compare2_qsort);
+ qsort(records, nrecords, sizeof(record_t *), rtable->compare2_qsort);
}
/* Clear obsolete ones for MODE_SET */
@@ -26,7 +26,6 @@ extern int semanage_port_validate_local(semanage_handle_t * handle);
/* ==== Internal (to ports) API === */
- int semanage_port_compare2_qsort(const semanage_port_t ** port,
- const semanage_port_t ** port2);
+ int semanage_port_compare2_qsort(const void* p1, const void *p2);
#endif
@@ -40,11 +40,12 @@ int semanage_port_compare2(const semanage_port_t * port,
}
- int semanage_port_compare2_qsort(const semanage_port_t ** port,
- const semanage_port_t ** port2)
+ int semanage_port_compare2_qsort(const void *p1, const void *p2)
{
+ const semanage_port_t *const * port1 = p1;
+ const semanage_port_t *const * port2 = p2;
- return sepol_port_compare2(*port, *port2);
+ return sepol_port_compare2(*port1, *port2);
}
int semanage_port_key_create(semanage_handle_t * handle,
@@ -82,9 +82,7 @@ int semanage_port_validate_local(semanage_handle_t * handle)
/* List and sort the ports */
if (semanage_port_list_local(handle, &ports, &nports) < 0)
goto err;
- qsort(ports, nports, sizeof(semanage_port_t *),
- (int (*)(const void *, const void *))
- &semanage_port_compare2_qsort);
+ qsort(ports, nports, sizeof(semanage_port_t *), semanage_port_compare2_qsort);
/* Test each port for overlap */
while (i < nports) {
@@ -99,11 +99,12 @@ int semanage_seuser_compare2(const semanage_seuser_t * seuser,
}
-static int semanage_seuser_compare2_qsort(const semanage_seuser_t ** seuser,
- const semanage_seuser_t ** seuser2)
+static int semanage_seuser_compare2_qsort(const void *p1, const void *p2)
{
+ const semanage_seuser_t *const *seuser1 = p1;
+ const semanage_seuser_t *const *seuser2 = p2;
- return strcmp((*seuser)->name, (*seuser2)->name);
+ return semanage_seuser_compare2(*seuser1, *seuser2);
}
/* Name */
@@ -126,7 +126,8 @@ int semanage_seuser_modify_local(semanage_handle_t * handle,
const semanage_seuser_t * data)
{
int rc;
- void *callback = (void *) handle->msg_callback;
+ __attribute__((format(printf, 3, 4)))
+ void (*callback) (void*, semanage_handle_t*, const char*, ...) = handle->msg_callback;
dbase_config_t *dconfig = semanage_seuser_dbase_local(handle);
const char *sename = semanage_seuser_get_sename(data);
const char *mls_range = semanage_seuser_get_mlsrange(data);
@@ -47,12 +47,12 @@ static int semanage_user_base_compare2(const semanage_user_base_t * user,
return sepol_user_compare2(user, user2);
}
-static int semanage_user_base_compare2_qsort(const semanage_user_base_t ** user,
- const semanage_user_base_t **
- user2)
+static int semanage_user_base_compare2_qsort(const void *p1, const void *p2)
{
+ const semanage_user_base_t *const *user1 = p1;
+ const semanage_user_base_t *const *user2 = p2;
- return sepol_user_compare2(*user, *user2);
+ return sepol_user_compare2(*user1, *user2);
}
/* Name */
@@ -66,13 +66,12 @@ static int semanage_user_extra_compare2(const semanage_user_extra_t *
return strcmp(user_extra->name, user_extra2->name);
}
-static int semanage_user_extra_compare2_qsort(const semanage_user_extra_t **
- user_extra,
- const semanage_user_extra_t **
- user_extra2)
+static int semanage_user_extra_compare2_qsort(const void *p1, const void *p2)
{
+ const semanage_user_extra_t *const *user_extra1 = p1;
+ const semanage_user_extra_t *const *user_extra2 = p2;
- return strcmp((*user_extra)->name, (*user_extra2)->name);
+ return semanage_user_extra_compare2(*user_extra1, *user_extra2);
}
/* Name */
@@ -79,11 +79,12 @@ int semanage_user_compare2(const semanage_user_t * user,
}
-static int semanage_user_compare2_qsort(const semanage_user_t ** user,
- const semanage_user_t ** user2)
+static int semanage_user_compare2_qsort(const void *p1, const void *p2)
{
+ const semanage_user_t *const *user1 = p1;
+ const semanage_user_t *const *user2 = p2;
- return strcmp((*user)->name, (*user2)->name);
+ return semanage_user_compare2(*user1, *user2);
}
/* Name */
@@ -183,8 +183,7 @@ int semanage_list_sort(semanage_list_t ** l)
array[i++] = temp;
}
- qsort(array, count, sizeof(semanage_list_t *),
- (int (*)(const void *, const void *))&semanage_cmp_plist_t);
+ qsort(array, count, sizeof(semanage_list_t *), semanage_cmp_plist_t);
for (i = 0; i < (count - 1); ++i) {
array[i]->next = array[i + 1];
}
@@ -195,9 +194,12 @@ int semanage_list_sort(semanage_list_t ** l)
return 0;
}
-int semanage_cmp_plist_t(const semanage_list_t ** x, const semanage_list_t ** y)
+int semanage_cmp_plist_t(const void *x, const void *y)
{
- return strcmp((*x)->data, (*y)->data);
+ const semanage_list_t *const *l1 = x;
+ const semanage_list_t *const *l2 = y;
+
+ return strcmp((*l1)->data, (*l2)->data);
}
int semanage_str_count(const char *data, char what)
@@ -98,8 +98,7 @@ int semanage_list_sort(semanage_list_t ** l) WARN_UNUSED;
* returns strcmp(x->data, y->data)
* used internally by semanage_list_sort()
*/
-int semanage_cmp_plist_t(const semanage_list_t ** x,
- const semanage_list_t ** y);
+int semanage_cmp_plist_t(const void *x, const void *y);
/**
* @param data a target string
* @param what a character