CVS update: samba/source/libads

Andrew Bartlett abartlet at samba.org
Thu Jun 27 07:26:13 EST 2002


Jim McDonough wrote:
> 
> >This is not the way to do it.
> >
> >If 'push_utf8_allocate()' fails, then we have bigger problems - so just
> >clean up and fail at that point.  Don't try to be smart and set the
> >value anyway.
> >
> >Also, C has a 'uncostifiy' function already:  strdup().  I am really not
> >convinced that casting to a void* makes the solution any more clear.
> >
> >Remember, C warnings are not 'a thing to be got rid of', but a tool to
> >help you find more fundemental flaws in your program.  Use them - they
> >really are there to help you.
> Be careful what you say.  The assignment was there to begin with...you just
> didn't notice it until this round.

Yes, I didn't look at your last patch carefully enough.

> As for what to do when it fails, I agree with you, but take it up with
> Tridge.   Perhaps I misunderstood what he was asking for, but from what I
> recall it was basically this: don't fail if the conversion doesn't work.

Well, on this point I shall have to disagree with tridge then - not that
its the first nor will it be the last time...  If that fails then I
really don't like the idea of continuing.

> As for the warnings, I'd rather leave them there than try to eliminate
> them.  Sometimes you know better than the compiler, and allocating more
> memory just to get rid of a warning isn't always going to help.  In this
> specific case, strdup is definitely not the answer...failing is.  In other
> parts, I'd rather just leave them in.  Thanks for the info compiler, I'll
> take it into consideration.

OK - I should have been clearer:  Yes, strdup() is not the answer for
the converted strings - but I would strdup() the attributes.  Hmm, being
an array of strings, thats more miserible - so I could live with your
solution for the attributes.

> The difficulty is when you rely on others' protoypes, if they're not strict
> about it, but you want to be...ldap does not modify the string, so why
> should I allocate yet more memory just to satisfy the compiler?

Personally, I think that if sombody has been so lax with their headers
that they can't get const right, then it might just be worthwhile not
trusting them to not modify the strings either.  (Now I would put an
exception for just plain broken headers - as found on some unix systems
- but where this is the norm, I feel a bit of paninoia might not go
astray).

Andrew Bartlett

-- 
Andrew Bartlett                                 abartlet at pcug.org.au
Manager, Authentication Subsystems, Samba Team  abartlet at samba.org
Student Network Administrator, Hawker College   abartlet at hawkerc.net
http://samba.org     http://build.samba.org     http://hawkerc.net




More information about the samba-cvs mailing list