aboutsummaryrefslogtreecommitdiff
path: root/scripts/objdiff
diff options
context:
space:
mode:
authorMárton Németh <[email protected]>2009-11-21 23:10:15 +0100
committerIngo Molnar <[email protected]>2009-11-22 09:49:26 +0100
commit96b02d78a7e47cd189f6b307c5513fec6b2155dc (patch)
tree0bdd5060e9a01366cc2fab1ae8359743ad15e77d /scripts/objdiff
parent5093ebad5f2348076fdc3dac7d2358b1ad7f85f7 (diff)
perf_event: Remove redundant zero fill
The buffer is first zeroed out by memset(). Then strncpy() is used to fill the content. The strncpy() function also pads the string till the end of the specified length, which is redundant. The strncpy() does not ensures that the string will be properly closed with 0. Use strlcpy() instead. The semantic match that finds this kind of pattern is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ expression buffer; expression size; expression str; @@ memset(buffer, 0, size); ... - strncpy( + strlcpy( buffer, str, sizeof(buffer) ); @@ expression buffer; expression size; expression str; @@ memset(&buffer, 0, size); ... - strncpy( + strlcpy( &buffer, str, sizeof(buffer)); @@ expression buffer; identifier field; expression size; expression str; @@ memset(buffer, 0, size); ... - strncpy( + strlcpy( buffer->field, str, sizeof(buffer->field) ); @@ expression buffer; identifier field; expression size; expression str; @@ memset(&buffer, 0, size); ... - strncpy( + strlcpy( buffer.field, str, sizeof(buffer.field)); // </smpl> On strncpy() vs strlcpy() see http://www.gratisoft.us/todd/papers/strlcpy.html . Signed-off-by: Márton Németh <[email protected]> Cc: Julia Lawall <[email protected]> Cc: [email protected] Cc: Peter Zijlstra <[email protected]> Cc: Paul Mackerras <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
Diffstat (limited to 'scripts/objdiff')
0 files changed, 0 insertions, 0 deletions