From da5e82e8dcb5ee15e9699dfeaa2de144a8429d88 Mon Sep 17 00:00:00 2001 From: tedu Date: Fri, 9 May 2014 21:30:11 +0000 Subject: [PATCH] stop casting sizeof to int --- usr.sbin/smtpd/expand.c | 10 ++++++---- usr.sbin/smtpd/table.c | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/usr.sbin/smtpd/expand.c b/usr.sbin/smtpd/expand.c index 0cde969f73f..ca8f4e2f7a4 100644 --- a/usr.sbin/smtpd/expand.c +++ b/usr.sbin/smtpd/expand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: expand.c,v 1.26 2014/04/19 12:43:19 gilles Exp $ */ +/* $OpenBSD: expand.c,v 1.27 2014/05/09 21:30:11 tedu Exp $ */ /* * Copyright (c) 2009 Gilles Chehade @@ -193,12 +193,14 @@ static int expand_line_split(char **line, char **ret) { static char buffer[SMTPD_MAXLINESIZE]; - int esc, i, dq, sq; + int esc, dq, sq; + size_t i; char *s; memset(buffer, 0, sizeof buffer); - esc = dq = sq = i = 0; - for (s = *line; (*s) && (i < (int)sizeof(buffer)); ++s) { + esc = dq = sq = 0; + i = 0; + for (s = *line; (*s) && (i < sizeof(buffer)); ++s) { if (esc) { buffer[i++] = *s; esc = 0; diff --git a/usr.sbin/smtpd/table.c b/usr.sbin/smtpd/table.c index b6729204f52..47dc00626b3 100644 --- a/usr.sbin/smtpd/table.c +++ b/usr.sbin/smtpd/table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table.c,v 1.15 2014/04/19 18:01:01 gilles Exp $ */ +/* $OpenBSD: table.c,v 1.16 2014/05/09 21:30:11 tedu Exp $ */ /* * Copyright (c) 2013 Eric Faurot @@ -107,7 +107,7 @@ table_find(const char *name, const char *tag) if (tag == NULL) return dict_get(env->sc_tables_dict, name); - if (snprintf(buf, sizeof(buf), "%s#%s", name, tag) >= (int)sizeof(buf)) { + if ((size_t)snprintf(buf, sizeof(buf), "%s#%s", name, tag) >= sizeof(buf)) { log_warnx("warn: table name too long: %s#%s", name, tag); return (NULL); } @@ -194,8 +194,8 @@ table_create(const char *backend, const char *name, const char *tag, struct stat sb; if (name && tag) { - if (snprintf(buf, sizeof(buf), "%s#%s", name, tag) - >= (int)sizeof(buf)) + if ((size_t)snprintf(buf, sizeof(buf), "%s#%s", name, tag) >= + sizeof(buf)) errx(1, "table_create: name too long \"%s#%s\"", name, tag); name = buf; @@ -205,8 +205,8 @@ table_create(const char *backend, const char *name, const char *tag, errx(1, "table_create: table \"%s\" already defined", name); if ((tb = table_backend_lookup(backend)) == NULL) { - if (snprintf(path, sizeof(path), PATH_TABLES "/table-%s", - backend) >= (int)sizeof(path)) { + if ((size_t)snprintf(path, sizeof(path), PATH_TABLES "/table-%s", + backend) >= sizeof(path)) { errx(1, "table_create: path too long \"" PATH_TABLES "/table-%s\"", backend); } @@ -644,14 +644,14 @@ table_dump_lookup(enum table_service s, union lookup *lk) case K_DOMAIN: ret = snprintf(buf, sizeof(buf), "%s", lk->domain.name); - if (ret == -1 || ret >= (int)sizeof (buf)) + if (ret == -1 || (size_t)ret >= sizeof (buf)) goto err; break; case K_CREDENTIALS: ret = snprintf(buf, sizeof(buf), "%s:%s", lk->creds.username, lk->creds.password); - if (ret == -1 || ret >= (int)sizeof (buf)) + if (ret == -1 || (size_t)ret >= sizeof (buf)) goto err; break; @@ -659,7 +659,7 @@ table_dump_lookup(enum table_service s, union lookup *lk) ret = snprintf(buf, sizeof(buf), "%s/%d", sockaddr_to_text((struct sockaddr *)&lk->netaddr.ss), lk->netaddr.bits); - if (ret == -1 || ret >= (int)sizeof (buf)) + if (ret == -1 || (size_t)ret >= sizeof (buf)) goto err; break; @@ -669,14 +669,14 @@ table_dump_lookup(enum table_service s, union lookup *lk) lk->userinfo.uid, lk->userinfo.gid, lk->userinfo.directory); - if (ret == -1 || ret >= (int)sizeof (buf)) + if (ret == -1 || (size_t)ret >= sizeof (buf)) goto err; break; case K_SOURCE: ret = snprintf(buf, sizeof(buf), "%s", ss_to_text(&lk->source.addr)); - if (ret == -1 || ret >= (int)sizeof (buf)) + if (ret == -1 || (size_t)ret >= sizeof (buf)) goto err; break; @@ -684,14 +684,14 @@ table_dump_lookup(enum table_service s, union lookup *lk) ret = snprintf(buf, sizeof(buf), "%s@%s", lk->mailaddr.user, lk->mailaddr.domain); - if (ret == -1 || ret >= (int)sizeof (buf)) + if (ret == -1 || (size_t)ret >= sizeof (buf)) goto err; break; case K_ADDRNAME: ret = snprintf(buf, sizeof(buf), "%s", lk->addrname.name); - if (ret == -1 || ret >= (int)sizeof (buf)) + if (ret == -1 || (size_t)ret >= sizeof (buf)) goto err; break; -- 2.20.1