Skip to content

Commit

Permalink
global: Made all struct initialization using memset() use the same st…
Browse files Browse the repository at this point in the history
…yle.
  • Loading branch information
stephanbosch committed Dec 24, 2016
1 parent 96de409 commit 7074600
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/lib-dcrypt/dcrypt-openssl.c
Expand Up @@ -731,7 +731,7 @@ static
bool dcrypt_openssl_generate_keypair(struct dcrypt_keypair *pair_r, enum dcrypt_key_type kind, unsigned int bits, const char *curve, const char **error_r)
{
EVP_PKEY *pkey = NULL;
memset(pair_r, 0, sizeof(struct dcrypt_keypair));
memset(pair_r, 0, sizeof(*pair_r));
if (kind == DCRYPT_KEY_RSA) {
if (dcrypt_openssl_generate_rsa_key(bits, &pkey, error_r)) {
pair_r->priv = i_new(struct dcrypt_private_key, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/lib-dict/dict-cdb.c
Expand Up @@ -37,7 +37,7 @@ cdb_dict_init(struct dict *driver, const char *uri,
dict->flag = CDB_WITH_NULL | CDB_WITHOUT_NULL;

/* initialize cdb to 0 (unallocated) */
memset(&dict->cdb, 0, sizeof(struct cdb));
memset(&dict->cdb, 0, sizeof(dict->cdb));

dict->fd = open(dict->path, O_RDONLY);
if (dict->fd == -1) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib-dict/dict-db.c
Expand Up @@ -234,8 +234,8 @@ static int db_dict_lookup(struct dict *_dict, pool_t pool,
uint32_t value;
int ret;

memset(&pkey, 0, sizeof(DBT));
memset(&pdata, 0, sizeof(DBT));
memset(&pkey, 0, sizeof(pkey));
memset(&pdata, 0, sizeof(pdata));

pkey.data = (char *)key;
pkey.size = strlen(key);
Expand Down
6 changes: 3 additions & 3 deletions src/lib-http/http-url.c
Expand Up @@ -335,7 +335,7 @@ int http_url_parse(const char *url, struct http_url *base,
flags may also dictate whether relative URLs are allowed/required. */
i_assert((flags & HTTP_URL_PARSE_SCHEME_EXTERNAL) == 0 || base == NULL);

memset(&url_parser, '\0', sizeof(url_parser));
memset(&url_parser, 0, sizeof(url_parser));
uri_parser_init(&url_parser.parser, pool, url);

url_parser.url = p_new(pool, struct http_url, 1);
Expand All @@ -359,7 +359,7 @@ int http_url_request_target_parse(const char *request_target,
struct uri_authority auth;
struct http_url base;

memset(&url_parser, '\0', sizeof(url_parser));
memset(&url_parser, 0, sizeof(url_parser));
parser = &url_parser.parser;
uri_parser_init(parser, pool, host_header);

Expand All @@ -386,7 +386,7 @@ int http_url_request_target_parse(const char *request_target,
base.host = auth.host;
base.port = auth.port;

memset(parser, '\0', sizeof(*parser));
memset(parser, 0, sizeof(*parser));
uri_parser_init(parser, pool, request_target);

url_parser.url = p_new(pool, struct http_url, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/lib-imap/imap-date.c
Expand Up @@ -34,7 +34,7 @@ static const char *imap_parse_date_internal(const char *str, struct tm *tm)
if (str == NULL || *str == '\0')
return NULL;

memset(tm, 0, sizeof(struct tm));
memset(tm, 0, sizeof(*tm));

/* "dd-mon-yyyy [hh:mi:ss +|-zone]"
dd is 1-2 digits and may be prefixed with space or zero. */
Expand Down
2 changes: 1 addition & 1 deletion src/lib-imap/imap-url.c
Expand Up @@ -900,7 +900,7 @@ int imap_url_parse(const char *url, const struct imap_url *base,
i_assert((flags & IMAP_URL_PARSE_REQUIRE_RELATIVE) == 0 || base != NULL);
i_assert((flags & IMAP_URL_PARSE_SCHEME_EXTERNAL) == 0 || base == NULL);

memset(&url_parser, '\0', sizeof(url_parser));
memset(&url_parser, 0, sizeof(url_parser));
uri_parser_init(&url_parser.parser, pool_datastack_create(), url);

url_parser.url = t_new(struct imap_url, 1);
Expand Down
6 changes: 3 additions & 3 deletions src/lib/net.c
Expand Up @@ -654,7 +654,7 @@ int net_gethostbyname(const char *addr, struct ip_addr **ips,
return 0;
}

memset(&hints, 0, sizeof(struct addrinfo));
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;

/* save error to host_error for later use */
Expand Down Expand Up @@ -852,9 +852,9 @@ int net_getunixcred(int fd, struct net_unix_cred *cred_r)

sc = (struct sockcred *)cdata.buf;
sc->sc_uid = sc->sc_euid = sc->sc_gid = sc->sc_egid = -1;
memset(&cdata.ch, 0, sizeof cdata.ch);
memset(&cdata.ch, 0, sizeof(cdata.ch));

memset(&msg, 0, sizeof msg);
memset(&msg, 0, sizeof(msg));

msg.msg_iov = &iov;
msg.msg_iovlen = 1;
Expand Down

0 comments on commit 7074600

Please sign in to comment.