[ofa-general] Re: [PATCH] osm: source and destination strings overlap when using sprintf()

Hal Rosenstock halr at voltaire.com
Thu May 3 09:59:39 PDT 2007


On Tue, 2007-05-01 at 02:56, Yevgeny Kliteynik wrote:
> Sasha Khapyorsky wrote:
> > On 01:11 Wed 25 Apr     , Yevgeny Kliteynik wrote:
> >> Michael S. Tsirkin wrote:
> >>> Since you seem to do a strcat which does an anyway, how about, for example:
> >>>
> >>> -      sprintf( buf_line1,"%s 0x%01x |",
> >>> -               buf_line1, p_vla_tbl->vl_entry[i].vl);
> >>> +      sprintf( buf_line1 + strlen(buf_line1)," 0x%01x |",
> >>> +               p_vla_tbl->vl_entry[i].vl);
> >>>
> >>> and so on in all the other places?
> >> Agree.
> >> I'll send a new patch later.
> > 
> > Or like this:
> > 
> > +      int n = 0;
> > ...
> > -      sprintf( buf_line1,"%s 0x%01x |",
> > -               buf_line1, p_vla_tbl->vl_entry[i].vl);
> > +      n += sprintf( buf_line1 + n," 0x%01x |",
> > +                    p_vla_tbl->vl_entry[i].vl);
> > 
> > , so strlen() rerunning in loop is not needed anymore.
> 
> Right, it does look better.

So is someone going to submit this patch ? Thanks.

-- Hal

> -- Yevgeny
> 
> > Sasha
> > 
> 
> _______________________________________________
> general mailing list
> general at lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general
> 
> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general




More information about the general mailing list