From: James Antill <jantill@redhat.com>
To: Karl MacMillan <kmacmillan@mentalrootkit.com>
Cc: selinux@tycho.nsa.gov
Subject: Re: [POLICYREP PATCH] Add objset to libsepol
Date: Thu, 26 Apr 2007 13:35:00 -0400 [thread overview]
Message-ID: <1177608900.3999.34.camel@code.and.org> (raw)
In-Reply-To: <20070426165756.7021.40274.stgit@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 1500 bytes --]
On Thu, 2007-04-26 at 12:57 -0400, Karl MacMillan wrote:
> Add the objset data structure to libsepol. Object sets behave similarly to
> Python sets.
[...]
> +struct sepol_objset
> +{
> + struct sepol_list *objs;
> + sepol_objset_cmp_t cmp;
> + unsigned int len;
> + char compliment;
> +};
>
What is len for?
>
> +int sepol_objset_contains(struct sepol_handle *h, struct sepol_objset *s, void *obj)
> +{
> + int ret;
> + struct sepol_iter *iter;
> +
> + ret = sepol_objset_seek(h, s, &iter, obj);
> + if (ret == SEPOL_EEXIST) {
> + sepol_iter_free(h, iter);
> + return 1;
> + } else if (ret == SEPOL_ENOENT) {
> + sepol_iter_free(h, iter);
> + return 0;
> + } else if (ret == SEPOL_ITERSTOP) {
> + return 0;
> + }
This should be:
int ret;
struct sepol_iter *iter;
int found = !s->compliment;
ret = sepol_objset_seek(h, s, &iter, obj);
if (ret == SEPOL_EEXIST) {
sepol_iter_free(h, iter);
return found;
} else if (ret == SEPOL_ENOENT) {
sepol_iter_free(h, iter);
return !found;
} else if (ret == SEPOL_ITERSTOP) {
return !found;
}
...or something similar, no? Also C has switch, unlike python ;).
> +
> + return ret;
> +}
Having the iter errors bubble up the API like this sucks and will make
eq/subset/etc. much more complicated :(.
--
James Antill <jantill@redhat.com>
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2007-04-26 17:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-26 16:57 [POLICYREP PATCH] Add objset to libsepol Karl MacMillan
2007-04-26 17:35 ` James Antill [this message]
2007-04-26 18:31 ` Karl MacMillan
-- strict thread matches above, loose matches on Subject: below --
2007-04-26 18:39 Karl MacMillan
2007-04-26 18:35 Karl MacMillan
2007-04-25 21:58 Karl MacMillan
2007-04-25 23:42 ` James Antill
2007-04-26 16:59 ` Karl MacMillan
2007-04-27 2:13 ` Karl MacMillan
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=1177608900.3999.34.camel@code.and.org \
--to=jantill@redhat.com \
--cc=kmacmillan@mentalrootkit.com \
--cc=selinux@tycho.nsa.gov \
/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.