xref: /freebsd/tools/coccinelle/copystr9.cocci (revision 5f4c09dd85bff675e0ca63c55ea3c517e0fddfcc)
1@ nostorederror_nostoredlen @
2 expression __src, __dst, __len;
3 statement S1;
4@@
5
6 S1
7-copystr(__src, __dst, __len, NULL);
8+strlcpy(__dst, __src, __len);
9
10@ ifcondition_nostoredlen @
11 expression __src, __dst, __len;
12 statement S1;
13@@
14 if (
15(
16-copystr(__src, __dst, __len, NULL) == ENAMETOOLONG
17|
18-copystr(__src, __dst, __len, NULL) != 0
19|
20-copystr(__src, __dst, __len, NULL)
21)
22+strlcpy(__dst, __src, __len) >= __len
23 ) S1
24
25@ nostorederror_storedlen1 @
26 expression __src, __dst, __len;
27 identifier __done;
28 statement S1;
29@@
30 S1
31(
32-copystr(__src, __dst, __len, &__done);
33+__done = strlcpy(__dst, __src, __len);
34+__done = MIN(__done, __len);
35|
36-copystr(__src, __dst, __len, __done);
37+ *__done = strlcpy(__dst, __src, __len);
38+ *__done = MIN(*__done, __len);
39)
40