diff options
author | June McEnroe <june@causal.agency> | 2019-10-24 18:18:32 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-10-24 18:18:32 -0400 |
commit | 9380231e0ef0398ffb2ad2a6d455ded9fd40e73f (patch) | |
tree | 186d54208299dc88b557088765be48fe75b73530 | |
parent | Register readers by client usernames (diff) | |
download | pounce-9380231e0ef0398ffb2ad2a6d455ded9fd40e73f.tar.gz pounce-9380231e0ef0398ffb2ad2a6d455ded9fd40e73f.zip |
Zero entire Client struct
Does zeroing that extra 4K really matter? I'd rather not have uninitialized reads.
Diffstat (limited to '')
-rw-r--r-- | client.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/client.c b/client.c index eaa8555..4bb1f54 100644 --- a/client.c +++ b/client.c @@ -46,15 +46,10 @@ struct Client { }; struct Client *clientAlloc(struct tls *tls) { - struct Client *client = malloc(sizeof(*client)); - if (!client) err(EX_OSERR, "malloc"); - - client->error = false; + struct Client *client = calloc(1, sizeof(*client)); + if (!client) err(EX_OSERR, "calloc"); client->tls = tls; client->need = NeedNick | NeedUser | (clientPass ? NeedPass : 0); - client->serverTime = false; - client->len = 0; - return client; } @@ -185,12 +180,7 @@ static const struct { static void clientParse(struct Client *client, char *line) { struct Message msg = parse(line); - if (!msg.cmd) { - // FIXME: Identify client in message. - warnx("no command"); - client->error = true; - return; - } + if (!msg.cmd) return; for (size_t i = 0; i < ARRAY_LEN(Handlers); ++i) { if (strcmp(msg.cmd, Handlers[i].cmd)) continue; Handlers[i].fn(client, msg); |