style(9): add parentheses to sizeof even when not strictly required.
MFC after: 3 days
This commit is contained in:
parent
460afc7340
commit
7a494517a4
@ -206,7 +206,7 @@ _fetch_reopen(int sd)
|
||||
conn_t *conn;
|
||||
|
||||
/* allocate and fill connection structure */
|
||||
if ((conn = calloc(1, sizeof *conn)) == NULL)
|
||||
if ((conn = calloc(1, sizeof(*conn))) == NULL)
|
||||
return (NULL);
|
||||
conn->sd = sd;
|
||||
++conn->ref;
|
||||
@ -552,7 +552,7 @@ _fetch_putln(conn_t *conn, const char *str, size_t len)
|
||||
iov[0].iov_base = __DECONST(char *, str);
|
||||
iov[0].iov_len = len;
|
||||
iov[1].iov_base = __DECONST(char *, ENDL);
|
||||
iov[1].iov_len = sizeof ENDL;
|
||||
iov[1].iov_len = sizeof(ENDL);
|
||||
if (len == 0)
|
||||
ret = _fetch_writev(conn, &iov[1], 1);
|
||||
else
|
||||
@ -593,7 +593,7 @@ _fetch_add_entry(struct url_ent **p, int *size, int *len,
|
||||
}
|
||||
|
||||
if (*len >= *size - 1) {
|
||||
tmp = realloc(*p, (*size * 2 + 1) * sizeof **p);
|
||||
tmp = realloc(*p, (*size * 2 + 1) * sizeof(**p));
|
||||
if (tmp == NULL) {
|
||||
errno = ENOMEM;
|
||||
_fetch_syserr();
|
||||
@ -605,7 +605,7 @@ _fetch_add_entry(struct url_ent **p, int *size, int *len,
|
||||
|
||||
tmp = *p + *len;
|
||||
snprintf(tmp->name, PATH_MAX, "%s", name);
|
||||
bcopy(us, &tmp->stat, sizeof *us);
|
||||
bcopy(us, &tmp->stat, sizeof(*us));
|
||||
|
||||
(*len)++;
|
||||
(++tmp)->name[0] = 0;
|
||||
@ -638,7 +638,7 @@ _fetch_netrc_auth(struct url *url)
|
||||
FILE *f;
|
||||
|
||||
if ((p = getenv("NETRC")) != NULL) {
|
||||
if (snprintf(fn, sizeof fn, "%s", p) >= (int)sizeof(fn)) {
|
||||
if (snprintf(fn, sizeof(fn), "%s", p) >= (int)sizeof(fn)) {
|
||||
_fetch_info("$NETRC specifies a file name "
|
||||
"longer than PATH_MAX");
|
||||
return (-1);
|
||||
@ -651,7 +651,7 @@ _fetch_netrc_auth(struct url *url)
|
||||
(p = pwd->pw_dir) == NULL)
|
||||
return (-1);
|
||||
}
|
||||
if (snprintf(fn, sizeof fn, "%s/.netrc", p) >= (int)sizeof(fn))
|
||||
if (snprintf(fn, sizeof(fn), "%s/.netrc", p) >= (int)sizeof(fn))
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@ -675,7 +675,7 @@ _fetch_netrc_auth(struct url *url)
|
||||
if (strcmp(word, "login") == 0) {
|
||||
if ((word = _fetch_read_word(f)) == NULL)
|
||||
goto ferr;
|
||||
if (snprintf(url->user, sizeof url->user,
|
||||
if (snprintf(url->user, sizeof(url->user),
|
||||
"%s", word) > (int)sizeof(url->user)) {
|
||||
_fetch_info("login name in .netrc is too long");
|
||||
url->user[0] = '\0';
|
||||
@ -683,7 +683,7 @@ _fetch_netrc_auth(struct url *url)
|
||||
} else if (strcmp(word, "password") == 0) {
|
||||
if ((word = _fetch_read_word(f)) == NULL)
|
||||
goto ferr;
|
||||
if (snprintf(url->pwd, sizeof url->pwd,
|
||||
if (snprintf(url->pwd, sizeof(url->pwd),
|
||||
"%s", word) > (int)sizeof(url->pwd)) {
|
||||
_fetch_info("password in .netrc is too long");
|
||||
url->pwd[0] = '\0';
|
||||
|
@ -274,7 +274,7 @@ fetchMakeURL(const char *scheme, const char *host, int port, const char *doc,
|
||||
}
|
||||
|
||||
/* allocate struct url */
|
||||
if ((u = calloc(1, sizeof *u)) == NULL) {
|
||||
if ((u = calloc(1, sizeof(*u))) == NULL) {
|
||||
_fetch_syserr();
|
||||
return (NULL);
|
||||
}
|
||||
@ -285,7 +285,7 @@ fetchMakeURL(const char *scheme, const char *host, int port, const char *doc,
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#define seturl(x) snprintf(u->x, sizeof u->x, "%s", x)
|
||||
#define seturl(x) snprintf(u->x, sizeof(u->x), "%s", x)
|
||||
seturl(scheme);
|
||||
seturl(host);
|
||||
seturl(user);
|
||||
@ -310,7 +310,7 @@ fetchParseURL(const char *URL)
|
||||
int i;
|
||||
|
||||
/* allocate struct url */
|
||||
if ((u = calloc(1, sizeof *u)) == NULL) {
|
||||
if ((u = calloc(1, sizeof(*u))) == NULL) {
|
||||
_fetch_syserr();
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -127,11 +127,11 @@ fetchListFile(struct url *u, const char *flags __unused)
|
||||
}
|
||||
|
||||
ue = NULL;
|
||||
strncpy(fn, u->doc, sizeof fn - 2);
|
||||
fn[sizeof fn - 2] = 0;
|
||||
strncpy(fn, u->doc, sizeof(fn) - 2);
|
||||
fn[sizeof(fn) - 2] = 0;
|
||||
strcat(fn, "/");
|
||||
p = strchr(fn, 0);
|
||||
l = sizeof fn - strlen(fn) - 1;
|
||||
l = sizeof(fn) - strlen(fn) - 1;
|
||||
|
||||
while ((de = readdir(dir)) != NULL) {
|
||||
strncpy(p, de->d_name, l - 1);
|
||||
|
@ -434,7 +434,7 @@ _ftp_setup(conn_t *cconn, conn_t *dconn, int mode)
|
||||
|
||||
if (cconn == NULL || dconn == NULL)
|
||||
return (NULL);
|
||||
if ((io = malloc(sizeof *io)) == NULL)
|
||||
if ((io = malloc(sizeof(*io))) == NULL)
|
||||
return (NULL);
|
||||
io->cconn = cconn;
|
||||
io->dconn = dconn;
|
||||
@ -473,7 +473,7 @@ _ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
strncasecmp(s, "no", 2) != 0);
|
||||
|
||||
/* find our own address, bind, and listen */
|
||||
l = sizeof sa;
|
||||
l = sizeof(sa);
|
||||
if (getsockname(conn->sd, (struct sockaddr *)&sa, &l) == -1)
|
||||
goto sysouch;
|
||||
if (sa.ss_family == AF_INET6)
|
||||
@ -559,7 +559,7 @@ _ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
goto sysouch;
|
||||
|
||||
/* construct sockaddr for data socket */
|
||||
l = sizeof sa;
|
||||
l = sizeof(sa);
|
||||
if (getpeername(conn->sd, (struct sockaddr *)&sa, &l) == -1)
|
||||
goto sysouch;
|
||||
if (sa.ss_family == AF_INET6)
|
||||
@ -622,7 +622,7 @@ _ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
((struct sockaddr_in *)&sa)->sin_port = 0;
|
||||
arg = low ? IP_PORTRANGE_DEFAULT : IP_PORTRANGE_HIGH;
|
||||
if (setsockopt(sd, IPPROTO_IP, IP_PORTRANGE,
|
||||
(char *)&arg, sizeof arg) == -1)
|
||||
(char *)&arg, sizeof(arg)) == -1)
|
||||
goto sysouch;
|
||||
break;
|
||||
}
|
||||
@ -756,7 +756,7 @@ _ftp_authenticate(conn_t *conn, struct url *url, struct url *purl)
|
||||
len = 0;
|
||||
else if (len > MAXLOGNAME)
|
||||
len = MAXLOGNAME;
|
||||
gethostname(pbuf + len, sizeof pbuf - len);
|
||||
gethostname(pbuf + len, sizeof(pbuf) - len);
|
||||
pwd = pbuf;
|
||||
}
|
||||
e = _ftp_cmd(conn, "PASS %s", pwd);
|
||||
@ -881,7 +881,7 @@ _ftp_cached_connect(struct url *url, struct url *purl, const char *flags)
|
||||
if (cached_connection)
|
||||
_ftp_disconnect(cached_connection);
|
||||
cached_connection = _fetch_ref(conn);
|
||||
memcpy(&cached_host, url, sizeof *url);
|
||||
memcpy(&cached_host, url, sizeof(*url));
|
||||
return (conn);
|
||||
}
|
||||
|
||||
|
@ -304,7 +304,7 @@ _http_funopen(conn_t *conn, int chunked)
|
||||
struct httpio *io;
|
||||
FILE *f;
|
||||
|
||||
if ((io = calloc(1, sizeof *io)) == NULL) {
|
||||
if ((io = calloc(1, sizeof(*io))) == NULL) {
|
||||
_fetch_syserr();
|
||||
return (NULL);
|
||||
}
|
||||
@ -470,7 +470,7 @@ _http_parse_mtime(const char *p, time_t *mtime)
|
||||
char locale[64], *r;
|
||||
struct tm tm;
|
||||
|
||||
strncpy(locale, setlocale(LC_TIME, NULL), sizeof locale);
|
||||
strncpy(locale, setlocale(LC_TIME, NULL), sizeof(locale));
|
||||
setlocale(LC_TIME, "C");
|
||||
r = strptime(p, "%a, %d %b %Y %H:%M:%S GMT", &tm);
|
||||
/* XXX should add support for date-2 and date-3 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user