-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace fgetsx() by fgets(3) and fputsx() by fputs(3) #1056
base: master
Are you sure you want to change the base?
Commits on Oct 15, 2024
-
lib/, src/: Use strsep(3) instead of strtok(3)
Signed-off-by: Alejandro Colomar <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for b87f79c - Browse repository at this point
Copy the full SHA b87f79cView commit details -
lib/, src/: Use str[n]cmp(3) instead of explicit byte comparisons
This is simpler to read, IMO. Signed-off-by: Alejandro Colomar <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ee5bceb - Browse repository at this point
Copy the full SHA ee5bcebView commit details -
contrib/, lib/, src/: Use consistent style using strchr(3) in conditi…
…onals For negative matches, use if (strchr(...) == NULL) For positive matches, use the cast-to-bool operator: if (!!strchr(...)) For positive matches, when a variable is also set, use while (NULL != (p = strchr(...))) Signed-off-by: Alejandro Colomar <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 2f753cf - Browse repository at this point
Copy the full SHA 2f753cfView commit details -
lib/fields.c: Remove dead code
A few lines above, we've removed the '\n' already. Signed-off-by: Alejandro Colomar <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for aa3f0f9 - Browse repository at this point
Copy the full SHA aa3f0f9View commit details -
lib/gshadow.c: endsgent(): Invert logic to reduce indentation
Signed-off-by: Alejandro Colomar <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 2b6a141 - Browse repository at this point
Copy the full SHA 2b6a141View commit details -
contrib/, lib/, src/: Consistently use sizeof() as if it were a function
sizeof(foo) - No spaces. Not: sizeof (foo) - Parentheses. Not: sizeof foo - No parentheses wrapping sizeof itself Not: (sizeof foo) This patch can be approximated with the following semantic patch: $ cat ~/tmp/spatch/sizeof.sp @@ identifier a, b; @@ - sizeof a->b + sizeof(a->b) @@ identifier a, b; @@ - sizeof a.b + sizeof(a.b) @@ identifier x; @@ - sizeof x + sizeof(x) @@ identifier x; @@ - sizeof *x + sizeof(*x) @@ identifier x; @@ - (sizeof(x)) + sizeof(x) @@ identifier x; @@ - (sizeof(*x)) + sizeof(*x) Applied as $ find contrib/ lib* src/ -type f \ | xargs spatch --sp-file ~/tmp/spatch/sizeof.sp --in-place; The differences between the actual patch and the approximation via the semantic patch from above are whitespace only. When reviewing, it'll be useful to diff with '-w'. Link: <https://lkml.org/lkml/2012/7/11/103> Signed-off-by: Alejandro Colomar <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 61bc9a0 - Browse repository at this point
Copy the full SHA 61bc9a0View commit details -
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->fgets(a, (int) (b), c) + p->fgets(a, b, c) @@ expression a, b, c, p; @@ - p->fgets(a, (int) b, c) + p->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 <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ca165cc - Browse repository at this point
Copy the full SHA ca165ccView commit details -
lib/, src/: Consistently use NULL with fgets(3)
fgets(3) returns either NULL or the input pointer. Checking for NULL is more explicit, and simpler. <stddef.h> is the header that provides NULL; add it where appropriate. The meat of this patch can be approximated with the following semantic patch: $ cat ~/tmp/spatch/fgets_null.sp @@ expression a, b, c; @@ - fgets(a, b, c) == a + fgets(a, b, c) != NULL @@ expression a, b, c; @@ - fgetsx(a, b, c) == a + fgetsx(a, b, c) != NULL @@ expression a, b, c, p; @@ - p->fgets(a, b, c) == a + p->fgets(a, b, c) != NULL @@ expression a, b, c; @@ - fgets(a, b, c) != a + fgets(a, b, c) == NULL @@ expression a, b, c; @@ - fgetsx(a, b, c) != a + fgetsx(a, b, c) == NULL @@ expression a, b, c, p; @@ - p->fgets(a, b, c) != a + p->fgets(a, b, c) == NUL Applied as $ find contrib/ lib* src/ -type f \ | xargs spatch --sp-file ~/tmp/spatch/fgets_null.sp --in-place; The differences between the actual patch and the approximation via the semantic patch from above are includes, whitespace, braces, and a case where there was an implicit pointer-to-bool comparison which I made explicit. When reviewing, it'll be useful to use git-diff(1) with '-w' and '--color-words=.'. Signed-off-by: Alejandro Colomar <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 8929e11 - Browse repository at this point
Copy the full SHA 8929e11View commit details -
lib/, po/: Remove fgetsx() and fputsx()
It seems they never worked correctly. Let's keep it simple and remove support for escaped newlines. Closes: <shadow-maint#1055> Reported-by: Chris Hofstaedtler <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for fee111c - Browse repository at this point
Copy the full SHA fee111cView commit details -
lib/: Use getline(3) instead of its pattern
Signed-off-by: Alejandro Colomar <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 08d1534 - Browse repository at this point
Copy the full SHA 08d1534View commit details -
lib/gshadow.c: fgetsgent(): Don't use static variables
Reported-by: Chris Hofstaedtler <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for b6b6a6b - Browse repository at this point
Copy the full SHA b6b6a6bView commit details