<<< Date Index >>>     <<< Thread Index >>>

[PATCH] Shrink mutt_buffy_check (noop clean up)



 buffy.c |  54 ++++++++++++++++--------------------------------------
 1 files changed, 16 insertions(+), 38 deletions(-)


# HG changeset patch
# User Aron Griffis <agriffis@xxxxxxxxx>
# Date 1240350248 14400
# Branch HEAD
# Node ID 48011e7f6411a40de83709c63084ed27286ff20a
# Parent  14f9e5f0f7206aadee8ed637e5e701c4e873c8ef
Shrink mutt_buffy_check (noop clean up)

1. Initialize stat structs with { 0 } as done elsewhere in mutt code
2. Avoid the twisted mix of #ifdef USE_IMAP/USE_POP and C conditional.
   The code inside the switch is only relevant to non-imap non-pop
   anyway.
3. "return" is not a function call

Signed-off-by: Aron Griffis <agriffis@xxxxxxxxx>

diff -r 14f9e5f0f720 -r 48011e7f6411 buffy.c
--- a/buffy.c   Tue Apr 21 17:03:56 2009 -0400
+++ b/buffy.c   Tue Apr 21 17:44:08 2009 -0400
@@ -277,17 +277,13 @@
 int mutt_buffy_check (int force)
 {
   BUFFY *tmp;
-  struct stat sb;
+  struct stat sb = { 0 };
   struct dirent *de;
   DIR *dirp;
   char path[_POSIX_PATH_MAX];
-  struct stat contex_sb;
+  struct stat contex_sb = { 0 };
   time_t t;
 
-  sb.st_size=0;
-  contex_sb.st_dev=0;
-  contex_sb.st_ino=0;
-
 #ifdef USE_IMAP
   /* update postponed count as well, on force */
   if (force)
@@ -314,28 +310,24 @@
   if (!Context || Context->magic != M_POP)
 #endif
   /* check device ID and serial number instead of comparing paths */
-  if (!Context || !Context->path || stat (Context->path, &contex_sb) != 0)
-  {
-    contex_sb.st_dev=0;
-    contex_sb.st_ino=0;
-  }
+  if (Context && Context->path)
+    stat (Context->path, &contex_sb);
   
   for (tmp = Incoming; tmp; tmp = tmp->next)
   {
 #ifdef USE_IMAP
     if (tmp->magic != M_IMAP)
+    {
 #endif
     tmp->new = 0;
 
-#ifdef USE_IMAP
-    if (tmp->magic != M_IMAP)
-    {
-#endif
 #ifdef USE_POP
     if (mx_is_pop (tmp->path))
       tmp->magic = M_POP;
     else
+    {
 #endif
+
     if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) 
||
        (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
     {
@@ -346,32 +338,11 @@
       tmp->size = 0;
       continue;
     }
-#ifdef USE_IMAP
-    }
-#endif
 
     /* check to see if the folder is the currently selected folder
      * before polling */
     if (!Context || !Context->path ||
-#if defined USE_IMAP || defined USE_POP
-       ((
-#ifdef USE_IMAP
-       tmp->magic == M_IMAP
-#endif
-#ifdef USE_POP
-#ifdef USE_IMAP
-       ||
-#endif
-       tmp->magic == M_POP
-#endif
-       ) ? mutt_strcmp (tmp->path, Context->path) :
-#endif
-        (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
-#if defined USE_IMAP || defined USE_POP         
-           )
-#endif
-       )
-       
+       sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
     {
       switch (tmp->magic)
       {
@@ -426,6 +397,13 @@
     else if (option(OPTCHECKMBOXSIZE) && Context && Context->path)
       tmp->size = (off_t) sb.st_size;  /* update the size of current folder */
 
+#ifdef USE_POP
+    }
+#endif
+#ifdef USE_IMAP
+    }
+#endif
+
     if (!tmp->new)
       tmp->notified = 0;
     else if (!tmp->notified)
@@ -433,7 +411,7 @@
   }
 
   BuffyDoneTime = BuffyTime;
-  return (BuffyCount);
+  return BuffyCount;
 }
 
 int mutt_buffy_list (void)