Skip to content
Snippets Groups Projects
Select Git revision
  • 5473201c73d51139281de4dd940edab4bc50b8b7
  • master default
  • enum_all_formats_v4
  • enum_all_formats_v3
  • enum_all_formats_v2
  • enum_all_formats
  • stable-1.26
  • stable-1.24
  • stable-1.22
  • stable-1.20
  • stable-1.18
  • stable-1.16
  • stable-1.14
  • stable-1.12
  • stable-1.8
  • stable-1.6
  • stable-1.4
  • stable-1.2
  • stable-0.8
  • stable-1.0
  • stable-1.10
  • v4l-utils-1.28.0
  • v4l-utils-1.26.1
  • v4l-utils-1.26.0
  • v4l-utils-1.24.1
  • v4l-utils-1.24.0
  • v4l-utils-1.22.1
  • v4l-utils-1.22.0
  • v4l-utils-1.20.0
  • v4l-utils-1.18.1
  • v4l-utils-1.16.8
  • v4l-utils-1.18.0
  • v4l-utils-1.16.7
  • v4l-utils-1.14.5
  • v4l-utils-1.12.8
  • v4l-utils-1.14.4
  • v4l-utils-1.16.6
  • v4l-utils-1.16.5
  • v4l-utils-1.12.7
  • v4l-utils-1.14.3
  • v4l-utils-1.16.4
41 results

configure.ac

Blame
  • memcpy-assign.cocci 1.88 KiB
    //
    // Replace memcpy with struct assignment.
    //
    // Confidence: High
    // Copyright: (C) 2012 Peter Senna Tschudin, INRIA/LIP6.  GPLv2.
    // URL: http://coccinelle.lip6.fr/
    // Comments:
    // Options: --no-includes --include-headers
    
    virtual patch
    virtual report
    virtual context
    virtual org
    
    @r1 depends on !patch@
    identifier struct_name;
    struct struct_name to;
    struct struct_name from;
    struct struct_name *top;
    struct struct_name *fromp;
    position p;
    @@
    memcpy@p(\(&(to)\|top\), \(&(from)\|fromp\), \(sizeof(to)\|sizeof(from)\|sizeof(struct struct_name)\|sizeof(*top)\|sizeof(*fromp)\))
    
    @script:python depends on report@
    p << r1.p;
    @@
    coccilib.report.print_report(p[0],"Replace memcpy with struct assignment")
    
    @depends on context@
    position r1.p;
    @@
    *memcpy@p(...);
    
    @script:python depends on org@
    p << r1.p;
    @@
    cocci.print_main("Replace memcpy with struct assignment",p)
    
    @depends on patch@
    identifier struct_name;
    struct struct_name to;
    struct struct_name from;
    @@
    (
    -memcpy(&(to), &(from), sizeof(to));
    +to = from;
    |
    -memcpy(&(to), &(from), sizeof(from));
    +to = from;
    |
    -memcpy(&(to), &(from), sizeof(struct struct_name));
    +to = from;
    )
    
    @depends on patch@
    identifier struct_name;
    struct struct_name to;
    struct struct_name *from;
    @@
    (
    -memcpy(&(to), from, sizeof(to));
    +to = *from;
    |
    -memcpy(&(to), from, sizeof(*from));
    +to = *from;
    |
    -memcpy(&(to), from, sizeof(struct struct_name));
    +to = *from;
    )
    
    @depends on patch@
    identifier struct_name;
    struct struct_name *to;
    struct struct_name from;
    @@
    (
    -memcpy(to, &(from), sizeof(*to));
    + *to = from;
    |
    -memcpy(to, &(from), sizeof(from));
    + *to = from;
    |
    -memcpy(to, &(from), sizeof(struct struct_name));
    + *to = from;
    )
    
    @depends on patch@
    identifier struct_name;
    struct struct_name *to;
    struct struct_name *from;
    @@
    (
    -memcpy(to, from, sizeof(*to));
    + *to = *from;
    |
    -memcpy(to, from, sizeof(*from));
    + *to = *from;
    |
    -memcpy(to, from, sizeof(struct struct_name));
    + *to = *from;
    )