| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /// Use kstrdup rather than duplicating its implementation |
|---|
| 2 | 3 | /// |
|---|
| 3 | 4 | // Confidence: High |
|---|
| 4 | | -// Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. |
|---|
| 5 | | -// Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. |
|---|
| 6 | | -// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. |
|---|
| 5 | +// Copyright: (C) 2010-2012 Nicolas Palix. |
|---|
| 6 | +// Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. |
|---|
| 7 | +// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. |
|---|
| 7 | 8 | // URL: http://coccinelle.lip6.fr/ |
|---|
| 8 | 9 | // Comments: |
|---|
| 9 | 10 | // Options: --no-includes --include-headers |
|---|
| .. | .. |
|---|
| 65 | 66 | |
|---|
| 66 | 67 | * x = strlen(from) + 1; |
|---|
| 67 | 68 | ... when != \( x = E1 \| from = E1 \) |
|---|
| 68 | | -* to = \(kmalloc@p1\|kzalloc@p2\)(x,flag); |
|---|
| 69 | +* to = \(kmalloc@p1\|kzalloc@p1\)(x,flag); |
|---|
| 69 | 70 | ... when != \(x = E2 \| from = E2 \| to = E2 \) |
|---|
| 70 | 71 | if (to==NULL || ...) S |
|---|
| 71 | 72 | ... when != \(x = E3 \| from = E3 \| to = E3 \) |
|---|
| .. | .. |
|---|
| 76 | 77 | p2 << r1.p2; |
|---|
| 77 | 78 | @@ |
|---|
| 78 | 79 | |
|---|
| 79 | | -cocci.print_main("WARNING opportunity for kstrdep",p1) |
|---|
| 80 | +cocci.print_main("WARNING opportunity for kstrdup",p1) |
|---|
| 80 | 81 | cocci.print_secs("strcpy",p2) |
|---|
| 81 | 82 | |
|---|
| 82 | 83 | @script:python depends on org@ |
|---|
| .. | .. |
|---|
| 84 | 85 | p2 << r2.p2; |
|---|
| 85 | 86 | @@ |
|---|
| 86 | 87 | |
|---|
| 87 | | -cocci.print_main("WARNING opportunity for kstrdep",p1) |
|---|
| 88 | +cocci.print_main("WARNING opportunity for kstrdup",p1) |
|---|
| 88 | 89 | cocci.print_secs("memcpy",p2) |
|---|
| 89 | 90 | |
|---|
| 90 | 91 | @script:python depends on report@ |
|---|
| .. | .. |
|---|
| 92 | 93 | p2 << r1.p2; |
|---|
| 93 | 94 | @@ |
|---|
| 94 | 95 | |
|---|
| 95 | | -msg = "WARNING opportunity for kstrdep (strcpy on line %s)" % (p2[0].line) |
|---|
| 96 | +msg = "WARNING opportunity for kstrdup (strcpy on line %s)" % (p2[0].line) |
|---|
| 96 | 97 | coccilib.report.print_report(p1[0], msg) |
|---|
| 97 | 98 | |
|---|
| 98 | 99 | @script:python depends on report@ |
|---|
| .. | .. |
|---|
| 100 | 101 | p2 << r2.p2; |
|---|
| 101 | 102 | @@ |
|---|
| 102 | 103 | |
|---|
| 103 | | -msg = "WARNING opportunity for kstrdep (memcpy on line %s)" % (p2[0].line) |
|---|
| 104 | +msg = "WARNING opportunity for kstrdup (memcpy on line %s)" % (p2[0].line) |
|---|
| 104 | 105 | coccilib.report.print_report(p1[0], msg) |
|---|