20 compiler warning fixes
authorChris Tallon <chris@vomp.tv>
Thu, 6 Feb 2020 01:50:45 +0000 (01:50 +0000)
committerChris Tallon <chris@vomp.tv>
Thu, 6 Feb 2020 01:50:45 +0000 (01:50 +0000)
12 files changed:
boxstack.cc
dsock.cc
vconnect.cc
vepg.cc
vmute.cc
vrecordinglist.cc
vrecordingmenu.cc
vsleeptimer.cc
vvideolivetv.cc
vvideorec.cc
vvolume.cc
vwelcome.cc

index 0c477d464b307ba359dbd38fa3157ec7b1c38352..69345a030381069eed2b40ecc038997e18bd0d80 100644 (file)
@@ -14,8 +14,7 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
 */
 
 #include "boxstack.h"
@@ -587,12 +586,12 @@ void BoxStack::processMessage(Message* m)
   {
     case Message::CLOSE_ME:
     {
-      remove((Boxx*)m->from);
+      remove(static_cast<Boxx*>(m->from));
       break;
     }
     case Message::ADD_VIEW:
     {
-      Boxx* toAdd = (Boxx*)m->parameter;
+      Boxx* toAdd = reinterpret_cast<Boxx*>(m->parameter);
       add(toAdd);
       toAdd->draw();
       update(toAdd);
index ec793b54e0317714a51c60eda2f2e8bb8c8e1bf3..ebc41dbd6e4ecac9483b8017ed54803304f95667 100644 (file)
--- a/dsock.cc
+++ b/dsock.cc
@@ -14,8 +14,7 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
 */
 
 #include "dsock.h"
@@ -45,7 +44,7 @@ int DatagramSocket::init()
   myAddr.sin_addr.s_addr = getIPNumber(iterate_ip++); // auto-fill with my IP
   memset(&(myAddr.sin_zero), 0, 8);    // zero the rest of the struct
 
-  if (bind(socketnum, (struct sockaddr *)&myAddr, addrlen) == -1)
+  if (bind(socketnum, reinterpret_cast<struct sockaddr *>(&myAddr), addrlen) == -1)
   { perror("bind"); return 0; }
 
   FD_ZERO(&readfds);
@@ -54,7 +53,7 @@ int DatagramSocket::init()
   tv.tv_usec = 0;
 
   int allowed = 1;
-  setsockopt(socketnum, SOL_SOCKET, SO_BROADCAST, (char*)&allowed, sizeof(allowed));
+  setsockopt(socketnum, SOL_SOCKET, SO_BROADCAST, static_cast<void*>(&allowed), sizeof(allowed));
 
   initted = true;
 
@@ -106,7 +105,7 @@ unsigned char DatagramSocket::waitforMessage(unsigned char how)
   {  return 1;  }
 
   if ((mlength = recvfrom(socketnum, buf, MAXBUFLEN, 0,
-      (struct sockaddr *)&theirAddr, &addrlen)) == -1)
+      reinterpret_cast<struct sockaddr *>(&theirAddr), &addrlen)) == -1)
   { perror("recvfrom"); return 0; }
   else
   {
@@ -119,7 +118,7 @@ unsigned char DatagramSocket::waitforMessage(unsigned char how)
       //printf("%s:%i\tIN  %i\t", fromIPA, fromPort, mlength);
       int k;
       for(k = 0; k < mlength; k++)
-        printf("%u ", (unsigned char)buf[k]);
+        printf("%u ", static_cast<unsigned char>(buf[k]));
       printf("\n");
     }
     return 2;
@@ -150,7 +149,7 @@ void DatagramSocket::send(const char *ipa, short port, char *message, int length
     int k;
     UCHAR l;
     for (k = 0; k < length; k++)
-      { l = (UCHAR)message[k]; printf("%u ", l); }
+      { l = static_cast<UCHAR>(message[k]); printf("%u ", l); }
   }
 
   int sentLength = 0;
@@ -164,7 +163,7 @@ void DatagramSocket::send(const char *ipa, short port, char *message, int length
 
   errno = 0;
 
-  sentLength = sendto(socketnum, message, length, 0, (struct sockaddr *)&theirAddr, addrlen);
+  sentLength = sendto(socketnum, message, length, 0, reinterpret_cast<struct sockaddr *>(&theirAddr), addrlen);
   if (sentLength == length)
   {
     if (DSOCKDEBUG) printf(" GOOD\n");
@@ -175,7 +174,7 @@ void DatagramSocket::send(const char *ipa, short port, char *message, int length
     {
       printf(" --BAD--");  fflush(stdout);
     }
-    sentLength = sendto(socketnum, message, length, 0, (struct sockaddr *)&theirAddr, addrlen);
+    sentLength = sendto(socketnum, message, length, 0, reinterpret_cast<struct sockaddr *>(&theirAddr), addrlen);
     if (sentLength == length)
     {
       if (DSOCKDEBUG) printf(" GOOD\n");
@@ -203,17 +202,14 @@ void DatagramSocket::send(const char *ipa, short port, char *message, int length
   }
 }
 
-ULONG DatagramSocket::getIPNumber(ULONG num)
-{
 #ifndef WIN32
+ULONG DatagramSocket::getIPNumber(ULONG)
+{
   return INADDR_ANY;
-
-  // gcc 3.4 says:
-  // warning: Using 'gethostbyname' in statically linked applications requires at runtime
-  // the shared libraries from the glibc version used for linking
-
+}
 #else
-
+ULONG DatagramSocket::getIPNumber(ULONG num)
+{
   char buffer[100];
   ULONG returnaddress;
 
@@ -234,6 +230,5 @@ ULONG DatagramSocket::getIPNumber(ULONG num)
   int get_ip=(num%num_ip);//Just wrap around, if no interface are present any more
   memcpy(&returnaddress, hosts->h_addr_list[get_ip], sizeof(ULONG));
   return returnaddress;
-
-#endif
 }
+#endif
index e5c70cc1de84fbd16fb58a7cf2f3d455e12eb8c5..6982c751ed79b9ac874e04fc289ed0ccd117f58a 100644 (file)
@@ -65,7 +65,7 @@ void VConnect::draw()
   logger->log("VConnect", Log::DEBUG, "Draw done");
 }
 
-int VConnect::handleCommand(int command)
+int VConnect::handleCommand(int /* command */)
 {
   return 1;
 }
diff --git a/vepg.cc b/vepg.cc
index 5354e737b741251347fda5d8bbd469772a96c41a..fe338a7d0bd6d2ed21291adfdab8376e53e3f86a 100644 (file)
--- a/vepg.cc
+++ b/vepg.cc
@@ -14,8 +14,7 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
 */
 /*
     vepg presents a 2 dimensional electronic programme guide with channels down
index a554b9a3f2feab9f250fa8b777be50af8faa7944..3691253a60eb72b85779b10be4346c116de5d74a 100644 (file)
--- a/vmute.cc
+++ b/vmute.cc
@@ -14,8 +14,7 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
 */
 
 #include "vmute.h"
@@ -66,7 +65,7 @@ void VMute::draw()
   Timers::getInstance()->setTimerD(this, 1, 2);
 }
 
-void VMute::timercall(int clientReference)
+void VMute::timercall(int /* clientReference */)
 {
   // delete me!
   Message* m = new Message(); // Delete self
index 9331cb624ce7d2063121c14ec2f2806bc487eb03..f5a66ada445607f98c089ee608e2b01f4fb8399b 100644 (file)
@@ -14,8 +14,7 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
 */
 
 #include "vrecordinglist.h"
@@ -88,7 +87,7 @@ void VRecordingList::processMessage(Message* m)
   else if (m->message == Message::MOVE_RECORDING)
   {
     Log::getInstance()->log("VRecordingList", Log::DEBUG, "Doing move recording");
-    doMoveRecording((Directory*)m->parameter);
+    doMoveRecording(reinterpret_cast<Directory*>(m->parameter));
   }
   else if (m->message == Message::PLAY_SELECTED_RECORDING)
   {
index 49307d0b75ff7133c1f1a207e871c1c7afc3d574..1af32d8d4f2eec2aeab406afc2dd0065f40a17f1 100644 (file)
@@ -182,6 +182,8 @@ int VRecordingMenu::handleCommand(int command)
         BoxStack::getInstance()->update(v);
         return 2;
       }
+
+      [[fallthrough]]; // it won't, as long as sl.getCurrentOptionData() is 1-5, but keep the compiler happy
     }
     case Remote::BACK:
     {
index e1f1814fb47b744abe8c056cb67692941fbb66eb..85c387240c370fbb3e9f33991f8061b5da3aeaed 100644 (file)
@@ -161,7 +161,7 @@ void Sleeptimer::threadMethod()
       Message* m1 = new Message();
       m1->message = Message::ADD_VIEW;
       m1->to = BoxStack::getInstance();
-      m1->parameter = (ULONG)count;
+      m1->parameter = reinterpret_cast<ULONG>(count);
       MessageQueue::getInstance()->postMessage(m1);
     }
     MILLISLEEP(1000);
@@ -224,7 +224,7 @@ void VSleeptimer::draw()
   Timers::getInstance()->setTimerD(this, 1, 2);
 }
 
-void VSleeptimer::timercall(int clientReference)
+void VSleeptimer::timercall(int /* clientReference */)
 {
   // delete me!
   Message* m = new Message(); // Delete self
index 8f05b06fc8235c7d11e9199c85d5d2e4932cb34c..48a5b71c820c66e0d9fb1b75261eda287fa59e53 100644 (file)
@@ -313,6 +313,7 @@ int VVideoLiveTV::handleCommand(int command)
       }
       // else drop through to stop
     }
+    [[fallthrough]];
     case Remote::STOP:
     {
       stop();
index 12650abd5fe8de7574c586ad5af36b67fa2f169e..5b15739a8372f7b3f08aa572d2e8be617e42e40c 100644 (file)
@@ -14,8 +14,7 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
 */
 
 #include <math.h>
@@ -246,7 +245,8 @@ int VVideoRec::handleCommand(int command)
         removeSummary();
         return 2;
       }
-    } // DROP THROUGH
+    }
+    [[fallthrough]];
     case Remote::STOP:
     case Remote::MENU:
     {
index 9c05d626cd6b9128a110b702c3346659e74c66a2..bf9dce1e5cc89ef9e8cccd47cc49066b755a99b8 100644 (file)
@@ -14,8 +14,7 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
 */
 
 #include "vvolume.h"
@@ -82,7 +81,7 @@ void VVolume::draw()
   Timers::getInstance()->setTimerD(this, 1, 2);
 }
 
-void VVolume::timercall(int clientReference)
+void VVolume::timercall(int /* clientReference */)
 {
   // delete me!
   Message* m = new Message(); // Delete self
index d995e4a77101c3f6af533a8c385393dfe3f792bb..5ce34fd79fa457a8e04a6792ae4d388b47f68d80 100644 (file)
@@ -14,8 +14,7 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
 */
 
 #include "vwelcome.h"
@@ -174,7 +173,7 @@ void VWelcome::drawClock()
   Timers::getInstance()->setTimerT(this, 1, dt);
 }
 
-void VWelcome::timercall(int clientReference)
+void VWelcome::timercall(int /* clientReference */)
 {
 #ifndef GRADIENT_DRAWING
   drawClock();