[Patch] Fix the ";binary" suffix behavior
Andreas Schneider
asn at samba.org
Tue Aug 9 06:20:14 UTC 2016
On Friday, 5 August 2016 12:57:01 CEST Jeremy Allison wrote:
> On Fri, Aug 05, 2016 at 12:56:35PM +0200, Niklas Abel wrote:
> > Hey Jeremy,
> >
> > here is the new patch version.
>
> Closer - comments below.
>
> > >> +const static char * strip_suffix (const void *mem_ctx, const char
> > >> *attr, const char *suffix) +{
> > >> + size_t attr_length = 0;
> > >> + size_t suffix_length = 0;
> > >> + size_t new_attr_size = 0;
> > >> + const char *tmp = NULL;
> > >> + const static char *result = NULL;
> > >> +
> > >> + if (!attr || !*attr || !suffix || !*suffix) {
> > >> + return attr;
> > >> + }
> > >> + attr_length = strlen(attr);
> > >> + suffix_length = strlen(suffix);
> > >> + if (attr_length < suffix_length) {
> > >> + return attr;
> > >> + }
> > >> + new_attr_size = (attr_length - suffix_length);
> > >> + tmp = attr + new_attr_size;
> > >> + if (0==strcasecmp(suffix, tmp)) {
>
> Convention in Samba is 'if (strcasecmp(suffix, tmp) == 0)'
> (yeah, picky I know :-).
Nope, the convention is:
int cmp;
cmp = strcasecmp(suffix, tmp);
if (cmp == 0)
This make it easier to debug ...
--
Andreas Schneider GPG-ID: CC014E3D
Samba Team asn at samba.org
www.samba.org
More information about the samba-technical
mailing list