From mboxrd@z Thu Jan 1 00:00:00 1970 From: julia.lawall@lip6.fr (Julia Lawall) Date: Wed, 30 Aug 2017 15:05:04 +0200 (CEST) Subject: [Cocci] OpenLDAP debug statements In-Reply-To: <20170830125059.eqlq4w54oz57azum@eos.mistotebe.net> References: <20170829150811.xnttkxd47mknqzzn@eos.mistotebe.net> <20170829221532.ukkaxuvcgr7d25cn@eos.mistotebe.net> <20170830125059.eqlq4w54oz57azum@eos.mistotebe.net> Message-ID: To: cocci@systeme.lip6.fr List-Id: cocci@systeme.lip6.fr On Wed, 30 Aug 2017, Ond?ej Kuzn?k wrote: > On Wed, Aug 30, 2017 at 07:25:00AM +0200, Julia Lawall wrote: > > On Tue, 29 Aug 2017, Ond?ej Kuzn?k wrote: > >> On Tue, Aug 29, 2017 at 11:17:53PM +0200, Julia Lawall wrote: > >>> Allowing format list to match strings in multiple pieces seems like a > >>> somewhat complex undertaking. > >> > >> Again, I have little understanding of > >> how the parser works, but maybe it might be able to keep around a second > >> internal representation of the string as it is concatenated and extract > >> this information from that, even if it did not allow all manipulations > >> on it? > > > > This was my thought also, but looking at the code, it seems complex. > > OK, I understand. I any case, the suggestion below has very few false > negatives and no false positives that I could find, thanks a lot! > > The only false negatives are related to macro expansion, which probably > ties into the same limitation. It's strings like this: > > "string" BACKSQL_IDFMT "rest of string" > > Where BACKSQL_IDFMT is "%llu" or similar. Given how few of these there > are and that there have been no false positives from that that I could > see, I'm happy. Maybe if you put this macro in with the others, then it will find it. > > I will see how the sprintf merging will pan out shortly after I clean > out the false negatives and re-test the patch series up to this point. > > Again, many thanks! Without coccinelle, this project would not have been > possible at all. :) julia > >>> Perhaps the following could be acceptable? > >>> > >>> @initialize:ocaml@ > >>> @@ > >>> > >>> let fmtn(fmt,n) = > >>> List.length (Str.split_delim (Str.regexp_string "%") fmt) = 3 > >>> > >>> @@ > >>> char[] fmt : script:ocaml() { fmtn(fmt,2) }; > >>> expression list[2] args; > >>> expression E; > >>> @@ > >>> > >>> Debug( E, fmt, args > >>> -, 0 > >>> ); > >>> > >>> You would have to duplicate the latter rule for each possible number of > >>> arugments. > >> > >> I'll test it out, the potential problem I see is when I look into the > >> second step, merging the sprintf(buf, fmt,...);Debug(...,fmt2,...,buf,...) > >> calls into a single Debug call. I think I needed similar information > >> there but had no idea how complex the format string was, but will check > >> that patch again as well. > > -- > Ond?ej Kuzn?k > Senior Software Engineer > Symas Corporation http://www.symas.com > Packaged, certified, and supported LDAP solutions powered by OpenLDAP >