[Nut-upsdev] Re: [Nut-upsuser] Ablerex 625L USB version

Peter Selinger selinger at mathstat.dal.ca
Sat Feb 3 05:45:12 CET 2007


Alexander I. Gordeev wrote:
> 
> > Near line 198:
> 
> >          if ( (c==endchar) || (c==0) ) {
> >              break;
> >          }
> 
> > +        if (ignset == NULL) break;
> >          if (NULL!=strchr(ignset,c)) continue;
> 
> > I wasn't sure if this makes sense. Can ignset ever be NULL? And if
> > yes, why should there be a "break", rather than just skipping the
> > following test?
> 
> I guess, it should be something like this:
> 
>     if ((ignset == NULL) || (NULL!=strchr(ignset,c))) continue;
>
> because it is safer. If ignset is NULL, strchr causes segmentation
> fault. However, if we deal only with megatec.c ignset cannot be NULL.

No, I think the correct expression would be:

if ((ignset != NULL) && (NULL!=strchr(ignset,c))) continue;

In cases where ignset==NULL, you don't want to call strchr, but in
this case you should assume that c is *not* an ignored character,
i.e., don't "continue".

-- Peter



More information about the Nut-upsdev mailing list