Re: [Cocci] [PATCH 01/18] coccinelle: change strncpy+truncation to strlcpy

From: Julia Lawall
Date: Fri Jul 13 2018 - 06:50:19 EST


For the file drivers/net/wireless/ti/wl1251/acx.c, the following keeps the
comment before the buf update and moves the strlcpy call below it. It
does however drop the comment just before the original call to strncpy.

julia


@r@
expression dest, src;
expression f;
@@

- strncpy(dest,src,f);
dest[f - 1] = '\0'
+ + strlcpy(dest,src,f)
;

@@
expression r.dest, r.src;
expression r.f;
@@

- dest[f - 1] = '\0' + strlcpy(dest,src,f);
+ strlcpy(dest,src,f);