summaryrefslogtreecommitdiffstats
path: root/daemon.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-12-23 18:32:10 +0100
committerJunio C Hamano <gitster@pobox.com>2024-12-23 18:32:11 +0100
commit4156b6a741c7fb15a4eccb320612fb6e453f439c (patch)
tree203f68166cc5f2337fd80f6628c3b344d2dd3abf /daemon.c
parentMerge branch 'kn/reftable-writer-log-write-verify' (diff)
parentt/helper: don't depend on implicit wraparound (diff)
downloadgit-4156b6a741c7fb15a4eccb320612fb6e453f439c.tar.xz
git-4156b6a741c7fb15a4eccb320612fb6e453f439c.zip
Merge branch 'ps/build-sign-compare'
Start working to make the codebase buildable with -Wsign-compare. * ps/build-sign-compare: t/helper: don't depend on implicit wraparound scalar: address -Wsign-compare warnings builtin/patch-id: fix type of `get_one_patchid()` builtin/blame: fix type of `length` variable when emitting object ID gpg-interface: address -Wsign-comparison warnings daemon: fix type of `max_connections` daemon: fix loops that have mismatching integer types global: trivial conversions to fix `-Wsign-compare` warnings pkt-line: fix -Wsign-compare warning on 32 bit platform csum-file: fix -Wsign-compare warning on 32-bit platform diff.h: fix index used to loop through unsigned integer config.mak.dev: drop `-Wno-sign-compare` global: mark code units that generate warnings with `-Wsign-compare` compat/win32: fix -Wsign-compare warning in "wWinMain()" compat/regex: explicitly ignore "-Wsign-compare" warnings git-compat-util: introduce macros to disable "-Wsign-compare" warnings
Diffstat (limited to 'daemon.c')
-rw-r--r--daemon.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/daemon.c b/daemon.c
index 756c3f0b02..d1be61fd57 100644
--- a/daemon.c
+++ b/daemon.c
@@ -504,8 +504,7 @@ static struct daemon_service daemon_service[] = {
static void enable_service(const char *name, int ena)
{
- int i;
- for (i = 0; i < ARRAY_SIZE(daemon_service); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(daemon_service); i++) {
if (!strcmp(daemon_service[i].name, name)) {
daemon_service[i].enabled = ena;
return;
@@ -516,8 +515,7 @@ static void enable_service(const char *name, int ena)
static void make_service_overridable(const char *name, int ena)
{
- int i;
- for (i = 0; i < ARRAY_SIZE(daemon_service); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(daemon_service); i++) {
if (!strcmp(daemon_service[i].name, name)) {
daemon_service[i].overridable = ena;
return;
@@ -738,7 +736,7 @@ static void set_keep_alive(int sockfd)
static int execute(void)
{
char *line = packet_buffer;
- int pktlen, len, i;
+ int pktlen, len;
char *addr = getenv("REMOTE_ADDR"), *port = getenv("REMOTE_PORT");
struct hostinfo hi = HOSTINFO_INIT;
struct strvec env = STRVEC_INIT;
@@ -759,7 +757,7 @@ static int execute(void)
if (len != pktlen)
parse_extra_args(&hi, &env, line + len + 1, pktlen - len - 1);
- for (i = 0; i < ARRAY_SIZE(daemon_service); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(daemon_service); i++) {
struct daemon_service *s = &(daemon_service[i]);
const char *arg;
@@ -804,8 +802,7 @@ static int addrcmp(const struct sockaddr_storage *s1,
return 0;
}
-static int max_connections = 32;
-
+static unsigned int max_connections = 32;
static unsigned int live_children;
static struct child {
@@ -1109,8 +1106,8 @@ static void socksetup(struct string_list *listen_addr, int listen_port, struct s
if (!listen_addr->nr)
setup_named_sock(NULL, listen_port, socklist);
else {
- int i, socknum;
- for (i = 0; i < listen_addr->nr; i++) {
+ int socknum;
+ for (size_t i = 0; i < listen_addr->nr; i++) {
socknum = setup_named_sock(listen_addr->items[i].string,
listen_port, socklist);
@@ -1124,11 +1121,10 @@ static void socksetup(struct string_list *listen_addr, int listen_port, struct s
static int service_loop(struct socketlist *socklist)
{
struct pollfd *pfd;
- int i;
CALLOC_ARRAY(pfd, socklist->nr);
- for (i = 0; i < socklist->nr; i++) {
+ for (size_t i = 0; i < socklist->nr; i++) {
pfd[i].fd = socklist->list[i];
pfd[i].events = POLLIN;
}
@@ -1136,8 +1132,6 @@ static int service_loop(struct socketlist *socklist)
signal(SIGCHLD, child_handler);
for (;;) {
- int i;
-
check_dead_children();
if (poll(pfd, socklist->nr, -1) < 0) {
@@ -1149,7 +1143,7 @@ static int service_loop(struct socketlist *socklist)
continue;
}
- for (i = 0; i < socklist->nr; i++) {
+ for (size_t i = 0; i < socklist->nr; i++) {
if (pfd[i].revents & POLLIN) {
union {
struct sockaddr sa;
@@ -1321,10 +1315,11 @@ int cmd_main(int argc, const char **argv)
continue;
}
if (skip_prefix(arg, "--max-connections=", &v)) {
- if (strtol_i(v, 10, &max_connections))
+ int parsed_value;
+ if (strtol_i(v, 10, &parsed_value))
die(_("invalid max-connections '%s', expecting an integer"), v);
- if (max_connections < 0)
- max_connections = 0; /* unlimited */
+ /* A negative value indicates unlimited children. */
+ max_connections = parsed_value < 0 ? 0 : parsed_value;
continue;
}
if (!strcmp(arg, "--strict-paths")) {