diff --git a/lib/groupio.c b/lib/groupio.c index a2182ee7..abad2cbf 100644 --- a/lib/groupio.c +++ b/lib/groupio.c @@ -210,17 +210,25 @@ void __gr_del_entry (const struct commonio_entry *ent) static int gr_cmp (const void *p1, const void *p2) { + const struct commonio_entry *const *ce1; + const struct commonio_entry *const *ce2; + const struct group *g1, *g2; gid_t u1, u2; - if ((*(struct commonio_entry **) p1)->eptr == NULL) { + ce1 = p1; + g1 = (*ce1)->eptr; + if (g1 == NULL) { return 1; } - if ((*(struct commonio_entry **) p2)->eptr == NULL) { + + ce2 = p2; + g2 = (*ce2)->eptr; + if (g2 == NULL) { return -1; } - u1 = ((struct group *) (*(struct commonio_entry **) p1)->eptr)->gr_gid; - u2 = ((struct group *) (*(struct commonio_entry **) p2)->eptr)->gr_gid; + u1 = g1->gr_gid; + u2 = g2->gr_gid; if (u1 < u2) { return -1; diff --git a/lib/pwio.c b/lib/pwio.c index 0ef46069..95ed0abc 100644 --- a/lib/pwio.c +++ b/lib/pwio.c @@ -182,15 +182,23 @@ struct commonio_db *__pw_get_db (void) static int pw_cmp (const void *p1, const void *p2) { + const struct commonio_entry *const *ce1; + const struct commonio_entry *const *ce2; + const struct passwd *pw1, *pw2; uid_t u1, u2; - if ((*(struct commonio_entry **) p1)->eptr == NULL) + ce1 = p1; + pw1 = (*ce1)->eptr; + if (pw1 == NULL) return 1; - if ((*(struct commonio_entry **) p2)->eptr == NULL) + + ce2 = p2; + pw2 = (*ce2)->eptr; + if (pw2 == NULL) return -1; - u1 = ((struct passwd *) (*(struct commonio_entry **) p1)->eptr)->pw_uid; - u2 = ((struct passwd *) (*(struct commonio_entry **) p2)->eptr)->pw_uid; + u1 = pw1->pw_uid; + u2 = pw2->pw_uid; if (u1 < u2) return -1; diff --git a/lib/subordinateio.c b/lib/subordinateio.c index 4139674f..b5f5b91a 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -352,14 +352,17 @@ void free_subordinate_ranges(struct subordinate_range **ranges, int count) */ static int subordinate_range_cmp (const void *p1, const void *p2) { - struct subordinate_range *range1, *range2; + const struct commonio_entry *const *ce1; + const struct commonio_entry *const *ce2; + const struct subordinate_range *range1, *range2; - - range1 = (*(struct commonio_entry **) p1)->eptr; + ce1 = p1; + range1 = (*ce1)->eptr; if (range1 == NULL) return 1; - range2 = (*(struct commonio_entry **) p2)->eptr; + ce2 = p2; + range2 = (*ce2)->eptr; if (range2 == NULL) return -1;