[Patch] Fix the ";binary" suffix behavior

Jeremy Allison jra at samba.org
Tue Aug 9 15:43:26 UTC 2016


On Tue, Aug 09, 2016 at 08:20:14AM +0200, Andreas Schneider wrote:
> 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 ...

Fair enough. I got closer though.. :-).



More information about the samba-technical mailing list