> let snprintf_va = makeVarinfo true "snprintf" (TVoid [])> let snprintf =
Lval((Var snprintf_va),NoOffset)

> >
> > class snprintfV ?(tracelist=[]) file = object
> >   inherit nopCilVisitor
> >   method vstmt s = ChangeDoChildrenPost(
> >     s,
> >     fun s -> if L.mem (s.sid) tracelist then (
> >       match s.skind with
> >         |Instr il -> let new_il = L.map (
> >             fun ins -> match ins with
> >               |Call(None,Lval(Var {vname="sprintf"},_),expl,loc)->
> >                  let to_buf = L.hd expl in
> >                  Call(None,snprintf,to_buf::(SizeOfE(to_buf)::L.tl
> expl),loc)
>
> I'm not sure the SizeOfE will give a reliable result (imagine buf is a
> pointer on a malloc()ed area, rather than an static array - this is
> undecidable in the general case).  But if your tracelist contains only
> statements on which this transformation is sound, this should be good.
>
>
I don't know if using SizeOfE is right either  ---

if the program is

char dest [100] = "";
char *src = "hello world";
sprintf(dest,src);

so if I want to change it to

snprintf(dest,src,sizeof(dest));

then I am not sure which SizeOf to use ?  should I use AddressOf something
here?
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to