With the creation of mutt_errno_dbg(), a lot of direct errno handling
is now moved inside the macro.

Remove the include header from other parts of the code that are not
directly referencing errno anymore.

Move the "#include <errno.h>" inside the lib.h header, where the macro
is defined, conditionally based on #ifdef DEBUG.  That way callers of
the macro don't have to think about including the header.

Fix three muttdbg() calls in mutt_socket.c that were referencing
strerror(errno) to instead call mutt_errno_dbg().
---
 attach.c        | 1 -
 complete.c      | 1 -
 compress.c      | 1 -
 crypt.c         | 1 -
 curs_main.c     | 1 -
 group.c         | 1 -
 imap/message.c  | 1 -
 lib.h           | 3 +++
 mbox.c          | 1 -
 mutt_sasl.c     | 1 -
 mutt_sasl_gnu.c | 1 -
 mutt_socket.c   | 9 +++------
 mutt_zstrm.c    | 1 -
 pager.c         | 1 -
 pgp.c           | 1 -
 pgppubring.c    | 1 -
 rfc1524.c       | 1 -
 send.c          | 1 -
 smime.c         | 1 -
 system.c        | 1 -
 20 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/attach.c b/attach.c
index 98750901..74cc99e7 100644
--- a/attach.c
+++ b/attach.c
@@ -42,7 +42,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <string.h>
-#include <errno.h>
 
 int mutt_get_tmp_attachment(BODY *a)
 {
diff --git a/complete.c b/complete.c
index 9263bbd7..b2952ae2 100644
--- a/complete.c
+++ b/complete.c
@@ -30,7 +30,6 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <errno.h>
 
 /* given a partial pathname, this routine fills in as much of the rest of the
  * path as is unique.
diff --git a/compress.c b/compress.c
index 546cc33d..2f66434b 100644
--- a/compress.c
+++ b/compress.c
@@ -20,7 +20,6 @@
 #include "config.h"
 #endif
 
-#include <errno.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <unistd.h>
diff --git a/crypt.c b/crypt.c
index 0c1c6d90..e4c8051d 100644
--- a/crypt.c
+++ b/crypt.c
@@ -41,7 +41,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/stat.h>
-#include <errno.h>
 #include <ctype.h>
 
 #include <locale.h>
diff --git a/curs_main.c b/curs_main.c
index 477f25ce..372007ff 100644
--- a/curs_main.c
+++ b/curs_main.c
@@ -60,7 +60,6 @@
 #include <sys/wait.h>
 #include <string.h>
 #include <sys/stat.h>
-#include <errno.h>
 
 #include <assert.h>
 
diff --git a/group.c b/group.c
index 92f8df15..9fb91b41 100644
--- a/group.c
+++ b/group.c
@@ -33,7 +33,6 @@
 #include <unistd.h>
 #include <string.h>
 #include <sys/utsname.h>
-#include <errno.h>
 #include <sys/wait.h>
 
 group_t *mutt_pattern_group(const char *k)
diff --git a/imap/message.c b/imap/message.c
index db36a1a8..d953a9a1 100644
--- a/imap/message.c
+++ b/imap/message.c
@@ -24,7 +24,6 @@
 # include "config.h"
 #endif
 
-#include <errno.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include <limits.h>
diff --git a/lib.h b/lib.h
index 2e48273c..830459d6 100644
--- a/lib.h
+++ b/lib.h
@@ -34,6 +34,9 @@
 # include <limits.h>
 # include <stdarg.h>
 # include <signal.h>
+# ifdef DEBUG
+#  include <errno.h>
+# endif
 
 # ifndef _POSIX_PATH_MAX
 #  include <limits.h>
diff --git a/mbox.c b/mbox.c
index 5c7cfe3e..f584337a 100644
--- a/mbox.c
+++ b/mbox.c
@@ -34,7 +34,6 @@
 #include <string.h>
 #include <utime.h>
 #include <sys/file.h>
-#include <errno.h>
 #include <unistd.h>
 #include <fcntl.h>
 
diff --git a/mutt_sasl.c b/mutt_sasl.c
index b78add78..969019ab 100644
--- a/mutt_sasl.c
+++ b/mutt_sasl.c
@@ -27,7 +27,6 @@
 #include "mutt_sasl.h"
 #include "mutt_socket.h"
 
-#include <errno.h>
 #include <netdb.h>
 #include <sasl/sasl.h>
 #include <sys/socket.h>
diff --git a/mutt_sasl_gnu.c b/mutt_sasl_gnu.c
index 820c011c..9a7a4b87 100644
--- a/mutt_sasl_gnu.c
+++ b/mutt_sasl_gnu.c
@@ -25,7 +25,6 @@
 #include "mutt_sasl_gnu.h"
 #include "mutt_socket.h"
 
-#include <errno.h>
 #include <gsasl.h>
 
 static Gsasl *mutt_gsasl_ctx = NULL;
diff --git a/mutt_socket.c b/mutt_socket.c
index 7581cb7d..79314fe9 100644
--- a/mutt_socket.c
+++ b/mutt_socket.c
@@ -108,8 +108,7 @@ int mutt_socket_write_d(CONNECTION *conn, const char *buf, 
int len, int dbg)
   {
     if ((rc = conn->conn_write(conn, buf + sent, len - sent)) < 0)
     {
-      muttdbg(1, "mutt_socket_write: error writing (%s), closing socket",
-              strerror(errno));
+      mutt_errno_dbg(1, "mutt_socket_write: error writing, closing socket");
       mutt_socket_close(conn);
 
       return -1;
@@ -433,16 +432,14 @@ static int socket_connect(int fd, struct sockaddr *sa)
   {
     struct timeval tv = { SocketReceiveTimeout, 0 };
     if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)) < 0)
-      muttdbg(1, "error setting receive timeout (%s)",
-              strerror(errno));
+      mutt_errno_dbg(1, "error setting receive timeout");
   }
 
   if (SocketSendTimeout > 0)
   {
     struct timeval tv = { SocketSendTimeout, 0 };
     if (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(tv)) < 0)
-      muttdbg(1, "error setting send timeout (%s)",
-              strerror(errno));
+      mutt_errno_dbg(1, "error setting send timeout");
   }
 
   if (connect(fd, sa, sa_size) < 0)
diff --git a/mutt_zstrm.c b/mutt_zstrm.c
index 61b5c996..d5dd4fd3 100644
--- a/mutt_zstrm.c
+++ b/mutt_zstrm.c
@@ -21,7 +21,6 @@
 #endif
 
 #include <zlib.h>
-#include <errno.h>
 
 #include "mutt.h"
 #include "mutt_socket.h"
diff --git a/pager.c b/pager.c
index 92fa152a..e9062702 100644
--- a/pager.c
+++ b/pager.c
@@ -45,7 +45,6 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
-#include <errno.h>
 
 #define ISHEADER(x) ((x) == MT_COLOR_HEADER || (x) == MT_COLOR_HDEFAULT)
 
diff --git a/pgp.c b/pgp.c
index 2a4a165c..d6fcaa85 100644
--- a/pgp.c
+++ b/pgp.c
@@ -42,7 +42,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/stat.h>
-#include <errno.h>
 #include <ctype.h>
 
 #include <locale.h>
diff --git a/pgppubring.c b/pgppubring.c
index 43b8b978..3e8b76ab 100644
--- a/pgppubring.c
+++ b/pgppubring.c
@@ -49,7 +49,6 @@
 extern char *optarg;
 extern int optind;
 #endif
-#include <errno.h>
 
 #include "sha1.h"
 #include "md5.h"
diff --git a/rfc1524.c b/rfc1524.c
index 5f996a4a..f1b13fc9 100644
--- a/rfc1524.c
+++ b/rfc1524.c
@@ -39,7 +39,6 @@
 
 #include <sys/stat.h>
 #include <sys/wait.h>
-#include <errno.h>
 #include <unistd.h>
 
 /* The command semantics include the following:
diff --git a/send.c b/send.c
index 7554967e..65445b1c 100644
--- a/send.c
+++ b/send.c
@@ -44,7 +44,6 @@
 #include <locale.h>
 #include <unistd.h>
 #include <string.h>
-#include <errno.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <dirent.h>
diff --git a/smime.c b/smime.c
index dca780e0..1b1d70fd 100644
--- a/smime.c
+++ b/smime.c
@@ -35,7 +35,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/stat.h>
-#include <errno.h>
 #include <ctype.h>
 
 #include <locale.h>
diff --git a/system.c b/system.c
index 07cc4ad2..498b8a5c 100644
--- a/system.c
+++ b/system.c
@@ -23,7 +23,6 @@
 #include "mutt.h"
 #ifdef USE_IMAP
 # include "imap.h"
-# include <errno.h>
 #endif
 
 #include <stdlib.h>
-- 
2.54.0

Reply via email to