From: rob Date: Sat, 23 Jan 2021 16:11:11 +0000 (+0000) Subject: Remove unused variables found by clang. Additional unused var spotted by eric@. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1997d66f4fc0e870de13f20439a916e5ebccc82d;p=openbsd Remove unused variables found by clang. Additional unused var spotted by eric@. OK mvs@, eric@ --- diff --git a/usr.sbin/smtpd/compress_gzip.c b/usr.sbin/smtpd/compress_gzip.c index e7421cec076..76f0926196b 100644 --- a/usr.sbin/smtpd/compress_gzip.c +++ b/usr.sbin/smtpd/compress_gzip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: compress_gzip.c,v 1.10 2015/12/28 22:08:30 jung Exp $ */ +/* $OpenBSD: compress_gzip.c,v 1.11 2021/01/23 16:11:11 rob Exp $ */ /* * Copyright (c) 2012 Gilles Chehade @@ -129,7 +129,7 @@ compress_gzip_file(FILE *in, FILE *out) { gzFile gzf; char ibuf[GZIP_BUFFER_SIZE]; - int r, w; + int r; int ret = 0; if (in == NULL || out == NULL) @@ -140,7 +140,7 @@ compress_gzip_file(FILE *in, FILE *out) return (0); while ((r = fread(ibuf, 1, GZIP_BUFFER_SIZE, in)) != 0) { - if ((w = gzwrite(gzf, ibuf, r)) != r) + if (gzwrite(gzf, ibuf, r) != r) goto end; } if (!feof(in)) @@ -159,7 +159,7 @@ uncompress_gzip_file(FILE *in, FILE *out) { gzFile gzf; char obuf[GZIP_BUFFER_SIZE]; - int r, w; + int r; int ret = 0; if (in == NULL || out == NULL) @@ -170,7 +170,7 @@ uncompress_gzip_file(FILE *in, FILE *out) return (0); while ((r = gzread(gzf, obuf, sizeof(obuf))) > 0) { - if ((w = fwrite(obuf, r, 1, out)) != 1) + if (fwrite(obuf, r, 1, out) != 1) goto end; } if (!gzeof(gzf)) diff --git a/usr.sbin/smtpd/crypto.c b/usr.sbin/smtpd/crypto.c index b6a7547cf11..4319dd41b14 100644 --- a/usr.sbin/smtpd/crypto.c +++ b/usr.sbin/smtpd/crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.c,v 1.8 2019/06/28 13:32:50 deraadt Exp $ */ +/* $OpenBSD: crypto.c,v 1.9 2021/01/23 16:11:11 rob Exp $ */ /* * Copyright (c) 2013 Gilles Chehade @@ -68,7 +68,7 @@ crypto_encrypt_file(FILE * in, FILE * out) uint8_t iv[IV_SIZE]; uint8_t tag[GCM_TAG_SIZE]; uint8_t version = API_VERSION; - size_t r, w; + size_t r; int len; int ret = 0; struct stat sb; @@ -80,13 +80,13 @@ crypto_encrypt_file(FILE * in, FILE * out) return 0; /* prepend version byte*/ - if ((w = fwrite(&version, 1, sizeof version, out)) != sizeof version) + if (fwrite(&version, 1, sizeof version, out) != sizeof version) return 0; /* generate and prepend IV */ memset(iv, 0, sizeof iv); arc4random_buf(iv, sizeof iv); - if ((w = fwrite(iv, 1, sizeof iv, out)) != sizeof iv) + if (fwrite(iv, 1, sizeof iv, out) != sizeof iv) return 0; ctx = EVP_CIPHER_CTX_new(); @@ -99,7 +99,7 @@ crypto_encrypt_file(FILE * in, FILE * out) while ((r = fread(ibuf, 1, CRYPTO_BUFFER_SIZE, in)) != 0) { if (!EVP_EncryptUpdate(ctx, obuf, &len, ibuf, r)) goto end; - if (len && (w = fwrite(obuf, len, 1, out)) != 1) + if (len && fwrite(obuf, len, 1, out) != 1) goto end; } if (!feof(in)) @@ -108,12 +108,12 @@ crypto_encrypt_file(FILE * in, FILE * out) /* finalize and write last chunk if any */ if (!EVP_EncryptFinal_ex(ctx, obuf, &len)) goto end; - if (len && (w = fwrite(obuf, len, 1, out)) != 1) + if (len && fwrite(obuf, len, 1, out) != 1) goto end; /* get and append tag */ EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, sizeof tag, tag); - if ((w = fwrite(tag, sizeof tag, 1, out)) != 1) + if (fwrite(tag, sizeof tag, 1, out) != 1) goto end; fflush(out); @@ -133,7 +133,7 @@ crypto_decrypt_file(FILE * in, FILE * out) uint8_t iv[IV_SIZE]; uint8_t tag[GCM_TAG_SIZE]; uint8_t version; - size_t r, w; + size_t r; off_t sz; int len; int ret = 0; @@ -190,7 +190,7 @@ crypto_decrypt_file(FILE * in, FILE * out) break; if (!EVP_DecryptUpdate(ctx, obuf, &len, ibuf, r)) goto end; - if (len && (w = fwrite(obuf, len, 1, out)) != 1) + if (len && fwrite(obuf, len, 1, out) != 1) goto end; sz -= r; } @@ -200,7 +200,7 @@ crypto_decrypt_file(FILE * in, FILE * out) /* finalize, write last chunk if any and perform authentication check */ if (!EVP_DecryptFinal_ex(ctx, obuf, &len)) goto end; - if (len && (w = fwrite(obuf, len, 1, out)) != 1) + if (len && fwrite(obuf, len, 1, out) != 1) goto end; fflush(out); diff --git a/usr.sbin/smtpd/iobuf.c b/usr.sbin/smtpd/iobuf.c index e8a178abe24..c899dc50332 100644 --- a/usr.sbin/smtpd/iobuf.c +++ b/usr.sbin/smtpd/iobuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iobuf.c,v 1.13 2020/04/24 11:34:07 eric Exp $ */ +/* $OpenBSD: iobuf.c,v 1.14 2021/01/23 16:11:11 rob Exp $ */ /* * Copyright (c) 2012 Eric Faurot * @@ -403,13 +403,12 @@ ssize_t iobuf_write_tls(struct iobuf *io, void *tls) { struct ioqbuf *q; - int r; ssize_t n; q = io->outq; n = SSL_write(tls, q->buf + q->rpos, q->wpos - q->rpos); if (n <= 0) { - switch ((r = SSL_get_error(tls, n))) { + switch (SSL_get_error(tls, n)) { case SSL_ERROR_WANT_READ: return (IOBUF_WANT_READ); case SSL_ERROR_WANT_WRITE: @@ -433,11 +432,10 @@ ssize_t iobuf_read_tls(struct iobuf *io, void *tls) { ssize_t n; - int r; n = SSL_read(tls, io->buf + io->wpos, iobuf_left(io)); if (n < 0) { - switch ((r = SSL_get_error(tls, n))) { + switch (SSL_get_error(tls, n)) { case SSL_ERROR_WANT_READ: return (IOBUF_WANT_READ); case SSL_ERROR_WANT_WRITE: diff --git a/usr.sbin/smtpd/ioev.c b/usr.sbin/smtpd/ioev.c index d36210fd7dd..8ae0bc30d58 100644 --- a/usr.sbin/smtpd/ioev.c +++ b/usr.sbin/smtpd/ioev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ioev.c,v 1.42 2019/06/12 17:42:53 eric Exp $ */ +/* $OpenBSD: ioev.c,v 1.43 2021/01/23 16:11:11 rob Exp $ */ /* * Copyright (c) 2012 Eric Faurot * @@ -858,7 +858,7 @@ void io_dispatch_accept_tls(int fd, short event, void *humppa) { struct io *io = humppa; - int e, ret; + int ret; io_frame_enter("io_dispatch_accept_tls", io, event); @@ -873,7 +873,7 @@ io_dispatch_accept_tls(int fd, short event, void *humppa) goto leave; } - switch ((e = SSL_get_error(io->tls, ret))) { + switch (SSL_get_error(io->tls, ret)) { case SSL_ERROR_WANT_READ: io_reset(io, EV_READ, io_dispatch_accept_tls); break; @@ -895,7 +895,7 @@ void io_dispatch_connect_tls(int fd, short event, void *humppa) { struct io *io = humppa; - int e, ret; + int ret; io_frame_enter("io_dispatch_connect_tls", io, event); @@ -910,7 +910,7 @@ io_dispatch_connect_tls(int fd, short event, void *humppa) goto leave; } - switch ((e = SSL_get_error(io->tls, ret))) { + switch (SSL_get_error(io->tls, ret)) { case SSL_ERROR_WANT_READ: io_reset(io, EV_READ, io_dispatch_connect_tls); break; diff --git a/usr.sbin/smtpd/lka_filter.c b/usr.sbin/smtpd/lka_filter.c index 3ff8a93c766..07e14bc2c7d 100644 --- a/usr.sbin/smtpd/lka_filter.c +++ b/usr.sbin/smtpd/lka_filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka_filter.c,v 1.66 2020/12/31 08:27:15 martijn Exp $ */ +/* $OpenBSD: lka_filter.c,v 1.67 2021/01/23 16:11:11 rob Exp $ */ /* * Copyright (c) 2018 Gilles Chehade @@ -129,8 +129,6 @@ struct filter_chain { TAILQ_HEAD(, filter_entry) chain[nitems(filter_execs)]; }; -static struct dict filter_smtp_in; - static struct tree sessions; static int filters_inited; @@ -408,14 +406,12 @@ lka_filter_init(void) void lka_filter_register_hook(const char *name, const char *hook) { - struct dict *subsystem; struct filter *filter; const char *filter_name; void *iter; size_t i; if (strncasecmp(hook, "smtp-in|", 8) == 0) { - subsystem = &filter_smtp_in; hook += 8; } else diff --git a/usr.sbin/smtpd/mail.lmtp.c b/usr.sbin/smtpd/mail.lmtp.c index 4bab03f86ba..69e584a6a7b 100644 --- a/usr.sbin/smtpd/mail.lmtp.c +++ b/usr.sbin/smtpd/mail.lmtp.c @@ -316,9 +316,8 @@ stream_file(FILE *conn) { char *line = NULL; size_t linesize = 0; - ssize_t linelen; - while ((linelen = getline(&line, &linesize, stdin)) != -1) { + while (getline(&line, &linesize, stdin) != -1) { line[strcspn(line, "\n")] = '\0'; if (line[0] == '.') fprintf(conn, "."); diff --git a/usr.sbin/smtpd/mail.maildir.c b/usr.sbin/smtpd/mail.maildir.c index 5e55888414c..5fddc1f3dc8 100644 --- a/usr.sbin/smtpd/mail.maildir.c +++ b/usr.sbin/smtpd/mail.maildir.c @@ -129,7 +129,6 @@ maildir_engine(const char *dirname, int junk) FILE *fp; char *line = NULL; size_t linesize = 0; - ssize_t linelen; struct stat sb; char *home; char *extension; @@ -186,7 +185,7 @@ maildir_engine(const char *dirname, int junk) if ((fp = fdopen(fd, "w")) == NULL) err(EX_TEMPFAIL, NULL); - while ((linelen = getline(&line, &linesize, stdin)) != -1) { + while (getline(&line, &linesize, stdin) != -1) { line[strcspn(line, "\n")] = '\0'; if (line[0] == '\0') in_hdr = 0; diff --git a/usr.sbin/smtpd/mail.mboxfile.c b/usr.sbin/smtpd/mail.mboxfile.c index c466e56685d..e24215b158e 100644 --- a/usr.sbin/smtpd/mail.mboxfile.c +++ b/usr.sbin/smtpd/mail.mboxfile.c @@ -67,7 +67,6 @@ mboxfile_engine(const char *sender, const char *filename) FILE *fp; char *line = NULL; size_t linesize = 0; - ssize_t linelen; time_t now; time(&now); @@ -80,7 +79,7 @@ mboxfile_engine(const char *sender, const char *filename) err(EX_TEMPFAIL, NULL); fprintf(fp, "From %s %s", sender, ctime(&now)); - while ((linelen = getline(&line, &linesize, stdin)) != -1) { + while (getline(&line, &linesize, stdin) != -1) { line[strcspn(line, "\n")] = '\0'; if (strncmp(line, "From ", 5) == 0) fprintf(fp, ">%s\n", line); diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index b6783a222f9..c2022bdbeae 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.283 2021/01/19 09:16:20 claudio Exp $ */ +/* $OpenBSD: parse.y,v 1.284 2021/01/23 16:11:11 rob Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -1840,7 +1840,6 @@ filter_phase_connect filterel: STRING { struct filter_config *fr; - struct filter_proc *fp; size_t i; if ((fr = dict_get(conf->sc_filters_dict, $1)) == NULL) { @@ -1863,7 +1862,7 @@ STRING { } if (fr->proc) { - if ((fp = dict_get(&filter_config->chain_procs, fr->proc))) { + if (dict_get(&filter_config->chain_procs, fr->proc)) { yyerror("no proc allowed twice within a filter chain: %s", fr->proc); free($1); YYERROR; @@ -1887,7 +1886,6 @@ filterel filter: FILTER STRING PROC STRING { - struct filter_proc *fp; if (dict_get(conf->sc_filters_dict, $2)) { yyerror("filter already exists with that name: %s", $2); @@ -1895,7 +1893,7 @@ FILTER STRING PROC STRING { free($4); YYERROR; } - if ((fp = dict_get(conf->sc_filter_processes_dict, $4)) == NULL) { + if (dict_get(conf->sc_filter_processes_dict, $4) == NULL) { yyerror("no processor exist with that name: %s", $4); free($4); YYERROR; diff --git a/usr.sbin/smtpd/table_db.c b/usr.sbin/smtpd/table_db.c index daa6a3f8143..97013ed5170 100644 --- a/usr.sbin/smtpd/table_db.c +++ b/usr.sbin/smtpd/table_db.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table_db.c,v 1.21 2019/06/28 13:32:51 deraadt Exp $ */ +/* $OpenBSD: table_db.c,v 1.22 2021/01/23 16:11:11 rob Exp $ */ /* * Copyright (c) 2011 Gilles Chehade @@ -255,7 +255,6 @@ static char * table_db_get_entry(void *hdl, const char *key, size_t *len) { struct dbhandle *handle = hdl; - int ret; DBT dbk; DBT dbv; char pkey[LINE_MAX]; @@ -266,7 +265,7 @@ table_db_get_entry(void *hdl, const char *key, size_t *len) dbk.data = pkey; dbk.size = strlen(pkey) + 1; - if ((ret = handle->db->get(handle->db, &dbk, &dbv, 0)) != 0) + if (handle->db->get(handle->db, &dbk, &dbv, 0) != 0) return NULL; *len = dbv.size;