[PATCH] ldb_debug: Fix for bug 13185
Andreas Schneider
asn at samba.org
Thu Feb 22 07:22:29 UTC 2018
On Thursday, 22 February 2018 05:16:25 CET Douglas Bagnall via samba-technical
wrote:
> On 22/02/18 16:53, Douglas Bagnall via samba-technical wrote:
> > On 22/02/18 16:06, Gary Lockyer via samba-technical wrote:
> >> + /*
> >> + * Check for duplicates in unique indexes
> >>
> >> */
> >>
> >> if (list->count > 0 &&
> >>
> >> ((a != NULL
> >>
> >> && (a->flags & LDB_ATTR_FLAG_UNIQUE_INDEX ||
> >>
> >> - (el->flags & LDB_FLAG_INTERNAL_FORCE_UNIQUE_INDEX))) ||
> >> - ldb_attr_cmp(el->name, LTDB_IDXDN) == 0)) {
> >> + (el->flags & LDB_FLAG_INTERNAL_FORCE_UNIQUE_INDEX))))) {
> >
> > This looks a bit wrong. I don't think it actually is wrong, but it
> > just looks scary having "&" mixing with other operators without tight
> > parentheses. I had to read random web pages to be sure the precedence
> > of (a & b || c) works as intended.
> >
> > I think something like this is logically the same but a bit clearer:
> > if (list->count > 0 &&
> >
> > a != NULL &&
> >
> > ((a->flags & LDB_ATTR_FLAG_UNIQUE_INDEX) ||
> >
> > (el->flags & LDB_FLAG_INTERNAL_FORCE_UNIQUE_INDEX))) {
>
> Well, I spoke with Andrew, and it turns out he meant this:
>
> if (list->count > 0 &&
> ((a != NULL && (a->flags & LDB_ATTR_FLAG_UNIQUE_INDEX)) ||
> (el->flags & LDB_FLAG_INTERNAL_FORCE_UNIQUE_INDEX))) {
Add a unit test for this patch?
--
Andreas Schneider GPG-ID: CC014E3D
Samba Team asn at samba.org
www.samba.org
More information about the samba-technical
mailing list