[ofa-general] Re: [PATCH] osm: source and destination strings overlap when using sprintf()
Sasha Khapyorsky
sashak at voltaire.com
Sun May 6 05:43:33 PDT 2007
On 12:59 Thu 03 May , Hal Rosenstock wrote:
> 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.
Will do.
Sasha
More information about the general
mailing list