]> granicus.if.org Git - neomutt/commitdiff
tidy: unify sizeof usage
authorRichard Russon <rich@flatcap.org>
Sat, 25 Mar 2017 15:57:40 +0000 (15:57 +0000)
committerRichard Russon <rich@flatcap.org>
Thu, 30 Mar 2017 22:19:16 +0000 (23:19 +0100)
The sizeof operator doesn't always require the argument to be ()'d.
However it wasn't used consistently.  Add ()s to all uses of sizeof.

crypt-gpgme.c
init.c
lib.c
mbox.c
md5.c
parse.c
pgplib.h
signal.c

index 451e5d07788f7baf3cd67483b0ccf1900512c988..31926a3d578f412ddb930a8ac1672231f39b205b 100644 (file)
@@ -285,7 +285,7 @@ static crypt_key_t *crypt_copy_key (crypt_key_t *key)
 {
   crypt_key_t *k = NULL;
 
-  k = safe_calloc (1, sizeof *k);
+  k = safe_calloc (1, sizeof (*k));
   k->kobj = key->kobj;
   gpgme_key_ref (key->kobj);
   k->idx = key->idx;
@@ -971,7 +971,7 @@ static BODY *sign_message (BODY *a, int use_smime)
                       &t->parameter);
   /* Get the micalg from gpgme.  Old gpgme versions don't support this
      for S/MIME so we assume sha-1 in this case. */
-  if (!get_micalg (ctx, use_smime, buf, sizeof buf))
+  if (!get_micalg (ctx, use_smime, buf, sizeof (buf)))
     mutt_set_parameter ("micalg", buf, &t->parameter);
   else if (use_smime)
     mutt_set_parameter ("micalg", "sha1", &t->parameter);
@@ -2370,7 +2370,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s)
      but we know that this may only be text thus we assume Latin-1
      here. */
   if (!mutt_get_body_charset (body_charset, sizeof (body_charset), m))
-    strfcpy (body_charset, "iso-8859-1", sizeof body_charset);
+    strfcpy (body_charset, "iso-8859-1", sizeof (body_charset));
 
   fseeko (s->fpin, m->offset, 0);
   last_pos = m->offset;
@@ -3242,7 +3242,7 @@ parse_dn (const char *string)
   int i;
 
   arraysize = 7; /* C,ST,L,O,OU,CN,email */
-  array = safe_malloc ((arraysize+1) * sizeof *array);
+  array = safe_malloc ((arraysize+1) * sizeof (*array));
   arrayidx = 0;
   while (*string)
     {
@@ -3255,7 +3255,7 @@ parse_dn (const char *string)
           struct dn_array_s *a2 = NULL;
 
           arraysize += 5;
-          a2 = safe_malloc ((arraysize+1) * sizeof *array);
+          a2 = safe_malloc ((arraysize+1) * sizeof (*array));
           for (i=0; i < arrayidx; i++)
             {
               a2[i].key = array[i].key;
@@ -3412,9 +3412,9 @@ static void print_key_info (gpgme_key_t key, FILE *fp)
 
       tm = localtime (&tt);
 #ifdef HAVE_LANGINFO_D_T_FMT
-      strftime (shortbuf, sizeof shortbuf, nl_langinfo (D_T_FMT), tm);
+      strftime (shortbuf, sizeof (shortbuf), nl_langinfo (D_T_FMT), tm);
 #else
-      strftime (shortbuf, sizeof shortbuf, "%c", tm);
+      strftime (shortbuf, sizeof (shortbuf), "%c", tm);
 #endif
       /* L10N: DOTFILL */
       fprintf (fp, _("Valid From : %s\n"), shortbuf);
@@ -3426,9 +3426,9 @@ static void print_key_info (gpgme_key_t key, FILE *fp)
 
       tm = localtime (&tt);
 #ifdef HAVE_LANGINFO_D_T_FMT
-      strftime (shortbuf, sizeof shortbuf, nl_langinfo (D_T_FMT), tm);
+      strftime (shortbuf, sizeof (shortbuf), nl_langinfo (D_T_FMT), tm);
 #else
-      strftime (shortbuf, sizeof shortbuf, "%c", tm);
+      strftime (shortbuf, sizeof (shortbuf), "%c", tm);
 #endif
       /* L10N: DOTFILL */
       fprintf (fp, _("Valid To ..: %s\n"), shortbuf);
@@ -3566,9 +3566,9 @@ static void print_key_info (gpgme_key_t key, FILE *fp)
 
               tm = localtime (&tt);
 #ifdef HAVE_LANGINFO_D_T_FMT
-              strftime (shortbuf, sizeof shortbuf, nl_langinfo (D_T_FMT), tm);
+              strftime (shortbuf, sizeof (shortbuf), nl_langinfo (D_T_FMT), tm);
 #else
-              strftime (shortbuf, sizeof shortbuf, "%c", tm);
+              strftime (shortbuf, sizeof (shortbuf), "%c", tm);
 #endif
               /* L10N: DOTFILL */
               fprintf (fp, _("Valid From : %s\n"), shortbuf);
@@ -3580,9 +3580,9 @@ static void print_key_info (gpgme_key_t key, FILE *fp)
 
               tm = localtime (&tt);
 #ifdef HAVE_LANGINFO_D_T_FMT
-              strftime (shortbuf, sizeof shortbuf, nl_langinfo (D_T_FMT), tm);
+              strftime (shortbuf, sizeof (shortbuf), nl_langinfo (D_T_FMT), tm);
 #else
-              strftime (shortbuf, sizeof shortbuf, "%c", tm);
+              strftime (shortbuf, sizeof (shortbuf), "%c", tm);
 #endif
               /* L10N: DOTFILL */
               fprintf (fp, _("Valid To ..: %s\n"), shortbuf);
@@ -3794,7 +3794,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, int secret)
       if (!n)
         goto no_pgphints;
 
-      patarr = safe_calloc (n+1, sizeof *patarr);
+      patarr = safe_calloc (n+1, sizeof (*patarr));
       for(l=hints, n=0; l; l = l->next)
         {
           if (l->data && *l->data)
@@ -3832,7 +3832,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, int secret)
 
          for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next)
             {
-              k = safe_calloc (1, sizeof *k);
+              k = safe_calloc (1, sizeof (*k));
               k->kobj = key;
               gpgme_key_ref (k->kobj);
               k->idx = idx;
@@ -3878,7 +3878,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, int secret)
 
          for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next)
             {
-              k = safe_calloc (1, sizeof *k);
+              k = safe_calloc (1, sizeof (*k));
               k->kobj = key;
               gpgme_key_ref (k->kobj);
               k->idx = idx;
diff --git a/init.c b/init.c
index 1f67656b90e396ee10e2dfbe101839c707eccf5c..b0dec0d25c447b5e446eec09ecd728c9e62d3948 100644 (file)
--- a/init.c
+++ b/init.c
@@ -3859,7 +3859,7 @@ void mutt_init (int skip_sys_rc, LIST *commands)
     Fqdn = safe_malloc (mutt_strlen (domain) + mutt_strlen (Hostname) + 2);
     sprintf (Fqdn, "%s.%s", NONULL(Hostname), domain); /* __SPRINTF_CHECKED__ */
   }
-  else if (!(getdnsdomainname (buffer, sizeof buffer)))
+  else if (!(getdnsdomainname (buffer, sizeof (buffer))))
   {
     Fqdn = safe_malloc (mutt_strlen (buffer) + mutt_strlen (Hostname) + 2);
     sprintf (Fqdn, "%s.%s", NONULL(Hostname), buffer); /* __SPRINTF_CHECKED__ */
@@ -4038,38 +4038,38 @@ void mutt_init (int skip_sys_rc, LIST *commands)
   {
     do
     {
-      if (mutt_set_xdg_path (kXDGConfigDirs, buffer, sizeof buffer))
+      if (mutt_set_xdg_path (kXDGConfigDirs, buffer, sizeof (buffer)))
         break;
 
-      snprintf (buffer, sizeof buffer, "%s/neomuttrc-%s", SYSCONFDIR, PACKAGE_VERSION);
+      snprintf (buffer, sizeof (buffer), "%s/neomuttrc-%s", SYSCONFDIR, PACKAGE_VERSION);
       if (access (buffer, F_OK) == 0)
         break;
 
-      snprintf (buffer, sizeof buffer, "%s/neomuttrc", SYSCONFDIR);
+      snprintf (buffer, sizeof (buffer), "%s/neomuttrc", SYSCONFDIR);
       if (access (buffer, F_OK) == 0)
         break;
 
-      snprintf (buffer, sizeof buffer, "%s/Muttrc-%s", SYSCONFDIR, MUTT_VERSION);
+      snprintf (buffer, sizeof (buffer), "%s/Muttrc-%s", SYSCONFDIR, MUTT_VERSION);
       if (access (buffer, F_OK) == 0)
         break;
 
-      snprintf (buffer, sizeof buffer, "%s/Muttrc", SYSCONFDIR);
+      snprintf (buffer, sizeof (buffer), "%s/Muttrc", SYSCONFDIR);
       if (access (buffer, F_OK) == 0)
         break;
 
-      snprintf (buffer, sizeof buffer, "%s/neomuttrc-%s", PKGDATADIR, PACKAGE_VERSION);
+      snprintf (buffer, sizeof (buffer), "%s/neomuttrc-%s", PKGDATADIR, PACKAGE_VERSION);
       if (access (buffer, F_OK) == 0)
         break;
 
-      snprintf (buffer, sizeof buffer, "%s/neomuttrc", PKGDATADIR);
+      snprintf (buffer, sizeof (buffer), "%s/neomuttrc", PKGDATADIR);
       if (access (buffer, F_OK) == 0)
         break;
 
-      snprintf (buffer, sizeof buffer, "%s/Muttrc-%s", PKGDATADIR, MUTT_VERSION);
+      snprintf (buffer, sizeof (buffer), "%s/Muttrc-%s", PKGDATADIR, MUTT_VERSION);
       if (access (buffer, F_OK) == 0)
         break;
 
-      snprintf (buffer, sizeof buffer, "%s/Muttrc", PKGDATADIR);
+      snprintf (buffer, sizeof (buffer), "%s/Muttrc", PKGDATADIR);
     } while (0);
     if (access (buffer, F_OK) == 0)
     {
diff --git a/lib.c b/lib.c
index 2123c10468f53f056b5c61531ea4c79b633a7a7c..1757b3af2bf3527e65229c5c118dc2674428d29c 100644 (file)
--- a/lib.c
+++ b/lib.c
@@ -428,8 +428,8 @@ int safe_symlink(const char *oldpath, const char *newpath)
   {
     char abs_oldpath[_POSIX_PATH_MAX];
 
-    if ((getcwd (abs_oldpath, sizeof abs_oldpath) == NULL) ||
-       (strlen (abs_oldpath) + 1 + strlen (oldpath) + 1 > sizeof abs_oldpath))
+    if ((getcwd (abs_oldpath, sizeof (abs_oldpath)) == NULL) ||
+       (strlen (abs_oldpath) + 1 + strlen (oldpath) + 1 > sizeof (abs_oldpath)))
     return -1;
 
     strcat (abs_oldpath, "/");         /* __STRCAT_CHECKED__ */
diff --git a/mbox.c b/mbox.c
index 15f9e617601ce22b8065e4f0661a2a06b296839c..1c91850ee6c341855640012da99d02504f094c49 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -1101,7 +1101,7 @@ static int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
    * sure we seek to the correct location
    */
   if (ctx->magic == MUTT_MMDF)
-    offset -= (sizeof MMDF_SEP - 1);
+    offset -= (sizeof (MMDF_SEP) - 1);
 
   /* allocate space for the new offsets */
   newOffset = safe_calloc (ctx->msgcount - first, sizeof (struct m_update_t));
diff --git a/md5.c b/md5.c
index f1b35faaf0eecc2b2de8ffe7f0ce69aec838972f..55e1cf7b6c17997093a4cf28ef3630fd006c0a61 100644 (file)
--- a/md5.c
+++ b/md5.c
@@ -87,7 +87,7 @@ md5_init_ctx (struct md5_ctx *ctx)
 static inline void
 set_uint32 (char *cp, md5_uint32 v)
 {
-  memcpy (cp, &v, sizeof v);
+  memcpy (cp, &v, sizeof (v));
 }
 
 /* Put result from CTX in first 16 bytes following RESBUF.  The result
@@ -96,10 +96,10 @@ void *
 md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
 {
   char *r = resbuf;
-  set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A));
-  set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B));
-  set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C));
-  set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D));
+  set_uint32 (r + 0 * sizeof (ctx->A), SWAP (ctx->A));
+  set_uint32 (r + 1 * sizeof (ctx->B), SWAP (ctx->B));
+  set_uint32 (r + 2 * sizeof (ctx->C), SWAP (ctx->C));
+  set_uint32 (r + 3 * sizeof (ctx->D), SWAP (ctx->D));
 
   return resbuf;
 }
diff --git a/parse.c b/parse.c
index 0e6584b79323e5ef307fff1a6c5702b396ad0a46..81e3f60c3fe9f3c5bc2029eab34a28ed3f5e7d28 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -838,7 +838,7 @@ time_t mutt_parse_date (const char *s, HEADER *h)
        {
          struct tz_t *tz = NULL;
 
-         tz = bsearch (ptz, TimeZones, sizeof TimeZones/sizeof (struct tz_t),
+         tz = bsearch (ptz, TimeZones, sizeof (TimeZones)/sizeof (struct tz_t),
                        sizeof (struct tz_t),
                        (int (*)(const void *, const void *)) ascii_strcasecmp
                        /* This is safe to do: A pointer to a struct equals
index dc541389f9bfd4ad56355aa066a83c1c34032ccd..63d5420ae5b5151bf591cfd5a9785cbb9ab7e719 100644 (file)
--- a/pgplib.h
+++ b/pgplib.h
@@ -83,7 +83,7 @@ void pgp_free_key(pgp_key_t *kpp);
 
 static inline pgp_key_t pgp_new_keyinfo(void)
 {
-    return safe_calloc (1, sizeof *((pgp_key_t)0));
+    return safe_calloc (1, sizeof (*((pgp_key_t)0)));
 }
 
 #endif /* CRYPT_BACKEND_CLASSIC_PGP */
index aa45b3f4784d29aa1bf42576797ff20320467990..96cbdd7f9850c267ee2da79f4a164eb3b8878d1a 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -240,7 +240,7 @@ void mutt_allow_interrupt (int disposition)
 {
   struct sigaction sa;
 
-  memset (&sa, 0, sizeof sa);
+  memset (&sa, 0, sizeof (sa));
   sa.sa_handler = sighandler;
 #ifdef SA_RESTART
   if (disposition == 0)