diff --git a/builtin/remote-fd.c b/builtin/remote-fd.c index 91dfe07e06..b2a3980b1d 100644 --- a/builtin/remote-fd.c +++ b/builtin/remote-fd.c @@ -40,7 +40,7 @@ static void command_loop(int input_fd, int output_fd) if (!strcmp(buffer, "capabilities")) { printf("*connect\n\n"); fflush(stdout); - } else if (!strncmp(buffer, "connect ", 8)) { + } else if (starts_with(buffer, "connect ")) { printf("\n"); fflush(stdout); if (bidirectional_transfer_loop(input_fd, diff --git a/bundle-uri.c b/bundle-uri.c index 36268dda17..6462ab6deb 100644 --- a/bundle-uri.c +++ b/bundle-uri.c @@ -620,7 +620,7 @@ static int config_to_packet_line(const char *key, const char *value, void *data) { struct packet_reader *writer = data; - if (!strncmp(key, "bundle.", 7)) + if (starts_with(key, "bundle.")) packet_write_fmt(writer->fd, "%s=%s", key, value); return 0; diff --git a/ref-filter.c b/ref-filter.c index a24324123e..f8203c6b05 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -1209,7 +1209,7 @@ static const char *copy_name(const char *buf) { const char *cp; for (cp = buf; *cp && *cp != '\n'; cp++) { - if (!strncmp(cp, " <", 2)) + if (starts_with(cp, " <")) return xmemdupz(buf, cp - buf); } return xstrdup(""); diff --git a/urlmatch.c b/urlmatch.c index b615adc923..620a648efc 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -209,7 +209,7 @@ static char *url_normalize_1(const char *url, struct url_info *out_info, char al */ if (!url_len || strchr(":/?#", *url)) { /* Missing host invalid for all URL schemes except file */ - if (strncmp(norm.buf, "file:", 5)) { + if (!starts_with(norm.buf, "file:")) { if (out_info) { out_info->url = NULL; out_info->err = _("missing host and scheme is not 'file:'"); @@ -268,11 +268,11 @@ static char *url_normalize_1(const char *url, struct url_info *out_info, char al if (url == slash_ptr) { /* Skip ":" port with no number, it's same as default */ } else if (slash_ptr - url == 2 && - !strncmp(norm.buf, "http:", 5) && + starts_with(norm.buf, "http:") && !strncmp(url, "80", 2)) { /* Skip http :80 as it's the default */ } else if (slash_ptr - url == 3 && - !strncmp(norm.buf, "https:", 6) && + starts_with(norm.buf, "https:") && !strncmp(url, "443", 3)) { /* Skip https :443 as it's the default */ } else {