From: Alejandro Colomar Date: Sun, 21 Jul 2024 16:40:25 +0000 (+0200) Subject: lib/, src/: Remove useless casts in fgets(3) X-Git-Tag: 4.19.0-rc1~56 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c85a4d3ba27e9296531a418a09b9effe13225109;p=thirdparty%2Fshadow.git lib/, src/: Remove useless casts in fgets(3) 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 --- diff --git a/lib/setupenv.c b/lib/setupenv.c index 1485f69e2..1bf8b3a35 100644 --- a/lib/setupenv.c +++ b/lib/setupenv.c @@ -55,7 +55,7 @@ static void read_env_file (const char *filename) 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; diff --git a/lib/shadow/gshadow/fgetsgent.c b/lib/shadow/gshadow/fgetsgent.c index 57e45fb5e..29ef11b72 100644 --- a/lib/shadow/gshadow/fgetsgent.c +++ b/lib/shadow/gshadow/fgetsgent.c @@ -66,9 +66,7 @@ fgetsgent(FILE *fp) 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; } } diff --git a/src/chgpasswd.c b/src/chgpasswd.c index 256172f49..97ad30029 100644 --- a/src/chgpasswd.c +++ b/src/chgpasswd.c @@ -476,7 +476,7 @@ int main (int argc, char **argv) * 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"),