This patch can be replicated with the following semantic patch:
$ cat fgets_cast.sp
@@
expression a, b, c;
@@
- fgets(a, (int) (b), c)
+ fgets(a, b, c)
@@
expression a, b, c;
@@
- fgets(a, (int) b, c)
+ fgets(a, b, c)
@@
expression a, b, c;
@@
- fgetsx(a, (int) (b), c)
+ fgetsx(a, b, c)
@@
expression a, b, c;
@@
- fgetsx(a, (int) b, c)
+ fgetsx(a, b, c)
@@
expression a, b, c, p;
@@
- p->cio_fgets(a, (int) (b), c)
+ p->cio_fgets(a, b, c)
@@
expression a, b, c, p;
@@
- p->cio_fgets(a, (int) b, c)
+ p->cio_fgets(a, b, c)
which is applied as:
$ find lib* src/ -type f \
| xargs spatch --sp-file ~/tmp/spatch/fgets_cast.sp --in-place;
Signed-off-by: Alejandro Colomar <alx@kernel.org>
if (NULL == fp) {
return;
}
- while (fgets(buf, (int) sizeof(buf), fp) == buf) {
+ while (fgets(buf, sizeof(buf), fp) == buf) {
if (stpsep(buf, "\n") == NULL)
break;
buflen *= 2;
len = strlen (buf);
- if (fgetsx (&buf[len],
- (int) (buflen - len),
- fp) != &buf[len]) {
+ if (fgetsx(&buf[len], buflen - len, fp) != &buf[len]) {
return NULL;
}
}
* group entry for each group will be looked up in the appropriate
* file (gshadow or group) and the password changed.
*/
- while (fgets(buf, (int) sizeof(buf), stdin) != NULL) {
+ while (fgets(buf, sizeof(buf), stdin) != NULL) {
line++;
if (stpsep(buf, "\n") == NULL) {
fprintf (stderr, _("%s: line %jd: line too long\n"),