mirror of
https://github.com/git/git
synced 2024-10-01 06:05:20 +00:00
f0e578c69c
Add and apply a semantic patch for calling xstrncmpz() to compare a NUL-terminated string with a buffer of a known length instead of using strncmp() and checking the terminating NUL explicitly. This simplifies callers by reducing code duplication. I had to adjust remote.c manually because Coccinelle inexplicably changed the indent of the else branches. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
29 lines
478 B
Plaintext
29 lines
478 B
Plaintext
@@
|
|
expression S, T, L;
|
|
@@
|
|
(
|
|
- strncmp(S, T, L) || S[L]
|
|
+ !!xstrncmpz(S, T, L)
|
|
|
|
|
- strncmp(S, T, L) || S[L] != '\0'
|
|
+ !!xstrncmpz(S, T, L)
|
|
|
|
|
- strncmp(S, T, L) || T[L]
|
|
+ !!xstrncmpz(T, S, L)
|
|
|
|
|
- strncmp(S, T, L) || T[L] != '\0'
|
|
+ !!xstrncmpz(T, S, L)
|
|
|
|
|
- !strncmp(S, T, L) && !S[L]
|
|
+ !xstrncmpz(S, T, L)
|
|
|
|
|
- !strncmp(S, T, L) && S[L] == '\0'
|
|
+ !xstrncmpz(S, T, L)
|
|
|
|
|
- !strncmp(S, T, L) && !T[L]
|
|
+ !xstrncmpz(T, S, L)
|
|
|
|
|
- !strncmp(S, T, L) && T[L] == '\0'
|
|
+ !xstrncmpz(T, S, L)
|
|
)
|