[pan: 14/22] More cppcheck inspired cleanup




commit b67590785502799d776148dd113a04bde629c981
Author: Thomas Tanner <thosrtanner googlemail com>
Date:   Sat Jul 9 10:22:48 2022 +0100

    More cppcheck inspired cleanup

 Makefile.am                       |  2 +-
 pan/tasks/nzb.cc                  | 10 +++++++++-
 pan/tasks/socket-impl-openssl.cc  |  2 +-
 pan/tasks/socket-impl-scripted.cc | 11 +++++++----
 pan/usenet-utils/blowfish.h       |  8 ++++++--
 pan/usenet-utils/text-massager.h  |  4 ++++
 uulib/uunconc.c                   |  4 +++-
 uulib/uuscan.c                    |  2 +-
 8 files changed, 32 insertions(+), 11 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index ac95a7a..10182a2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,8 +49,8 @@ EXTRA_DIST = \
  $(man_MANS) \
  $(NULL)
 
+# A note: -j doesn't work reliably on mingw otherwise would be -j 4
 CPPCHECK_CMD = cppcheck \
-    -j 4 \
     --force \
     --inline-suppr \
     --error-exitcode=1 \
diff --git a/pan/tasks/nzb.cc b/pan/tasks/nzb.cc
index da3d7d6..ea20e2d 100644
--- a/pan/tasks/nzb.cc
+++ b/pan/tasks/nzb.cc
@@ -86,7 +86,15 @@ namespace
 
     MyContext (ArticleCache& ac, EncodeCache& ec, ArticleRead& r,
                const ServerRank& rank, const GroupServer& g, const StringView& p):
-      cache(ac), encode_cache(ec), read(r), ranks(rank), gs(g), fallback_path(p) { }
+      cache(ac),
+      encode_cache(ec),
+      read(r),
+      ranks(rank),
+      gs(g),
+      fallback_path(p),
+      bytes(0),
+      number(0)
+    { }
 
     void file_clear () {
       groups.clear ();
diff --git a/pan/tasks/socket-impl-openssl.cc b/pan/tasks/socket-impl-openssl.cc
index 7b12556..4798875 100644
--- a/pan/tasks/socket-impl-openssl.cc
+++ b/pan/tasks/socket-impl-openssl.cc
@@ -537,7 +537,7 @@ GIOChannelSocketGnuTLS :: gnutls_read_line(GString* g, gsize *ret, GError **gerr
   if (_channel->read_buf->len == 0)
   {
     err = gnutls_record_recv (chan->session, tmp, tmp_size);
-    if (ret) *ret = err < 0 ? 0 : err;
+    *ret = err < 0 ? 0 : err;
     if(err < 0)
     {
       if ((err == GNUTLS_E_INTERRUPTED) ||
diff --git a/pan/tasks/socket-impl-scripted.cc b/pan/tasks/socket-impl-scripted.cc
index cb5f4d3..6fdecda 100644
--- a/pan/tasks/socket-impl-scripted.cc
+++ b/pan/tasks/socket-impl-scripted.cc
@@ -17,15 +17,16 @@
  *
  */
 
+#include "socket-impl-scripted.h"
+
 #include <config.h>
 #include <cassert>
 #include <cstdlib>
 #include <pan/general/debug.h>
 #include <pan/general/messages.h>
 #include <pan/general/string-view.h>
-#include "socket-impl-scripted.h"
 
-using namespace pan;
+namespace pan {
 
 const std::string ScriptedSocket::ABORT ("[[[ABORT]]]");
 const std::string ScriptedSocket::NETWORK_ERROR ("[[[NETWORK ERROR]]]");
@@ -48,8 +49,8 @@ ScriptedSocket :: open (const StringView& address UNUSED, int port UNUSED)
 void ScriptedSocket :: write_command (const StringView& chars, Listener * l)
 {
    if (_script.empty()) {
-      debug ("UNEXPECTED [" << chars << ']');
-      assert (!_script.empty());
+      std::cerr << "UNEXPECTED [" << chars << "]\n";
+      abort();
    }
 
    command_and_responses_t cat (_script.front());
@@ -109,3 +110,5 @@ ScriptedSocket :: clear ()
 {
    _script.clear ();
 }
+
+}
diff --git a/pan/usenet-utils/blowfish.h b/pan/usenet-utils/blowfish.h
index 6e06b39..530795e 100644
--- a/pan/usenet-utils/blowfish.h
+++ b/pan/usenet-utils/blowfish.h
@@ -26,8 +26,12 @@ private:
        void            Blowfish_decipher (DWORD *xl, DWORD *xr) ;
 
 public:
-                       CBlowFish () ;
-                       ~CBlowFish () ;
+  CBlowFish () ;
+  ~CBlowFish () ;
+
+  CBlowFish(CBlowFish const &) = delete;
+  CBlowFish &operator=(CBlowFish const &) = delete;
+
        void            Initialize (BYTE key[], int keybytes) ;
        DWORD           GetOutputLength (DWORD lInputLong) ;
        DWORD           Encode (BYTE * pInput, BYTE * pOutput, DWORD lSize) ;
diff --git a/pan/usenet-utils/text-massager.h b/pan/usenet-utils/text-massager.h
index f7e264e..7a46352 100644
--- a/pan/usenet-utils/text-massager.h
+++ b/pan/usenet-utils/text-massager.h
@@ -43,6 +43,10 @@ namespace pan
     public:
       TextMassager ();
       ~TextMassager ();
+
+      TextMassager(TextMassager const &) = delete;
+      TextMassager &operator=(TextMassager const &) = delete;
+
     public:
       static char* rot13_inplace (char * text);
       std::string mute_quotes (const StringView& text) const;
diff --git a/uulib/uunconc.c b/uulib/uunconc.c
index d30f3e2..f3f51aa 100644
--- a/uulib/uunconc.c
+++ b/uulib/uunconc.c
@@ -910,7 +910,9 @@ UUDecodePT (FILE *datain, FILE *dataout, int *state,
 int
 UUDecodeField (char *s, char *d, int method)
 {
-  int z1, z2, z3, z4;
+  //Intialise z2 - z4 to something, just in case the 1st character in s
+  //causes us to break out of the loop below.
+  int z1, z2 = -1, z3 = -1, z4 = -1;
   int count=0;
 
   if (method == B64ENCODED) {
diff --git a/uulib/uuscan.c b/uulib/uuscan.c
index d92acdd..2307d20 100644
--- a/uulib/uuscan.c
+++ b/uulib/uuscan.c
@@ -495,7 +495,7 @@ ParseHeader (headers *theheaders, char *line)
        theheaders->fname = _FP_strdup (thenew);
       }
     }
-    variable = NULL;
+    return theheaders;
   }
   else {
     /*


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]